Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2003-2014 LOGILAB S.A. (Paris, FRANCE). | 1 # Copyright (c) 2003-2014 LOGILAB S.A. (Paris, FRANCE). |
| 2 # http://www.logilab.fr/ -- mailto:contact@logilab.fr | 2 # http://www.logilab.fr/ -- mailto:contact@logilab.fr |
| 3 # | 3 # |
| 4 # This program is free software; you can redistribute it and/or modify it under | 4 # This program is free software; you can redistribute it and/or modify it under |
| 5 # the terms of the GNU General Public License as published by the Free Software | 5 # the terms of the GNU General Public License as published by the Free Software |
| 6 # Foundation; either version 2 of the License, or (at your option) any later | 6 # Foundation; either version 2 of the License, or (at your option) any later |
| 7 # version. | 7 # version. |
| 8 # | 8 # |
| 9 # This program is distributed in the hope that it will be useful, but WITHOUT | 9 # This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 # initialize msgs_state now that all messages have been registered into | 664 # initialize msgs_state now that all messages have been registered into |
| 665 # the store | 665 # the store |
| 666 for msg in self.msgs_store.messages: | 666 for msg in self.msgs_store.messages: |
| 667 if not msg.may_be_emitted(): | 667 if not msg.may_be_emitted(): |
| 668 self._msgs_state[msg.msgid] = False | 668 self._msgs_state[msg.msgid] = False |
| 669 | 669 |
| 670 if not isinstance(files_or_modules, (list, tuple)): | 670 if not isinstance(files_or_modules, (list, tuple)): |
| 671 files_or_modules = (files_or_modules,) | 671 files_or_modules = (files_or_modules,) |
| 672 | 672 |
| 673 if self.config.jobs == 1: | 673 if self.config.jobs == 1: |
| 674 self._do_check(files_or_modules) | 674 with fix_import_path(files_or_modules): |
|
iannucci
2015/06/25 01:54:32
note that all child checkers come through here
| |
| 675 self._do_check(files_or_modules) | |
| 675 else: | 676 else: |
| 676 # Hack that permits running pylint, on Windows, with -m switch | 677 # Hack that permits running pylint, on Windows, with -m switch |
| 677 # and with --jobs, as in 'python -2 -m pylint .. --jobs'. | 678 # and with --jobs, as in 'python -2 -m pylint .. --jobs'. |
| 678 # For more details why this is needed, | 679 # For more details why this is needed, |
| 679 # see Python issue http://bugs.python.org/issue10845. | 680 # see Python issue http://bugs.python.org/issue10845. |
| 680 | 681 |
| 681 mock_main = __name__ != '__main__' # -m switch | 682 mock_main = __name__ != '__main__' # -m switch |
| 682 if mock_main: | 683 if mock_main: |
| 683 sys.modules['__main__'] = sys.modules[__name__] | 684 sys.modules['__main__'] = sys.modules[__name__] |
| 684 try: | 685 try: |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 if multiprocessing is None: | 1246 if multiprocessing is None: |
| 1246 print("Multiprocessing library is missing, " | 1247 print("Multiprocessing library is missing, " |
| 1247 "fallback to single process", file=sys.stderr) | 1248 "fallback to single process", file=sys.stderr) |
| 1248 linter.set_option("jobs", 1) | 1249 linter.set_option("jobs", 1) |
| 1249 else: | 1250 else: |
| 1250 if linter.config.jobs == 0: | 1251 if linter.config.jobs == 0: |
| 1251 linter.config.jobs = multiprocessing.cpu_count() | 1252 linter.config.jobs = multiprocessing.cpu_count() |
| 1252 | 1253 |
| 1253 # insert current working directory to the python path to have a correct | 1254 # insert current working directory to the python path to have a correct |
| 1254 # behaviour | 1255 # behaviour |
| 1255 with fix_import_path(args): | 1256 if self.linter.config.profile: |
| 1256 if self.linter.config.profile: | 1257 with fix_import_path(args): |
| 1257 print('** profiled run', file=sys.stderr) | 1258 print('** profiled run', file=sys.stderr) |
| 1258 import cProfile, pstats | 1259 import cProfile, pstats |
| 1259 cProfile.runctx('linter.check(%r)' % args, globals(), locals(), | 1260 cProfile.runctx('linter.check(%r)' % args, globals(), locals(), |
| 1260 'stones.prof') | 1261 'stones.prof') |
| 1261 data = pstats.Stats('stones.prof') | 1262 data = pstats.Stats('stones.prof') |
| 1262 data.strip_dirs() | 1263 data.strip_dirs() |
| 1263 data.sort_stats('time', 'calls') | 1264 data.sort_stats('time', 'calls') |
| 1264 data.print_stats(30) | 1265 data.print_stats(30) |
| 1265 else: | 1266 else: |
| 1266 linter.check(args) | 1267 linter.check(args) |
| 1267 linter.generate_reports() | 1268 linter.generate_reports() |
|
iannucci
2015/06/25 01:54:32
report generation doesn't actually require the pat
| |
| 1268 if exit: | 1269 if exit: |
| 1269 sys.exit(self.linter.msg_status) | 1270 sys.exit(self.linter.msg_status) |
| 1270 | 1271 |
| 1271 def cb_set_rcfile(self, name, value): | 1272 def cb_set_rcfile(self, name, value): |
| 1272 """callback for option preprocessing (i.e. before option parsing)""" | 1273 """callback for option preprocessing (i.e. before option parsing)""" |
| 1273 self._rcfile = value | 1274 self._rcfile = value |
| 1274 | 1275 |
| 1275 def cb_add_plugins(self, name, value): | 1276 def cb_add_plugins(self, name, value): |
| 1276 """callback for option preprocessing (i.e. before option parsing)""" | 1277 """callback for option preprocessing (i.e. before option parsing)""" |
| 1277 self._plugins.extend(textutils.splitstrip(value)) | 1278 self._plugins.extend(textutils.splitstrip(value)) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1323 print('%-18s: %s' % level) | 1324 print('%-18s: %s' % level) |
| 1324 sys.exit(0) | 1325 sys.exit(0) |
| 1325 | 1326 |
| 1326 def cb_init_hook(optname, value): | 1327 def cb_init_hook(optname, value): |
| 1327 """exec arbitrary code to set sys.path for instance""" | 1328 """exec arbitrary code to set sys.path for instance""" |
| 1328 exec(value) # pylint: disable=exec-used | 1329 exec(value) # pylint: disable=exec-used |
| 1329 | 1330 |
| 1330 | 1331 |
| 1331 if __name__ == '__main__': | 1332 if __name__ == '__main__': |
| 1332 Run(sys.argv[1:]) | 1333 Run(sys.argv[1:]) |
| OLD | NEW |