Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 __version__ = '1.8.0' | 9 __version__ = '1.8.0' |
| 10 | 10 |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1086 break | 1086 break |
| 1087 parent_dir = os.path.dirname(directory) | 1087 parent_dir = os.path.dirname(directory) |
| 1088 if parent_dir == directory: | 1088 if parent_dir == directory: |
| 1089 # We hit the system root directory. | 1089 # We hit the system root directory. |
| 1090 break | 1090 break |
| 1091 directory = parent_dir | 1091 directory = parent_dir |
| 1092 | 1092 |
| 1093 # Look for PRESUBMIT.py in all candidate directories. | 1093 # Look for PRESUBMIT.py in all candidate directories. |
| 1094 results = [] | 1094 results = [] |
| 1095 for directory in sorted(list(candidates)): | 1095 for directory in sorted(list(candidates)): |
| 1096 for f in os.listdir(directory): | 1096 try: |
| 1097 directory_files = os.listdir(directory) | |
| 1098 except OSError: | |
| 1099 directory_files = [] | |
|
tandrii(chromium)
2016/08/17 09:39:13
continue
it's shorter and faster.
Tobias Sargeant
2016/08/17 09:57:45
Thanks. It seems like it's best to just wrap the w
| |
| 1100 for f in directory_files: | |
| 1097 p = os.path.join(directory, f) | 1101 p = os.path.join(directory, f) |
| 1098 if os.path.isfile(p) and re.match( | 1102 if os.path.isfile(p) and re.match( |
| 1099 r'PRESUBMIT.*\.py$', f) and not f.startswith('PRESUBMIT_test'): | 1103 r'PRESUBMIT.*\.py$', f) and not f.startswith('PRESUBMIT_test'): |
| 1100 results.append(p) | 1104 results.append(p) |
| 1101 | 1105 |
| 1102 logging.debug('Presubmit files: %s', ','.join(results)) | 1106 logging.debug('Presubmit files: %s', ','.join(results)) |
| 1103 return results | 1107 return results |
| 1104 | 1108 |
| 1105 | 1109 |
| 1106 class GetTrySlavesExecuter(object): | 1110 class GetTrySlavesExecuter(object): |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1822 return 2 | 1826 return 2 |
| 1823 | 1827 |
| 1824 | 1828 |
| 1825 if __name__ == '__main__': | 1829 if __name__ == '__main__': |
| 1826 fix_encoding.fix_encoding() | 1830 fix_encoding.fix_encoding() |
| 1827 try: | 1831 try: |
| 1828 sys.exit(main()) | 1832 sys.exit(main()) |
| 1829 except KeyboardInterrupt: | 1833 except KeyboardInterrupt: |
| 1830 sys.stderr.write('interrupted\n') | 1834 sys.stderr.write('interrupted\n') |
| 1831 sys.exit(2) | 1835 sys.exit(2) |
| OLD | NEW |