1. Ronald Oussoren
  2. modulegraph

Commits

Ronald Oussoren  committed ea77a2a

Run 'reindent.py' to remove trailing whitespace

  • Participants
  • Parent commits 653401b
  • Branches default

Comments (0)

Files changed (24)

File modulegraph/__init__.py

View file
  • Ignore whitespace
 import pkg_resources
 __version__ = pkg_resources.require('modulegraph')[0].version
-

File modulegraph/find_modules.py

View file
  • Ignore whitespace
 =========================================================================
 
 History
-........ 
+........
 
 Originally (loosely) based on code in py2exe's build_exe.py by Thomas Heller.
 """
     """
     Return two lists: the first one contains the python files in the graph,
     the second the C extensions.
-    
+
     :param mf: a :class:`modulegraph.modulegraph.ModuleGraph` instance
     """
     #for name, imports in get_hidden_imports().items():
     High-level interface, takes iterables for:
         scripts, includes, packages, excludes
 
-    And returns a :class:`modulegraph.modulegraph.ModuleGraph` instance, 
+    And returns a :class:`modulegraph.modulegraph.ModuleGraph` instance,
     python_files, and extensions
 
     python_files is a list of pure python dependencies as modulegraph.Module objects,

File modulegraph/modulegraph.py

View file
  • Ignore whitespace
 Based on the stdlib modulefinder by Thomas Heller and Just van Rossum,
 but uses a graph data structure and 2.3 features
 
-XXX: Verify all calls to import_hook (and variants) to ensure that 
+XXX: Verify all calls to import_hook (and variants) to ensure that
 imports are done in the right way.
 """
 from __future__ import absolute_import, print_function
 
 if sys.version_info[0] == 2:
     from StringIO import StringIO as BytesIO
-    from StringIO import StringIO 
+    from StringIO import StringIO
     from  urllib import pathname2url
     def _Bchr(value):
         return chr(value)
 
 
 # File open mode for reading (univeral newlines)
-_READ_MODE = "rU"  
+_READ_MODE = "rU"
 
 
 
 _packagePathMap = {}
 
 # Prefix used in magic .pth files used by setuptools to create namespace
-# packages without an __init__.py file. 
+# packages without an __init__.py file.
 #
-# The value is a list of such prefixes as the prefix varies with versions of 
+# The value is a list of such prefixes as the prefix varies with versions of
 # setuptools.
 _SETUPTOOLS_NAMESPACEPKG_PTHs=(
     "import sys,types,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('",
 )
 
 
-def _namespace_package_path(fqname, pathnames): 
+def _namespace_package_path(fqname, pathnames):
     """
     Return the __path__ for the python package in *fqname*.
 
     Deprecated name
     """
     warnings.warn("Use zipio.listdir instead of os_listdir",
-            DeprecationWarning) 
+            DeprecationWarning)
     return zipio.listdir(path)
 
 
         except ImportError:
             ImpImporter = pkg_resources.ImpWrapper
 
-    namespace_path =[] 
+    namespace_path =[]
     fp = None
     for entry in path:
         importer = pkg_resources.get_importer(entry)
         pathname = os.path.join(entry, *name.split('.'))
 
         if isinstance(loader, zipimport.zipimporter):
-            # Check if this happens to be a wrapper module introduced by 
+            # Check if this happens to be a wrapper module introduced by
             # setuptools, if it is we return the actual extension.
             zn = '/'.join(name.split('.'))
             for _sfx, _mode, _type in imp.get_suffixes():
 import warnings
 def AddPackagePath(packagename, path):
     warnings.warn("Use addPackagePath instead of AddPackagePath",
-            DeprecationWarning) 
+            DeprecationWarning)
 
     addPackagePath(packagename, path)
 
         # When this option is used namespace packages are writting to
         # disk *without* an __init__.py file, which means the regular
         # import machinery will not find them.
-        # 
+        #
         # We therefore explicitly look for the hack used by
         # setuptools to get this kind of namespace packages to work.
 
                     if imported_module.code is None:
                         m.starimports.add(name)
 
-                
-                # XXX: The code below tries to find the module we're 
+
+                # XXX: The code below tries to find the module we're
                 # star-importing from. That code uses heuristics, which is
                 # a bit lame as we already know that module: _safe_import has
-                # just calculated it for us (after a small tweak to the 
+                # just calculated it for us (after a small tweak to the
                 # return value of that method).
-                # 
+                #
                 #
                 #if have_star:
                 #    # We've encountered an "import *". If it is a Python module,
         # As per comment at top of file, simulate runtime packagepath additions.
         m.packagepath = m.packagepath + _packagePathMap.get(fqname, [])
 
-        
+
 
         try:
             self.msg(2, "find __init__ for %s"%(m.packagepath,))
                 content += imports % {"HEAD": "imported by", "LINKS": links}
             print(entry % {"NAME": name,"CONTENT": content}, file=out)
         print(footer, file=out)
-        
+
 
     def itergraphreport(self, name='G', flatpackages=()):
         # XXX: Can this be implemented using Dot()?

File modulegraph/zipio.py

View file
  • Ignore whitespace
 """
-A helper module that can work with paths 
+A helper module that can work with paths
 that can refer to data inside a zipfile
 
 XXX: Need to determine if isdir("zipfile.zip")
 
         if path == root:
             raise IOError(
-                _errno.ENOENT, full_path, 
+                _errno.ENOENT, full_path,
                 "No such file or directory")
 
         if not _os.path.isfile(path):
             raise IOError(
-                _errno.ENOENT, full_path, 
+                _errno.ENOENT, full_path,
                 "No such file or directory")
 
         rest.reverse()
 
         except _zipfile.error:
             raise IOError(
-                _errno.ENOENT, full_path, 
+                _errno.ENOENT, full_path,
                 "No such file or directory")
 
         try:
         except (_zipfile.error, KeyError):
             zf.close()
             raise IOError(
-                _errno.ENOENT, full_path, 
+                _errno.ENOENT, full_path,
                 "No such file or directory")
         zf.close()
 
 
         except _zipfile.error:
             raise IOError(
-                _errno.ENOENT, full_path, 
+                _errno.ENOENT, full_path,
                 "No such file or directory")
 
         result = set()
                 if rest is None:
                     seen = True
                     value = nm.split('/')[0]
-                    if value: 
+                    if value:
                         result.add(value)
 
                 elif nm.startswith(rest):
                     else:
                         value = None
 
-                    if value: 
+                    if value:
                         result.add(value)
         except _zipfile.error:
             zf.close()
             raise IOError(
-                _errno.ENOENT, full_path, 
+                _errno.ENOENT, full_path,
                 "No such file or directory")
 
         zf.close()
 
         if not seen:
             raise IOError(
-                _errno.ENOENT, full_path, 
+                _errno.ENOENT, full_path,
                 "No such file or directory")
 
         return list(result)
 
         # No trace in zipfile
         raise IOError(
-            _errno.ENOENT, full_path, 
+            _errno.ENOENT, full_path,
             "No such file or directory")
 
-        
-        
+
+
 
 def isdir(path):
     full_path = path
             zf = _zipfile.ZipFile(path)
         except _zipfile.error:
             raise IOError(
-                _errno.ENOENT, full_path, 
+                _errno.ENOENT, full_path,
                 "No such file or directory")
-            
+
         try:
             info = zf.getinfo(rest)
         except KeyError:
         else:
             # Directory entry found
             return True
-       
+
         for nm in zf.namelist():
             if nm.startswith(rest):
                 return True
 
         raise IOError(
-            _errno.ENOENT, full_path, 
+            _errno.ENOENT, full_path,
             "No such file or directory")
     finally:
         if zf is not None:
         zf = _zipfile.ZipFile(path)
     except _zipfile.error:
         raise IOError(
-            _errno.ENOENT, full_path, 
+            _errno.ENOENT, full_path,
             "No such file or directory")
     try:
-            
+
 
         try:
             info = zf.getinfo(rest)
                 return False
 
         raise IOError(
-            _errno.ENOENT, full_path, 
+            _errno.ENOENT, full_path,
             "No such file or directory")
 
     finally:
     if rest:
         # No symlinks inside zipfiles
         raise OSError(
-            _errno.ENOENT, full_path, 
+            _errno.ENOENT, full_path,
             "No such file or directory")
 
     return _os.readlink(path)
             info = zf.getinfo(rest)
         except KeyError:
             pass
-        
+
         if info is None:
             try:
                 info = zf.getinfo(rest + '/')
                     break
             else:
                 raise IOError(
-                    _errno.ENOENT, full_path, 
+                    _errno.ENOENT, full_path,
                     "No such file or directory")
-            
+
             # Directory exists, but has no entry of its
             # own, fake mtime by using the timestamp of
             # the zipfile itself.
         if zf is not None:
             zf.close()
         raise IOError(
-            _errno.ENOENT, full_path, 
+            _errno.ENOENT, full_path,
             "No such file or directory")

File modulegraph_tests/test_explicit_packages.py

View file
  • Ignore whitespace
 
 
 class PackagesTestCase (unittest.TestCase):
-    if not hasattr(unittest.TestCase, 'assertIsInstance'): 
+    if not hasattr(unittest.TestCase, 'assertIsInstance'):
         def assertIsInstance(self, object, types, message=None):
             self.assertTrue(isinstance(object, types),
                     message or '%r is not an instance of %r'%(object, types))
-                
+
     def testIncludePackage(self):
         root = os.path.join(
                 os.path.dirname(os.path.abspath(__file__)),

File modulegraph_tests/test_implies.py

View file
  • Ignore whitespace
 from modulegraph import modulegraph
 
 class ImpliesTestCase(unittest.TestCase):
-    if not hasattr(unittest.TestCase, 'assertIsInstance'): 
+    if not hasattr(unittest.TestCase, 'assertIsInstance'):
         def assertIsInstance(self, object, types, message=None):
             self.assertTrue(isinstance(object, types),
                     message or '%r is not an instance of %r'%(object, types))
-                
+
     def testBasicImplies(self):
         root = os.path.join(
                 os.path.dirname(os.path.abspath(__file__)),

File modulegraph_tests/test_import_from_init.py

View file
  • Ignore whitespace
                 print (%s.__name__)
             """) %(name, name)
 
-        p = subprocess.Popen([sys.executable, '-c', script], 
+        p = subprocess.Popen([sys.executable, '-c', script],
                 stdout=subprocess.PIPE,
                 stderr=subprocess.STDOUT,
                 cwd=os.path.join(
             print (data)
         self.assertEqual(sts, 0)
         return data
-        
+
 
     @unittest.skipUnless(sys.version_info[0] == 2, "Python 2.x test")
     def testRootPkg(self):
         m = self.importModule('pkg2.subpkg')
         self.assertEqual(m, 'pkg2.subpkg')
 
-    
+
 class TestModuleGraphImport (unittest.TestCase):
     if not hasattr(unittest.TestCase, 'assertIsInstance'):
         def assertIsInstance(self, value, types):

File modulegraph_tests/test_imports.py

View file
  • Ignore whitespace
                 print (%s.__name__)
             """) %(name, name)
 
-        p = subprocess.Popen([sys.executable, '-c', script], 
+        p = subprocess.Popen([sys.executable, '-c', script],
                 stdout=subprocess.PIPE,
                 stderr=subprocess.STDOUT,
                 cwd=os.path.join(
             print (data)
         self.assertEqual(sts, 0)
         return data
-        
+
 
     def testRootModule(self):
         m = self.importModule('mod')
     def testNewStyle(self):
         m = self.importModule('pkg.toplevel.mod')
         self.assertEqual(m, 'mod')
-    
+
     def testRelativeImport(self):
         m = self.importModule('pkg.relative.mod')
         self.assertEqual(m, 'pkg.mod')
         self.assertEqual(node.identifier, 'pkg.toplevel')
         sub = [ n for n in self.mf.get_edges(node)[0] if n.identifier != '__future__' ][0]
         self.assertEqual(sub.identifier, 'mod')
-    
+
     def testRelativeImport(self):
         node = self.mf.findNode('pkg.relative')
         self.assertIsInstance(node, modulegraph.SourceModule)
         import distutils.sysconfig, distutils.ccompiler
         node = self.mf.findNode('distutils.ccompiler')
         self.assertIsInstance(node, modulegraph.SourceModule)
-        self.assertEqual(os.path.dirname(node.filename), 
+        self.assertEqual(os.path.dirname(node.filename),
                 os.path.dirname(distutils.ccompiler.__file__))
 
         node = self.mf.findNode('distutils.sysconfig')
         self.assertIsInstance(node, modulegraph.SourceModule)
-        self.assertEqual(os.path.dirname(node.filename), 
+        self.assertEqual(os.path.dirname(node.filename),
                 os.path.dirname(distutils.sysconfig.__file__))
 
 class TestRegression4 (unittest.TestCase):

File modulegraph_tests/test_modulegraph.py

View file
  • Ignore whitespace
                     if self._namespace_packages is None:
                         raise ValueError("no file")
 
-                    return self._namespace_packages 
+                    return self._namespace_packages
 
                 raise ValueError("invalid lookup key")
 
                 if sys.platform == 'win32':
                     ext = '.pyd'
                 else:
-                    # This is a ly, but is good enough for now  
+                    # This is a ly, but is good enough for now
                     ext = '.so'
 
                 self.assertEqual(fp, None)
                 saved_replace = modulegraph.replacePackage
                 try:
                     called = []
-                    
+
                     def log_add(*args, **kwds):
                         called.append(('add', args, kwds))
                     def log_replace(*args, **kwds):
         self.assertEqual(d[n2], 'n2')
 
     def test_infoTuple(self):
-         n = modulegraph.Node('n1')
-         self.assertEqual(n.infoTuple(), ('n1',))
+        n = modulegraph.Node('n1')
+        self.assertEqual(n.infoTuple(), ('n1',))
 
     def assertNoMethods(self, klass):
         d = dict(klass.__dict__)
 
         g = Graph.Graph()
         o = modulegraph.ModuleGraph(['a', 'b', 'c'], ['modA'], [
-                ('fromA', 'toB'), ('fromC', 'toD')], 
+                ('fromA', 'toB'), ('fromC', 'toD')],
                 {
                     'modA': ['modB', 'modC'],
                     'modC': ['modE', 'modF'],
         graph.import_hook('os.path', None)
         graph.import_hook('idlelib', None)
         graph.import_hook('xml.dom', None)
-        
+
         for node in graph.nodes():
             if isinstance(node, modulegraph.Package):
                 break
                 ('sub1', 'root.sub.sub1', node),
                 ('sub2', 'root.sub.sub1.sub2', node2),
             ])
-        
+
         self.assertRaises(ImportError, graph.load_tail, root, 'raises')
         self.assertRaises(ImportError, graph.load_tail, root, 'sub.raises')
         self.assertRaises(ImportError, graph.load_tail, root, 'sub.raises.sub')
     def test_ensure_fromlist(self):
         # 1. basic 'from module import name, name'
         # 2. 'from module import *'
-        # 3. from module import os 
+        # 3. from module import os
         #    (where 'os' is not a name in 'module',
         #     should create MissingModule node, and
         #     should *not* refer to the global os)
         code = compile(textwrap.dedent('''\
             import sys
             import os.path
-            
+
             def testfunc():
                 import shutil
             '''), '<test>', 'exec', 0, False)
         # from module import *
         #  both:
         #   -> with/without globals
-        #   -> with/without modules in globals (e.g, 
+        #   -> with/without modules in globals (e.g,
         #       from os import * adds dependency to os.path)
         # from .module import a
         # from ..module import a
             record[:] = []
             m = graph.find_module('sax', xml.packagepath, xml)
             self.assertEqual(m,
-                    (None, os.path.join(os.path.dirname(xml.filename), 'sax'), 
+                    (None, os.path.join(os.path.dirname(xml.filename), 'sax'),
                     ('', '', imp.PKG_DIRECTORY)))
             self.assertEqual(record, [
                 ('sax', xml.packagepath),
                     expected.append([type(n).__name__, n.identifier, n.filename])
                 else:
                     expected.append([type(n).__name__, n.identifier])
-                    
+
             expected.sort()
             actual = [item.split() for item in lines[3:]]
             actual.sort()
 class CompatTests (unittest.TestCase):
     def test_Bchr(self):
         v = modulegraph._Bchr(ord('A'))
-        if sys.version_info[0] == 2: 
+        if sys.version_info[0] == 2:
             self.assertTrue(isinstance(v, bytes))
             self.assertEqual(v, b'A')
         else:

File modulegraph_tests/test_pep420_nspkg.py

View file
  • Ignore whitespace
                     print (%s.__name__)
                 """) %(test_dir1, test_dir2, name, name)
 
-            p = subprocess.Popen([sys.executable, '-c', script], 
+            p = subprocess.Popen([sys.executable, '-c', script],
                     stdout=subprocess.PIPE,
                     stderr=subprocess.STDOUT,
                     cwd=os.path.join(
                     print (%s.__name__)
                 """) %(test_dir1, test_dir2, name, name)
 
-            p = subprocess.Popen([sys.executable, '-c', script], 
+            p = subprocess.Popen([sys.executable, '-c', script],
                     stdout=subprocess.PIPE,
                     stderr=subprocess.STDOUT,
                     cwd=os.path.join(

File modulegraph_tests/test_setuptools_nspkg.py

View file
  • Ignore whitespace
 
 def install_testpkg(test_dir):
     p = subprocess.Popen([
-        sys.executable, 'setup.py', 'install', 
-            '--install-lib', test_dir, 
-            '--single-version-externally-managed', 
+        sys.executable, 'setup.py', 'install',
+            '--install-lib', test_dir,
+            '--single-version-externally-managed',
             '--record', os.path.join(test_dir, 'record.lst'),
         ], cwd=gSrcDir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-    
+
     data = p.communicate()[0]
 
     exit = p.wait()
                 print (%s.__name__)
             """) %(test_dir, name, name)
 
-        p = subprocess.Popen([sys.executable, '-c', script], 
+        p = subprocess.Popen([sys.executable, '-c', script],
                 stdout=subprocess.PIPE,
                 stderr=subprocess.STDOUT,
                 cwd=os.path.join(

File modulegraph_tests/test_util.py

View file
  • Ignore whitespace
             self.assertEqual(util.guess_encoding(fp), "utf-8")
 
         del fp
-            
+
 
 if __name__ == "__main__":
     unittest.main()

File modulegraph_tests/test_zipio.py

View file
  • Ignore whitespace
         os.symlink('test.txt', fn)
         try:
             self.assertTrue(zipio.islink(fn))
-        
+
         finally:
             os.unlink(fn)
 
         os.symlink('test.txt', fn)
         try:
             self.assertEqual(zipio.readlink(fn), 'test.txt')
-        
+
         finally:
             os.unlink(fn)
 
         self.assertRaises(OSError, zipio.readlink, os.path.join(TESTDATA, 'zipped.egg', 'subdir4'))
         self.assertRaises(OSError, zipio.readlink, os.path.join(TESTDATA, 'zipped.egg', 'no-such-file'))
         self.assertRaises(OSError, zipio.readlink, os.path.join(TESTDATA, 'zipped.egg', 'subdir/no-such-file'))
-        
+
     def test_getmtime(self):
         fn = os.path.join(TESTDATA, 'test.txt')
         self.assertEqual(os.path.getmtime(fn), zipio.getmtime(fn))

File modulegraph_tests/testpkg-regr1/main_script.py

View file
  • Ignore whitespace
-from pkg import a
+from pkg import a

File modulegraph_tests/testpkg-regr1/pkg/a.py

View file
  • Ignore whitespace
-from . import b
+from . import b

File modulegraph_tests/testpkg-regr2/pkg/__init__.py

View file
  • Ignore whitespace
-""" 
+"""
 Package structure simular to crcmod
 """
 try:

File modulegraph_tests/testpkg-regr4/pkg/core/callables.py

View file
  • Ignore whitespace
 """ pkg.callables """
 
 getID, getArgs, getRawFunction, ListenerInadequate, CallArgsInfo = [None]*5
-

File modulegraph_tests/testpkg-relimport/pkg/subpkg/mod2.py

View file
  • Ignore whitespace
 """ pkg.subpkg.mod2 """
 from __future__ import absolute_import
 from ..sub2.mod import __doc__
-from ..sub2 import mod 
+from ..sub2 import mod

File modulegraph_tests/testpkg-setuptools-namespace/build/lib/nspkg/__init__.py

View file
  • Ignore whitespace
 except ImportError:
     import pkgutil
     __path__ = pkgutil.extend_path(__path__, __name__)
-

File modulegraph_tests/testpkg-setuptools-namespace/build/lib/nspkg/nssubpkg/__init__.py

View file
  • Ignore whitespace
 except ImportError:
     import pkgutil
     __path__ = pkgutil.extend_path(__path__, __name__)
-

File modulegraph_tests/testpkg-setuptools-namespace/src/nspkg/__init__.py

View file
  • Ignore whitespace
 except ImportError:
     import pkgutil
     __path__ = pkgutil.extend_path(__path__, __name__)
-

File modulegraph_tests/testpkg-setuptools-namespace/src/nspkg/nssubpkg/__init__.py

View file
  • Ignore whitespace
 except ImportError:
     import pkgutil
     __path__ = pkgutil.extend_path(__path__, __name__)
-

File scripts/extract_implies.py

View file
  • Ignore whitespace
 of the stdlib.
 
 The current version has harcoded the location of the source
-tries on Ronald's machine, a future version will be able 
+tries on Ronald's machine, a future version will be able
 to rebuild the modulegraph source file that contains
 this information.
 """

File setup.py

View file
  • Ignore whitespace
 
 Additional functionality:
 
-* Section 'x-setup-stub': 
+* Section 'x-setup-stub':
 
     distribute-version: minimal distribute version
     setuptools-version: minimal setuptools version
         (for both: script will bail out when you have a too old
          version installed, and will install the version when
          it isn't installed)
-    prefer-distribute = 1  
+    prefer-distribute = 1
         If true install distribute when neither setuptools
         nor distribute is present, otherwise install setuptools
 
             if v:
                 result.append(v)
     return result
-            
+
 def _map_requirement(value):
     m = re.search(r'(\S+)\s*(?:\((.*)\))?', value)
     name = m.group(1)
 
         metadata['long_description'] = '\n\n'.join(parts)
 
-        
+
     try:
         v = cfg.get('metadata', 'zip-safe')
     except (NoOptionError, NoSectionError):
             # Collect sphinx output
             if not os.path.exists('dist'):
                 os.mkdir('dist')
-            zf = zipfile.ZipFile('dist/%s-docs.zip'%(name,), 'w', 
+            zf = zipfile.ZipFile('dist/%s-docs.zip'%(name,), 'w',
                     compression=zipfile.ZIP_DEFLATED)
 
             for toplevel, dirs, files in os.walk('doc/_build/html'):
             # Upload the results, this code is based on the distutils
             # 'upload' command.
             content = open('dist/%s-docs.zip'%(name,), 'rb').read()
-            
+
             data = {
                 ':action': 'doc_upload',
                 'name': name,
                 self.announce('Upload failed (%s): %s' % (r.status, r.reason),
                     log.ERROR)
 
-                print ('-'*75) 
+                print ('-'*75)
                 print (r.read())
                 print ('-'*75)
 
             if fnmatch(fn, pathPattern):
                 result.append(os.path.join(rootpath, fn))
     return result
-        
 
-def importExternalTestCases(unittest, 
+
+def importExternalTestCases(unittest,
         pathPattern="test_*.py", root=".", package=None):
     """
     Import all unittests in the PyObjC tree starting at 'root'
         testModules = [(package + '.' + m) for m in testModules]
 
     suites = []
-   
+
     for modName in testModules:
         try:
             module = __import__(modName)
         if nspkgs is not None:
             for nm in nspkgs:
                 del sys.modules[nm]
-        
+
         # Reset pkg_resources state:
         add_activation_listener(lambda dist: dist.activate())
         working_set.__init__()
             meta = self.distribution.metadata
             name = meta.get_name()
             test_pkg = name + "_tests"
-            suite = importExternalTestCases(unittest, 
+            suite = importExternalTestCases(unittest,
                     "test_*.py", test_pkg, test_pkg)
 
             runner = unittest.TextTestRunner(verbosity=self.verbosity)