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):
def _get_mro(cls):
"""Get an mro for a type or classic class"""
if not isinstance(cls, type):
class cls(cls, object): pass
class cls(cls, object):
pass
return cls.__mro__[1:]
return cls.__mro__
......
......@@ -53,7 +53,8 @@ class Require:
if self.attribute is None:
try:
f, p, i = find_module(self.module, paths)
if f: f.close()
if f:
f.close()
return default
except ImportError:
return None
......
......@@ -155,8 +155,10 @@ def check_package_data(dist, attr, value):
"""Verify that value is a dictionary of package names to glob lists"""
if isinstance(value, dict):
for k, v in value.items():
if not isinstance(k, str): break
try: iter(v)
if not isinstance(k, str):
break
try:
iter(v)
except TypeError:
break
else:
......@@ -807,7 +809,8 @@ class Feature:
r for r in require_features if 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):
remove = remove,
......
......@@ -45,7 +45,8 @@ class Mixin2to3(_Mixin2to3):
_Mixin2to3.run_2to3(self, files)
def __build_fixer_names(self):
if self.fixer_names: return
if self.fixer_names:
return
self.fixer_names = []
for p in setuptools.lib2to3_fixer_packages:
self.fixer_names.extend(get_fixers_from_package(p))
......
......@@ -82,14 +82,16 @@ def egg_info_for_url(url):
base = urllib.parse.unquote(path.split('/')[-1])
if server == 'sourceforge.net' and base == 'download': # XXX Yuck
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
def distros_for_url(url, metadata=None):
"""Yield egg or source distribution objects that might be found at a 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:
match = EGG_FRAGMENT.match(fragment)
if match:
......@@ -289,7 +291,8 @@ class PackageIndex(Environment):
self.to_scan = []
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)
else: self.opener = urllib.request.urlopen
else:
self.opener = urllib.request.urlopen
def process_url(self, url, retrieve=False):
"""Evaluate a URL as a possible download, and maybe retrieve it"""
......@@ -317,7 +320,8 @@ class PackageIndex(Environment):
self.info("Reading %s", url)
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)
if f is None: return
if f is None:
return
self.fetched_urls[f.url] = True
if 'html' not in f.headers.get('content-type', '').lower():
f.close() # not html, we can't process it
......@@ -442,7 +446,8 @@ class PackageIndex(Environment):
def scan_all(self, msg=None, *args):
if self.index_url not in self.fetched_urls:
if msg: self.warn(msg, *args)
if msg:
self.warn(msg, *args)
self.info(
"Scanning index of all packages (this may take a while)"
)
......@@ -714,7 +719,8 @@ class PackageIndex(Environment):
self.check_hash(checker, filename, tfp)
return headers
finally:
if fp: fp.close()
if fp:
fp.close()
def reporthook(self, url, filename, blocknum, blksize, size):
pass # no-op
......@@ -896,7 +902,8 @@ entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub
def uchr(c):
if not isinstance(c, int):
return c
if c > 255: return six.unichr(c)
if c > 255:
return six.unichr(c)
return chr(c)
......
......@@ -291,7 +291,8 @@ class AbstractSandbox:
return wrap
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):
original = original or getattr(_os, name)
......@@ -310,7 +311,8 @@ class AbstractSandbox:
"remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat",
"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):
original = getattr(_os, name)
......@@ -323,7 +325,8 @@ class AbstractSandbox:
return wrap
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):
original = getattr(_os, name)
......@@ -336,7 +339,8 @@ class AbstractSandbox:
return wrap
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):
"""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