Commit 37f1dd19 authored by insiv's avatar insiv

Add missing whitespace around operators.

parent 0addcafe
...@@ -155,7 +155,7 @@ class _SetuptoolsVersionMixin(object): ...@@ -155,7 +155,7 @@ class _SetuptoolsVersionMixin(object):
# pad for numeric comparison # pad for numeric comparison
yield part.zfill(8) yield part.zfill(8)
else: else:
yield '*'+part yield '*' + part
# ensure that alpha/beta/candidate are before final # ensure that alpha/beta/candidate are before final
yield '*final' yield '*final'
...@@ -217,13 +217,13 @@ def __getstate__(): ...@@ -217,13 +217,13 @@ def __getstate__():
state = {} state = {}
g = globals() g = globals()
for k, v in _state_vars.items(): for k, v in _state_vars.items():
state[k] = g['_sget_'+v](g[k]) state[k] = g['_sget_' + v](g[k])
return state return state
def __setstate__(state): def __setstate__(state):
g = globals() g = globals()
for k, v in state.items(): for k, v in state.items():
g['_sset_'+_state_vars[k]](k, g[k], v) g['_sset_' + _state_vars[k]](k, g[k], v)
return state return state
def _sget_dict(val): def _sget_dict(val):
...@@ -314,7 +314,7 @@ __all__ = [ ...@@ -314,7 +314,7 @@ __all__ = [
class ResolutionError(Exception): class ResolutionError(Exception):
"""Abstract base for dependency resolution errors""" """Abstract base for dependency resolution errors"""
def __repr__(self): def __repr__(self):
return self.__class__.__name__+repr(self.args) return self.__class__.__name__ + repr(self.args)
class VersionConflict(ResolutionError): class VersionConflict(ResolutionError):
...@@ -477,7 +477,7 @@ def compatible_platforms(provided, required): ...@@ -477,7 +477,7 @@ def compatible_platforms(provided, required):
XXX Needs compatibility checks for Linux and other unixy OSes. XXX Needs compatibility checks for Linux and other unixy OSes.
""" """
if provided is None or required is None or provided==required: if provided is None or required is None or provided == required:
# easy case # easy case
return True return True
...@@ -732,7 +732,7 @@ class WorkingSet(object): ...@@ -732,7 +732,7 @@ class WorkingSet(object):
for key in self.entry_keys[item]: for key in self.entry_keys[item]:
if key not in seen: if key not in seen:
seen[key]=1 seen[key] = 1
yield self.by_key[key] yield self.by_key[key]
def add(self, dist, entry=None, insert=True, replace=False): def add(self, dist, entry=None, insert=True, replace=False):
...@@ -1033,7 +1033,7 @@ class Environment(object): ...@@ -1033,7 +1033,7 @@ class Environment(object):
is returned. is returned.
""" """
return (self.python is None or dist.py_version is None return (self.python is None or dist.py_version is None
or dist.py_version==self.python) \ or dist.py_version == self.python) \
and compatible_platforms(dist.platform, self.platform) and compatible_platforms(dist.platform, self.platform)
def remove(self, dist): def remove(self, dist):
...@@ -1238,7 +1238,7 @@ class ResourceManager: ...@@ -1238,7 +1238,7 @@ class ResourceManager:
extract, as it tracks the generated names for possible cleanup later. extract, as it tracks the generated names for possible cleanup later.
""" """
extract_path = self.extraction_path or get_default_cache() extract_path = self.extraction_path or get_default_cache()
target_path = os.path.join(extract_path, archive_name+'-tmp', *names) target_path = os.path.join(extract_path, archive_name + '-tmp', *names)
try: try:
_bypass_ensure_directory(target_path) _bypass_ensure_directory(target_path)
except: except:
...@@ -1344,7 +1344,7 @@ def get_default_cache(): ...@@ -1344,7 +1344,7 @@ def get_default_cache():
except KeyError: except KeyError:
pass pass
if os.name!='nt': if os.name != 'nt':
return os.path.expanduser('~/.python-eggs') return os.path.expanduser('~/.python-eggs')
# XXX this may be locale-specific! # XXX this may be locale-specific!
...@@ -1492,7 +1492,7 @@ class NullProvider: ...@@ -1492,7 +1492,7 @@ class NullProvider:
return [] return []
def run_script(self, script_name, namespace): def run_script(self, script_name, namespace):
script = 'scripts/'+script_name script = 'scripts/' + script_name
if not self.has_metadata(script): if not self.has_metadata(script):
raise ResolutionError("No script named %r" % script_name) raise ResolutionError("No script named %r" % script_name)
script_text = self.get_metadata(script).replace('\r\n', '\n') script_text = self.get_metadata(script).replace('\r\n', '\n')
...@@ -1553,7 +1553,7 @@ class EggProvider(NullProvider): ...@@ -1553,7 +1553,7 @@ class EggProvider(NullProvider):
# of multiple eggs; that's why we use module_path instead of .archive # of multiple eggs; that's why we use module_path instead of .archive
path = self.module_path path = self.module_path
old = None old = None
while path!=old: while path != old:
if _is_unpacked_egg(path): if _is_unpacked_egg(path):
self.egg_name = os.path.basename(path) self.egg_name = os.path.basename(path)
self.egg_info = os.path.join(path, 'EGG-INFO') self.egg_info = os.path.join(path, 'EGG-INFO')
...@@ -1679,7 +1679,7 @@ class ZipProvider(EggProvider): ...@@ -1679,7 +1679,7 @@ class ZipProvider(EggProvider):
def __init__(self, module): def __init__(self, module):
EggProvider.__init__(self, module) EggProvider.__init__(self, module)
self.zip_pre = self.loader.archive+os.sep self.zip_pre = self.loader.archive + os.sep
def _zipinfo_name(self, fspath): def _zipinfo_name(self, fspath):
# Convert a virtual filename (full path to file) into a zipfile subpath # Convert a virtual filename (full path to file) into a zipfile subpath
...@@ -1693,9 +1693,9 @@ class ZipProvider(EggProvider): ...@@ -1693,9 +1693,9 @@ class ZipProvider(EggProvider):
def _parts(self, zip_path): def _parts(self, zip_path):
# Convert a zipfile subpath into an egg-relative path part list. # Convert a zipfile subpath into an egg-relative path part list.
# pseudo-fs path # pseudo-fs path
fspath = self.zip_pre+zip_path fspath = self.zip_pre + zip_path
if fspath.startswith(self.egg_root+os.sep): if fspath.startswith(self.egg_root + os.sep):
return fspath[len(self.egg_root)+1:].split(os.sep) return fspath[len(self.egg_root) + 1:].split(os.sep)
raise AssertionError( raise AssertionError(
"%s is not a subpath of %s" % (fspath, self.egg_root) "%s is not a subpath of %s" % (fspath, self.egg_root)
) )
...@@ -1766,7 +1766,7 @@ class ZipProvider(EggProvider): ...@@ -1766,7 +1766,7 @@ class ZipProvider(EggProvider):
# so proceed. # so proceed.
return real_path return real_path
# Windows, del old file and retry # Windows, del old file and retry
elif os.name=='nt': elif os.name == 'nt':
unlink(real_path) unlink(real_path)
rename(tmpnam, real_path) rename(tmpnam, real_path)
return real_path return real_path
...@@ -1786,7 +1786,7 @@ class ZipProvider(EggProvider): ...@@ -1786,7 +1786,7 @@ class ZipProvider(EggProvider):
if not os.path.isfile(file_path): if not os.path.isfile(file_path):
return False return False
stat = os.stat(file_path) stat = os.stat(file_path)
if stat.st_size!=size or stat.st_mtime!=timestamp: if stat.st_size != size or stat.st_mtime != timestamp:
return False return False
# check that the contents match # check that the contents match
zip_contents = self.loader.get_data(zip_path) zip_contents = self.loader.get_data(zip_path)
...@@ -1855,10 +1855,10 @@ class FileMetadata(EmptyProvider): ...@@ -1855,10 +1855,10 @@ class FileMetadata(EmptyProvider):
self.path = path self.path = path
def has_metadata(self, name): def has_metadata(self, name):
return name=='PKG-INFO' and os.path.isfile(self.path) return name == 'PKG-INFO' and os.path.isfile(self.path)
def get_metadata(self, name): def get_metadata(self, name):
if name=='PKG-INFO': if name == 'PKG-INFO':
with io.open(self.path, encoding='utf-8') as f: with io.open(self.path, encoding='utf-8') as f:
try: try:
metadata = f.read() metadata = f.read()
...@@ -1905,7 +1905,7 @@ class EggMetadata(ZipProvider): ...@@ -1905,7 +1905,7 @@ class EggMetadata(ZipProvider):
def __init__(self, importer): def __init__(self, importer):
"""Create a metadata provider from a zipimporter""" """Create a metadata provider from a zipimporter"""
self.zip_pre = importer.archive+os.sep self.zip_pre = importer.archive + os.sep
self.loader = importer self.loader = importer
if importer.prefix: if importer.prefix:
self.module_path = os.path.join(importer.archive, importer.prefix) self.module_path = os.path.join(importer.archive, importer.prefix)
...@@ -2117,7 +2117,7 @@ def file_ns_handler(importer, path_item, packageName, module): ...@@ -2117,7 +2117,7 @@ def file_ns_handler(importer, path_item, packageName, module):
subpath = os.path.join(path_item, packageName.split('.')[-1]) subpath = os.path.join(path_item, packageName.split('.')[-1])
normalized = _normalize_cached(subpath) normalized = _normalize_cached(subpath)
for item in module.__path__: for item in module.__path__:
if _normalize_cached(item)==normalized: if _normalize_cached(item) == normalized:
break break
else: else:
# Only return the path if it's not already there # Only return the path if it's not already there
...@@ -2294,7 +2294,7 @@ class EntryPoint(object): ...@@ -2294,7 +2294,7 @@ class EntryPoint(object):
ep = cls.parse(line, dist) ep = cls.parse(line, dist)
if ep.name in this: if ep.name in this:
raise ValueError("Duplicate entry point", group, ep.name) raise ValueError("Duplicate entry point", group, ep.name)
this[ep.name]=ep this[ep.name] = ep
return this return this
@classmethod @classmethod
...@@ -2356,7 +2356,7 @@ class Distribution(object): ...@@ -2356,7 +2356,7 @@ class Distribution(object):
@classmethod @classmethod
def from_location(cls, location, basename, metadata=None, **kw): def from_location(cls, location, basename, metadata=None, **kw):
project_name, version, py_version, platform = [None]*4 project_name, version, py_version, platform = [None] * 4
basename, ext = os.path.splitext(basename) basename, ext = os.path.splitext(basename)
if ext.lower() in _distributionImpl: if ext.lower() in _distributionImpl:
cls = _distributionImpl[ext.lower()] cls = _distributionImpl[ext.lower()]
...@@ -2478,9 +2478,9 @@ class Distribution(object): ...@@ -2478,9 +2478,9 @@ class Distribution(object):
extra, marker = extra.split(':', 1) extra, marker = extra.split(':', 1)
if invalid_marker(marker): if invalid_marker(marker):
# XXX warn # XXX warn
reqs=[] reqs = []
elif not evaluate_marker(marker): elif not evaluate_marker(marker):
reqs=[] reqs = []
extra = safe_extra(extra) or None extra = safe_extra(extra) or None
dm.setdefault(extra,[]).extend(parse_requirements(reqs)) dm.setdefault(extra,[]).extend(parse_requirements(reqs))
return dm return dm
...@@ -2611,7 +2611,7 @@ class Distribution(object): ...@@ -2611,7 +2611,7 @@ class Distribution(object):
nloc = _normalize_cached(loc) nloc = _normalize_cached(loc)
bdir = os.path.dirname(nloc) bdir = os.path.dirname(nloc)
npath= [(p and _normalize_cached(p) or p) for p in path] npath = [(p and _normalize_cached(p) or p) for p in path]
for p, item in enumerate(npath): for p, item in enumerate(npath):
if item == nloc: if item == nloc:
...@@ -2642,7 +2642,7 @@ class Distribution(object): ...@@ -2642,7 +2642,7 @@ class Distribution(object):
# p is the spot where we found or inserted loc; now remove duplicates # p is the spot where we found or inserted loc; now remove duplicates
while True: while True:
try: try:
np = npath.index(nloc, p+1) np = npath.index(nloc, p + 1)
except ValueError: except ValueError:
break break
else: else:
...@@ -2981,7 +2981,7 @@ def _initialize_master_working_set(): ...@@ -2981,7 +2981,7 @@ def _initialize_master_working_set():
dist.activate(replace=False) dist.activate(replace=False)
del dist del dist
add_activation_listener(lambda dist: dist.activate(replace=True), existing=False) add_activation_listener(lambda dist: dist.activate(replace=True), existing=False)
working_set.entries=[] working_set.entries = []
# match order # match order
list(map(working_set.add_entry, sys.path)) list(map(working_set.add_entry, sys.path))
globals().update(locals()) globals().update(locals())
...@@ -164,7 +164,7 @@ class TestDistro: ...@@ -164,7 +164,7 @@ class TestDistro:
ad.add(Baz) ad.add(Baz)
# Activation list now includes resolved dependency # Activation list now includes resolved dependency
assert list(ws.resolve(parse_requirements("Foo[bar]"), ad)) ==[Foo,Baz] assert list(ws.resolve(parse_requirements("Foo[bar]"), ad)) == [Foo,Baz]
# Requests for conflicting versions produce VersionConflict # Requests for conflicting versions produce VersionConflict
with pytest.raises(VersionConflict) as vc: with pytest.raises(VersionConflict) as vc:
ws.resolve(parse_requirements("Foo==1.2\nFoo!=1.2"), ad) ws.resolve(parse_requirements("Foo==1.2\nFoo!=1.2"), ad)
...@@ -426,7 +426,7 @@ class TestEntryPoints: ...@@ -426,7 +426,7 @@ class TestEntryPoints:
m = EntryPoint.parse_map({'xyz':self.submap_str}) m = EntryPoint.parse_map({'xyz':self.submap_str})
self.checkSubMap(m['xyz']) self.checkSubMap(m['xyz'])
assert list(m.keys()) == ['xyz'] assert list(m.keys()) == ['xyz']
m = EntryPoint.parse_map("[xyz]\n"+self.submap_str) m = EntryPoint.parse_map("[xyz]\n" + self.submap_str)
self.checkSubMap(m['xyz']) self.checkSubMap(m['xyz'])
assert list(m.keys()) == ['xyz'] assert list(m.keys()) == ['xyz']
with pytest.raises(ValueError): with pytest.raises(ValueError):
...@@ -644,7 +644,7 @@ class TestParsing: ...@@ -644,7 +644,7 @@ class TestParsing:
def testVersionOrdering(self): def testVersionOrdering(self):
def c(s1,s2): def c(s1,s2):
p1, p2 = parse_version(s1),parse_version(s2) p1, p2 = parse_version(s1),parse_version(s2)
assert p1<p2, (s1,s2,p1,p2) assert p1 < p2, (s1,s2,p1,p2)
c('2.1','2.1.1') c('2.1','2.1.1')
c('2a1','2b0') c('2a1','2b0')
...@@ -663,14 +663,14 @@ class TestParsing: ...@@ -663,14 +663,14 @@ class TestParsing:
c('2.1.0-rc1','2.1.0') c('2.1.0-rc1','2.1.0')
c('2.1dev','2.1a0') c('2.1dev','2.1a0')
torture =""" torture = """
0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1 0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1
0.79.9999+0.80.0pre2-3 0.79.9999+0.80.0pre2-2 0.79.9999+0.80.0pre2-3 0.79.9999+0.80.0pre2-2
0.77.2-1 0.77.1-1 0.77.0-1 0.77.2-1 0.77.1-1 0.77.0-1
""".split() """.split()
for p,v1 in enumerate(torture): for p,v1 in enumerate(torture):
for v2 in torture[p+1:]: for v2 in torture[p + 1:]:
c(v2,v1) c(v2,v1)
def testVersionBuildout(self): def testVersionBuildout(self):
...@@ -764,7 +764,7 @@ class TestNamespaces: ...@@ -764,7 +764,7 @@ class TestNamespaces:
pkg_resources._namespace_packages = saved_ns_pkgs pkg_resources._namespace_packages = saved_ns_pkgs
sys.path = saved_sys_path sys.path = saved_sys_path
issue591 = pytest.mark.xfail(platform.system()=='Windows', reason="#591") issue591 = pytest.mark.xfail(platform.system() == 'Windows', reason="#591")
@issue591 @issue591
def test_two_levels_deep(self, symlinked_tmpdir): def test_two_levels_deep(self, symlinked_tmpdir):
......
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