Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: tools-webrtc/check_package_boundaries.py

Issue 2695573003: Fix check_package_boundaries presubmit test for Windows. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools-webrtc/check_package_boundaries_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license 5 # Use of this source code is governed by a BSD-style license
6 # that can be found in the LICENSE file in the root of the source 6 # that can be found in the LICENSE file in the root of the source
7 # tree. An additional intellectual property rights grant can be found 7 # tree. An additional intellectual property rights grant can be found
8 # in the file PATENTS. All contributing project authors may 8 # in the file PATENTS. All contributing project authors may
9 # be found in the AUTHORS file in the root of the source tree. 9 # be found in the AUTHORS file in the root of the source tree.
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 else: 47 else:
48 self.messages_left -= 1 48 self.messages_left -= 1
49 message = ERROR_MESSAGE.format(build_file_path, line_number, target_name, 49 message = ERROR_MESSAGE.format(build_file_path, line_number, target_name,
50 source_file, subpackage) 50 source_file, subpackage)
51 logging.log(self.log_level, message) 51 logging.log(self.log_level, message)
52 52
53 53
54 def _BuildSubpackagesPattern(packages, query): 54 def _BuildSubpackagesPattern(packages, query):
55 """Returns a regular expression that matches source files inside subpackages 55 """Returns a regular expression that matches source files inside subpackages
56 of the given query.""" 56 of the given query."""
57 query += '/' 57 query += os.path.sep
58 length = len(query) 58 length = len(query)
59 pattern = r'(?P<line_number>\d+)\$\s*"(?P<source_file>(?P<subpackage>' 59 pattern = r'(?P<line_number>\d+)\$\s*"(?P<source_file>(?P<subpackage>'
60 pattern += '|'.join(package[length:] for package in packages 60 pattern += '|'.join(package[length:].replace(os.path.sep, '/')
61 if package.startswith(query)) 61 for package in packages if package.startswith(query))
62 pattern += r')/[\w\./]*)"' 62 pattern += r')/[\w\./]*)"'
63 return re.compile(pattern) 63 return re.compile(pattern)
64 64
65 65
66 def _ReadFileAndPrependLines(file_path): 66 def _ReadFileAndPrependLines(file_path):
67 """Reads the contents of a file and prepends the line number to every line.""" 67 """Reads the contents of a file and prepends the line number to every line."""
68 with open(file_path) as f: 68 with open(file_path) as f:
69 return "".join("{}${}".format(line_number, line) 69 return "".join("{}${}".format(line_number, line)
70 for line_number, line in enumerate(f, 1)) 70 for line_number, line in enumerate(f, 1))
71 71
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 logging.basicConfig(format=LOG_FORMAT) 129 logging.basicConfig(format=LOG_FORMAT)
130 logging.getLogger().setLevel(DISPLAY_LEVEL) 130 logging.getLogger().setLevel(DISPLAY_LEVEL)
131 logger = Logger(args.max_messages) 131 logger = Logger(args.max_messages)
132 132
133 return CheckPackageBoundaries(args.root_dir, logger, args.build_files) 133 return CheckPackageBoundaries(args.root_dir, logger, args.build_files)
134 134
135 135
136 if __name__ == '__main__': 136 if __name__ == '__main__':
137 sys.exit(main()) 137 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools-webrtc/check_package_boundaries_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698