__main__.py 576 B

123456789101112131415
  1. """Be able to execute coverage.py by pointing Python at a working tree."""
  2. import runpy, os
  3. PKG = 'coverage'
  4. try:
  5. run_globals = runpy.run_module(PKG, run_name='__main__', alter_sys=True)
  6. executed = os.path.splitext(os.path.basename(run_globals['__file__']))[0]
  7. if executed != '__main__': # For Python 2.5 compatibility
  8. raise ImportError(
  9. 'Incorrectly executed %s instead of __main__' % executed
  10. )
  11. except ImportError: # For Python 2.6 compatibility
  12. runpy.run_module('%s.__main__' % PKG, run_name='__main__', alter_sys=True)