Michele Lacchia avatar Michele Lacchia committed 2f3f645

General PEP 8 fixes

Comments (0)

Files changed (8)

wheel/__init__.py

-#
+#
 
 log = logging.getLogger("wheel")
 
+
 def archive_wheelfile(base_name, base_dir):
     olddir = os.path.abspath(os.curdir)
     base_name = os.path.abspath(base_name)
-    try:        
+    try:
         os.chdir(base_dir)
         return make_wheelfile_inner(base_name)
     finally:
         os.chdir(olddir)
 
+
 def make_wheelfile_inner(base_name, base_dir='.'):
     """Create a whl file from all the files under 'base_dir'.
-    
+
     Places .dist-info at the end of the archive."""
-    
+
     zip_filename = base_name + ".whl"
 
     log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir)
-    
+
     # XXX support bz2, xz when available
     zip = zipfile.ZipFile(open(zip_filename, "wb+"), "w",
                           compression=zipfile.ZIP_DEFLATED)
 
-    score = {'WHEEL': 1, 'METADATA': 2, 'RECORD': 3} 
+    score = {'WHEEL': 1, 'METADATA': 2, 'RECORD': 3}
     deferred = []
 
     def writefile(path):
     for dirpath, dirnames, filenames in os.walk(base_dir):
         for name in filenames:
             path = os.path.normpath(os.path.join(dirpath, name))
-            
+
             if os.path.isfile(path):
                 if dirpath.endswith('.dist-info'):
                     deferred.append((score.get(name, 0), path))

wheel/bdist_wininst2wheel.py

 # bdist_wininst_info_re = re.compile(r'''^(?P<name>.+?)(-(?P<ver>.+?)\.)?
 #     (?P<arch>\w+-\w+)-(?P<pyver>py\d.+).exe''', re.VERBOSE)
 
+
 def bdist_wininst2wheel(path):
     base = os.path.splitext(os.path.basename(path))[0]
     info = dict()
     info['ver'], sep, info['arch'] = base.rpartition('.')
     dist_info = "%(name)s-%(ver)s" % info
     datadir = "%s.data/" % dist_info
-    
+
     # rewrite paths to trick ZipFile into extracting an egg
     # XXX grab wininst .ini - between .exe, padding, and first zip file.
     bdw = zipfile.ZipFile(path)
             root_is_purelib = False
             break
     if root_is_purelib:
-        paths = {'purelib':''}
+        paths = {'purelib': ''}
     else:
-        paths = {'platlib':''}
+        paths = {'platlib': ''}
     for zipinfo in bdw.infolist():
         key, basename = zipinfo.filename.split('/', 1)
         key = key.lower()
         bdw.NameToInfo[newname] = zipinfo
     dir = tempfile.mkdtemp(suffix="_b2w")
     bdw.extractall(dir)
-    
+
     # egg2wheel
     abi = 'noabi'
     pyver = info['pyver'].replace('.', '')
         # assume all binary eggs are for CPython
         pyver = 'cp' + pyver[2:]
     wheel_name = '-'.join((
-            dist_info,
-            pyver,
-            abi,
-            arch
-            ))
+                          dist_info,
+                          pyver,
+                          abi,
+                          arch
+                          ))
     bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution())
     bw.root_is_purelib = root_is_purelib
     dist_info_dir = os.path.join(dir, '%s.dist-info' % dist_info)
     filename = make_archive(wheel_name, 'zip', root_dir=dir)
     os.rename(filename, filename[:-3] + 'whl')
     rmtree(dir)
-    
+
 
 if __name__ == "__main__":
     bdist_wininst2wheel(sys.argv[1])
-    
-        

wheel/decorator.py

 # from Pyramid
 
+
 class reify(object):
 
     """ Put the result of a method which uses this (non-data)
         self.wrapped = wrapped
         try:
             self.__doc__ = wrapped.__doc__
-        except: # pragma: no cover
+        except:  # pragma: no cover
             pass
 
     def __get__(self, inst, objtype=None):
         val = self.wrapped(inst)
         setattr(inst, self.wrapped.__name__, val)
         return val
-

wheel/egg2wheel.py

         # assume all binary eggs are for CPython
         pyver = 'cp' + pyver[2:]
     wheel_name = '-'.join((
-            dist_info,
-            pyver,
-            abi,
-            arch
-            ))
+                          dist_info,
+                          pyver,
+                          abi,
+                          arch
+                          ))
     bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution())
     bw.root_is_purelib = egg_info['arch'] is None
     dist_info_dir = os.path.join(dir, '%s.dist-info' % dist_info)
     filename = make_archive(wheel_name, 'zip', root_dir=dir)
     os.rename(filename, filename[:-3] + 'whl')
     rmtree(dir)
-
     r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
     ((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
     \.whl|\.dist-info)$""",
-re.VERBOSE).match
+    re.VERBOSE).match
 
 
 class WheelFile(object):
-    """Parse wheel-specific attributes from a wheel (.whl) file"""    
+    """Parse wheel-specific attributes from a wheel (.whl) file"""
     WHEEL_INFO = "WHEEL"
-    
+
     def __init__(self, filename):
         self.filename = filename
         basename = os.path.basename(filename)
 
     def __repr__(self):
         return self.filename
-        
+
     @reify
     def zipfile(self):
         return zipfile.ZipFile(self.filename)
-        
+
     def get_metadata(self):
         pass
-    
+
     @property
     def distinfo_name(self):
         return "%s.dist-info" % self.parsed_filename.group('namever')
-    
+
     @property
     def datadir_name(self):
         return "%s.data" % self.parsed_filename.group('namever')
-    
+
     @property
     def wheelinfo_name(self):
         return "%s/%s" % (self.distinfo_name, self.WHEEL_INFO)
-    
+
     @property
     def compatibility_tags(self):
         """A wheel file is compatible with the Cartesian product of the
             for abi in tags['abi'].split('.'):
                 for plat in tags['plat'].split('.'):
                     yield (pyver, abi, plat)
-                    
+
     @property
     def arity(self):
         '''The number of compatibility tags the wheel is compatible with.'''
     @reify
     def parsed_wheel_info(self):
         """Parse wheel metadata"""
-        return Parser().parse(self.zipfile.open(self.wheelinfo_name))    
-        
+        return Parser().parse(self.zipfile.open(self.wheelinfo_name))
+
     def check_version(self):
         version = self.parsed_wheel_info['Wheel-Version']
-        assert tuple(map(int, version.split('.'))) < VERSION_TOO_HIGH, "Wheel version is too high"
-        
+        assert tuple(map(int, version.split('.'))
+                     ) < VERSION_TOO_HIGH, "Wheel version is too high"
+
     def sign(self, key, alg="HS256"):
-        """Sign the wheel file's RECORD using `key` and algorithm `alg`. Alg 
+        """Sign the wheel file's RECORD using `key` and algorithm `alg`. Alg
         values are from JSON Web Signatures; only HS256 is supported at this
         time."""
         if alg != 'HS256':
-            # python-jws (not in pypi) supports other algorithms 
+            # python-jws (not in pypi) supports other algorithms
             raise ValueError("Unsupported algorithm")
         sig = self.sign_hs256(key)
         self.zipfile.writestr('/'.join((self.distinfo_name, 'RECORD.jws')),
                               sig)
-        
+
     def sign_hs256(self, key):
-        record = self.zipfile.read('/'.join((self.distinfo_name, 'RECORD')))        
+        record = self.zipfile.read('/'.join((self.distinfo_name, 'RECORD')))
         record_digest = urlsafe_b64encode(hashlib.sha256(record).digest())
         header = utf8(to_json(dict(alg="HS256", typ="JWT")))
-        payload = utf8(to_json(dict(hash="sha256="+record_digest)))
-        protected = b'.'.join((urlsafe_b64encode(header), 
+        payload = utf8(to_json(dict(hash="sha256=" + record_digest)))
+        protected = b'.'.join((urlsafe_b64encode(header),
                                urlsafe_b64encode(payload)))
         mac = hmac.HMAC(key, protected, hashlib.sha256).digest()
         sig = b'.'.join((protected, urlsafe_b64encode(mac)))
         return sig
-    
+
     def verify_hs256(self, key):
-        signature = self.zipfile.read('/'.join((self.distinfo_name, 
+        signature = self.zipfile.read('/'.join((self.distinfo_name,
                                                 'RECORD.JWT')))
         verify = self.sign_hs256(key)
         if verify != signature:
     try:
         sys.real_prefix
     except AttributeError:
-        raise Exception("This alpha version of wheel will only install into a virtualenv")
+        raise Exception(
+            "This alpha version of wheel will only install into a virtualenv")
     wf = WheelFile(wheel_path)
 def test_egg_re():
     """Make sure egg_info_re matches."""
     from . import egg2wheel
-    import pkg_resources
     egg_names = open(pkg_resources.resource_filename('wheel', 'eggnames.txt'))
     for line in egg_names:
         line = line.strip()
-        if not line: continue
+        if not line:
+            continue
         assert egg2wheel.egg_info_re.match(line), line
 
 
     assert_equal(list(wf.compatibility_tags),
                  [('cp32', 'noabi', 'noarch'), ('cp33', 'noabi', 'noarch')])
     assert_equal(wf.arity, 2)
-    
+
     wf2 = WheelFile("package-1.0.0-1st-cp33-noabi-noarch.whl")
     wf2_info = wf2.parsed_filename.groupdict()
     assert wf2_info['build'] == '1st', wf2_info
         return info['pyver'], info['abi'], info['plat']
 
     from wheel.install import pick_best, WheelFile
-    
+
     cand_tags = [('py27', 'noabi', 'noarch'), ('py26', 'noabi', 'noarch'),
-                 ('cp27', 'noabi', 'linux_i686'), ('cp26', 'noabi', 'linux_i686'),
-                 ('cp27', 'noabi', 'linux_x86_64'), ('cp26', 'noabi', 'linux_x86_64')]
-    cand_wheels = [WheelFile('testpkg-1.0-%s-%s-%s.whl' % t) for t in cand_tags]
+                 ('cp27', 'noabi', 'linux_i686'),
+                 ('cp26', 'noabi', 'linux_i686'),
+                 ('cp27', 'noabi', 'linux_x86_64'),
+                 ('cp26', 'noabi', 'linux_x86_64')]
+    cand_wheels = [WheelFile('testpkg-1.0-%s-%s-%s.whl' % t)
+                   for t in cand_tags]
 
     supported = [('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch')]
     supported2 = [('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch'),
 
     for supp in (supported, supported2, supported3):
         assert_equal(get_tags(pick_best(cand_wheels, supp)), supp[0])
-        assert_equal(map(get_tags, pick_best(cand_wheels, supp, top=False)), supp)
+        assert_equal(
+            map(get_tags, pick_best(cand_wheels, supp, top=False)), supp)
 
 
 if __name__ == '__main__':
 
 try:
     unicode
+
     def utf8(data):
         if isinstance(data, unicode):
             return data.encode('utf-8')
     arch = get_platform().replace('.', '_').replace('-', '_')
     for version in versions:
         for abi in abis:
-            supported.append(('%s%s' % (impl, version), abi, arch))    
+            supported.append(('%s%s' % (impl, version), abi, arch))
         if not impl.startswith('py'):
             # Add pure Python distributions if not already done so
             supported.append(('py%s' % (version), 'noabi', 'noarch'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.