Commit cadf172f authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #641 from stepshal/colon

Put colon-separated compound statement on separate lines.
parents e6168c60 64335b63
...@@ -2837,7 +2837,8 @@ class Requirement(packaging.requirements.Requirement): ...@@ -2837,7 +2837,8 @@ class Requirement(packaging.requirements.Requirement):
def _get_mro(cls): def _get_mro(cls):
"""Get an mro for a type or classic class""" """Get an mro for a type or classic class"""
if not isinstance(cls, type): if not isinstance(cls, type):
class cls(cls, object): pass class cls(cls, object):
pass
return cls.__mro__[1:] return cls.__mro__[1:]
return cls.__mro__ return cls.__mro__
......
...@@ -53,7 +53,8 @@ class Require: ...@@ -53,7 +53,8 @@ class Require:
if self.attribute is None: if self.attribute is None:
try: try:
f, p, i = find_module(self.module, paths) f, p, i = find_module(self.module, paths)
if f: f.close() if f:
f.close()
return default return default
except ImportError: except ImportError:
return None return None
......
...@@ -155,8 +155,10 @@ def check_package_data(dist, attr, value): ...@@ -155,8 +155,10 @@ def check_package_data(dist, attr, value):
"""Verify that value is a dictionary of package names to glob lists""" """Verify that value is a dictionary of package names to glob lists"""
if isinstance(value, dict): if isinstance(value, dict):
for k, v in value.items(): for k, v in value.items():
if not isinstance(k, str): break if not isinstance(k, str):
try: iter(v) break
try:
iter(v)
except TypeError: except TypeError:
break break
else: else:
...@@ -807,7 +809,8 @@ class Feature: ...@@ -807,7 +809,8 @@ class Feature:
r for r in require_features if isinstance(r, str) r for r in require_features if isinstance(r, str)
] ]
er = [r for r in require_features if not isinstance(r, str)] er = [r for r in require_features if not isinstance(r, str)]
if er: extras['require_features'] = er if er:
extras['require_features'] = er
if isinstance(remove, str): if isinstance(remove, str):
remove = remove, remove = remove,
......
...@@ -45,7 +45,8 @@ class Mixin2to3(_Mixin2to3): ...@@ -45,7 +45,8 @@ class Mixin2to3(_Mixin2to3):
_Mixin2to3.run_2to3(self, files) _Mixin2to3.run_2to3(self, files)
def __build_fixer_names(self): def __build_fixer_names(self):
if self.fixer_names: return if self.fixer_names:
return
self.fixer_names = [] self.fixer_names = []
for p in setuptools.lib2to3_fixer_packages: for p in setuptools.lib2to3_fixer_packages:
self.fixer_names.extend(get_fixers_from_package(p)) self.fixer_names.extend(get_fixers_from_package(p))
......
...@@ -82,14 +82,16 @@ def egg_info_for_url(url): ...@@ -82,14 +82,16 @@ def egg_info_for_url(url):
base = urllib.parse.unquote(path.split('/')[-1]) base = urllib.parse.unquote(path.split('/')[-1])
if server == 'sourceforge.net' and base == 'download': # XXX Yuck if server == 'sourceforge.net' and base == 'download': # XXX Yuck
base = urllib.parse.unquote(path.split('/')[-2]) base = urllib.parse.unquote(path.split('/')[-2])
if '#' in base: base, fragment = base.split('#', 1) if '#' in base:
base, fragment = base.split('#', 1)
return base, fragment return base, fragment
def distros_for_url(url, metadata=None): def distros_for_url(url, metadata=None):
"""Yield egg or source distribution objects that might be found at a URL""" """Yield egg or source distribution objects that might be found at a URL"""
base, fragment = egg_info_for_url(url) base, fragment = egg_info_for_url(url)
for dist in distros_for_location(url, base, metadata): yield dist for dist in distros_for_location(url, base, metadata):
yield dist
if fragment: if fragment:
match = EGG_FRAGMENT.match(fragment) match = EGG_FRAGMENT.match(fragment)
if match: if match:
...@@ -289,7 +291,8 @@ class PackageIndex(Environment): ...@@ -289,7 +291,8 @@ class PackageIndex(Environment):
self.to_scan = [] self.to_scan = []
if verify_ssl and ssl_support.is_available and (ca_bundle or ssl_support.find_ca_bundle()): if verify_ssl and ssl_support.is_available and (ca_bundle or ssl_support.find_ca_bundle()):
self.opener = ssl_support.opener_for(ca_bundle) self.opener = ssl_support.opener_for(ca_bundle)
else: self.opener = urllib.request.urlopen else:
self.opener = urllib.request.urlopen
def process_url(self, url, retrieve=False): def process_url(self, url, retrieve=False):
"""Evaluate a URL as a possible download, and maybe retrieve it""" """Evaluate a URL as a possible download, and maybe retrieve it"""
...@@ -317,7 +320,8 @@ class PackageIndex(Environment): ...@@ -317,7 +320,8 @@ class PackageIndex(Environment):
self.info("Reading %s", url) self.info("Reading %s", url)
self.fetched_urls[url] = True # prevent multiple fetch attempts self.fetched_urls[url] = True # prevent multiple fetch attempts
f = self.open_url(url, "Download error on %s: %%s -- Some packages may not be found!" % url) f = self.open_url(url, "Download error on %s: %%s -- Some packages may not be found!" % url)
if f is None: return if f is None:
return
self.fetched_urls[f.url] = True self.fetched_urls[f.url] = True
if 'html' not in f.headers.get('content-type', '').lower(): if 'html' not in f.headers.get('content-type', '').lower():
f.close() # not html, we can't process it f.close() # not html, we can't process it
...@@ -442,7 +446,8 @@ class PackageIndex(Environment): ...@@ -442,7 +446,8 @@ class PackageIndex(Environment):
def scan_all(self, msg=None, *args): def scan_all(self, msg=None, *args):
if self.index_url not in self.fetched_urls: if self.index_url not in self.fetched_urls:
if msg: self.warn(msg, *args) if msg:
self.warn(msg, *args)
self.info( self.info(
"Scanning index of all packages (this may take a while)" "Scanning index of all packages (this may take a while)"
) )
...@@ -714,7 +719,8 @@ class PackageIndex(Environment): ...@@ -714,7 +719,8 @@ class PackageIndex(Environment):
self.check_hash(checker, filename, tfp) self.check_hash(checker, filename, tfp)
return headers return headers
finally: finally:
if fp: fp.close() if fp:
fp.close()
def reporthook(self, url, filename, blocknum, blksize, size): def reporthook(self, url, filename, blocknum, blksize, size):
pass # no-op pass # no-op
...@@ -896,7 +902,8 @@ entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub ...@@ -896,7 +902,8 @@ entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub
def uchr(c): def uchr(c):
if not isinstance(c, int): if not isinstance(c, int):
return c return c
if c > 255: return six.unichr(c) if c > 255:
return six.unichr(c)
return chr(c) return chr(c)
......
...@@ -291,7 +291,8 @@ class AbstractSandbox: ...@@ -291,7 +291,8 @@ class AbstractSandbox:
return wrap return wrap
for name in ["rename", "link", "symlink"]: for name in ["rename", "link", "symlink"]:
if hasattr(_os, name): locals()[name] = _mk_dual_path_wrapper(name) if hasattr(_os, name):
locals()[name] = _mk_dual_path_wrapper(name)
def _mk_single_path_wrapper(name, original=None): def _mk_single_path_wrapper(name, original=None):
original = original or getattr(_os, name) original = original or getattr(_os, name)
...@@ -310,7 +311,8 @@ class AbstractSandbox: ...@@ -310,7 +311,8 @@ class AbstractSandbox:
"remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat", "remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat",
"startfile", "mkfifo", "mknod", "pathconf", "access" "startfile", "mkfifo", "mknod", "pathconf", "access"
]: ]:
if hasattr(_os, name): locals()[name] = _mk_single_path_wrapper(name) if hasattr(_os, name):
locals()[name] = _mk_single_path_wrapper(name)
def _mk_single_with_return(name): def _mk_single_with_return(name):
original = getattr(_os, name) original = getattr(_os, name)
...@@ -323,7 +325,8 @@ class AbstractSandbox: ...@@ -323,7 +325,8 @@ class AbstractSandbox:
return wrap return wrap
for name in ['readlink', 'tempnam']: for name in ['readlink', 'tempnam']:
if hasattr(_os, name): locals()[name] = _mk_single_with_return(name) if hasattr(_os, name):
locals()[name] = _mk_single_with_return(name)
def _mk_query(name): def _mk_query(name):
original = getattr(_os, name) original = getattr(_os, name)
...@@ -336,7 +339,8 @@ class AbstractSandbox: ...@@ -336,7 +339,8 @@ class AbstractSandbox:
return wrap return wrap
for name in ['getcwd', 'tmpnam']: for name in ['getcwd', 'tmpnam']:
if hasattr(_os, name): locals()[name] = _mk_query(name) if hasattr(_os, name):
locals()[name] = _mk_query(name)
def _validate_path(self, path): def _validate_path(self, path):
"""Called to remap or validate any path, whether input or output""" """Called to remap or validate any path, whether input or output"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment