| OLD | NEW |
| 1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 |
| 2 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt |
| 3 |
| 1 """Be able to execute coverage.py by pointing Python at a working tree.""" | 4 """Be able to execute coverage.py by pointing Python at a working tree.""" |
| 2 | 5 |
| 3 import runpy, os | 6 import runpy, os |
| 4 | 7 |
| 5 PKG = 'coverage' | 8 PKG = 'coverage' |
| 6 | 9 |
| 7 try: | 10 try: |
| 8 run_globals = runpy.run_module(PKG, run_name='__main__', alter_sys=True) | 11 run_globals = runpy.run_module(PKG, run_name='__main__', alter_sys=True) |
| 9 executed = os.path.splitext(os.path.basename(run_globals['__file__']))[0] | 12 executed = os.path.splitext(os.path.basename(run_globals['__file__']))[0] |
| 10 if executed != '__main__': # For Python 2.5 compatibility | 13 if executed != '__main__': # For Python 2.5 compatibility |
| 11 raise ImportError( | 14 raise ImportError( |
| 12 'Incorrectly executed %s instead of __main__' % executed | 15 'Incorrectly executed %s instead of __main__' % executed |
| 13 ) | 16 ) |
| 14 except ImportError: # For Python 2.6 compatibility | 17 except ImportError: # For Python 2.6 compatibility |
| 15 runpy.run_module('%s.__main__' % PKG, run_name='__main__', alter_sys=True) | 18 runpy.run_module('%s.__main__' % PKG, run_name='__main__', alter_sys=True) |
| OLD | NEW |