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

Merge pull request #742 from stepshal/whitespace

Add missing whitespace after comma.
parents 30594015 a527fa46
...@@ -752,8 +752,8 @@ class WorkingSet(object): ...@@ -752,8 +752,8 @@ class WorkingSet(object):
if entry is None: if entry is None:
entry = dist.location entry = dist.location
keys = self.entry_keys.setdefault(entry,[]) keys = self.entry_keys.setdefault(entry, [])
keys2 = self.entry_keys.setdefault(dist.location,[]) keys2 = self.entry_keys.setdefault(dist.location, [])
if not replace and dist.key in self.by_key: if not replace and dist.key in self.by_key:
# ignore hidden distros # ignore hidden distros
return return
...@@ -1353,7 +1353,7 @@ def get_default_cache(): ...@@ -1353,7 +1353,7 @@ def get_default_cache():
# best option, should be locale-safe # best option, should be locale-safe
(('APPDATA',), None), (('APPDATA',), None),
(('USERPROFILE',), app_data), (('USERPROFILE',), app_data),
(('HOMEDRIVE','HOMEPATH'), app_data), (('HOMEDRIVE', 'HOMEPATH'), app_data),
(('HOMEPATH',), app_data), (('HOMEPATH',), app_data),
(('HOME',), None), (('HOME',), None),
# 95/98/ME # 95/98/ME
...@@ -1392,7 +1392,7 @@ def safe_version(version): ...@@ -1392,7 +1392,7 @@ def safe_version(version):
# normalize the version # normalize the version
return str(packaging.version.Version(version)) return str(packaging.version.Version(version))
except packaging.version.InvalidVersion: except packaging.version.InvalidVersion:
version = version.replace(' ','.') version = version.replace(' ', '.')
return re.sub('[^A-Za-z0-9.]+', '-', version) return re.sub('[^A-Za-z0-9.]+', '-', version)
...@@ -1410,7 +1410,7 @@ def to_filename(name): ...@@ -1410,7 +1410,7 @@ def to_filename(name):
Any '-' characters are currently replaced with '_'. Any '-' characters are currently replaced with '_'.
""" """
return name.replace('-','_') return name.replace('-', '_')
def invalid_marker(text): def invalid_marker(text):
...@@ -1508,7 +1508,7 @@ class NullProvider: ...@@ -1508,7 +1508,7 @@ class NullProvider:
cache[script_filename] = ( cache[script_filename] = (
len(script_text), 0, script_text.split('\n'), script_filename len(script_text), 0, script_text.split('\n'), script_filename
) )
script_code = compile(script_text, script_filename,'exec') script_code = compile(script_text, script_filename, 'exec')
exec(script_code, namespace, namespace) exec(script_code, namespace, namespace)
def _has(self, path): def _has(self, path):
...@@ -1965,7 +1965,7 @@ def find_on_path(importer, path_item, only=False): ...@@ -1965,7 +1965,7 @@ def find_on_path(importer, path_item, only=False):
if _is_unpacked_egg(path_item): if _is_unpacked_egg(path_item):
yield Distribution.from_filename( yield Distribution.from_filename(
path_item, metadata=PathMetadata( path_item, metadata=PathMetadata(
path_item, os.path.join(path_item,'EGG-INFO') path_item, os.path.join(path_item, 'EGG-INFO')
) )
) )
else: else:
...@@ -2037,7 +2037,7 @@ def _handle_ns(packageName, path_item): ...@@ -2037,7 +2037,7 @@ def _handle_ns(packageName, path_item):
module = sys.modules[packageName] = types.ModuleType(packageName) module = sys.modules[packageName] = types.ModuleType(packageName)
module.__path__ = [] module.__path__ = []
_set_parent_ns(packageName) _set_parent_ns(packageName)
elif not hasattr(module,'__path__'): elif not hasattr(module, '__path__'):
raise TypeError("Not a package:", packageName) raise TypeError("Not a package:", packageName)
handler = _find_adapter(_namespace_handlers, importer) handler = _find_adapter(_namespace_handlers, importer)
subpath = handler(importer, path_item, packageName, module) subpath = handler(importer, path_item, packageName, module)
...@@ -2089,8 +2089,8 @@ def declare_namespace(packageName): ...@@ -2089,8 +2089,8 @@ def declare_namespace(packageName):
# Track what packages are namespaces, so when new path items are added, # Track what packages are namespaces, so when new path items are added,
# they can be updated # they can be updated
_namespace_packages.setdefault(parent,[]).append(packageName) _namespace_packages.setdefault(parent, []).append(packageName)
_namespace_packages.setdefault(packageName,[]) _namespace_packages.setdefault(packageName, [])
for path_item in path: for path_item in path:
# Ensure all the parent's path items are reflected in the child, # Ensure all the parent's path items are reflected in the child,
...@@ -2104,7 +2104,7 @@ def fixup_namespace_packages(path_item, parent=None): ...@@ -2104,7 +2104,7 @@ def fixup_namespace_packages(path_item, parent=None):
"""Ensure that previously-declared namespace packages include path_item""" """Ensure that previously-declared namespace packages include path_item"""
_imp.acquire_lock() _imp.acquire_lock()
try: try:
for package in _namespace_packages.get(parent,()): for package in _namespace_packages.get(parent, ()):
subpath = _handle_ns(package, path_item) subpath = _handle_ns(package, path_item)
if subpath: if subpath:
fixup_namespace_packages(subpath, package) fixup_namespace_packages(subpath, package)
...@@ -2482,7 +2482,7 @@ class Distribution(object): ...@@ -2482,7 +2482,7 @@ class Distribution(object):
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
def requires(self, extras=()): def requires(self, extras=()):
...@@ -2578,7 +2578,7 @@ class Distribution(object): ...@@ -2578,7 +2578,7 @@ class Distribution(object):
self._get_metadata('entry_points.txt'), self self._get_metadata('entry_points.txt'), self
) )
if group is not None: if group is not None:
return ep_map.get(group,{}) return ep_map.get(group, {})
return ep_map return ep_map
def get_entry_info(self, group, name): def get_entry_info(self, group, name):
...@@ -2682,7 +2682,7 @@ class Distribution(object): ...@@ -2682,7 +2682,7 @@ class Distribution(object):
return False return False
return True return True
def clone(self,**kw): def clone(self, **kw):
"""Copy this distribution, substituting in any changed keyword args""" """Copy this distribution, substituting in any changed keyword args"""
names = 'project_name version py_version platform location precedence' names = 'project_name version py_version platform location precedence'
for attr in names.split(): for attr in names.split():
...@@ -2769,7 +2769,7 @@ _distributionImpl = { ...@@ -2769,7 +2769,7 @@ _distributionImpl = {
} }
def issue_warning(*args,**kw): def issue_warning(*args, **kw):
level = 1 level = 1
g = globals() g = globals()
try: try:
...@@ -2916,12 +2916,12 @@ def split_sections(s): ...@@ -2916,12 +2916,12 @@ def split_sections(s):
# wrap up last segment # wrap up last segment
yield section, content yield section, content
def _mkstemp(*args,**kw): def _mkstemp(*args, **kw):
old_open = os.open old_open = os.open
try: try:
# temporarily bypass sandboxing # temporarily bypass sandboxing
os.open = os_open os.open = os_open
return tempfile.mkstemp(*args,**kw) return tempfile.mkstemp(*args, **kw)
finally: finally:
# and then put it back # and then put it back
os.open = old_open os.open = old_open
......
...@@ -51,15 +51,15 @@ class TestDistro: ...@@ -51,15 +51,15 @@ class TestDistro:
assert list(ad) == ['foopkg'] assert list(ad) == ['foopkg']
# Distributions sort by version # Distributions sort by version
assert [dist.version for dist in ad['FooPkg']] == ['1.4','1.3-1','1.2'] assert [dist.version for dist in ad['FooPkg']] == ['1.4', '1.3-1', '1.2']
# Removing a distribution leaves sequence alone # Removing a distribution leaves sequence alone
ad.remove(ad['FooPkg'][1]) ad.remove(ad['FooPkg'][1])
assert [dist.version for dist in ad['FooPkg']] == ['1.4','1.2'] assert [dist.version for dist in ad['FooPkg']] == ['1.4', '1.2']
# And inserting adds them in order # And inserting adds them in order
ad.add(dist_from_fn("FooPkg-1.9.egg")) ad.add(dist_from_fn("FooPkg-1.9.egg"))
assert [dist.version for dist in ad['FooPkg']] == ['1.9','1.4','1.2'] assert [dist.version for dist in ad['FooPkg']] == ['1.9', '1.4', '1.2']
ws = WorkingSet([]) ws = WorkingSet([])
foo12 = dist_from_fn("FooPkg-1.2-py2.4.egg") foo12 = dist_from_fn("FooPkg-1.2-py2.4.egg")
...@@ -86,7 +86,7 @@ class TestDistro: ...@@ -86,7 +86,7 @@ class TestDistro:
ws.add(foo14) ws.add(foo14)
assert ad.best_match(req, ws).version == '1.4' assert ad.best_match(req, ws).version == '1.4'
def checkFooPkg(self,d): def checkFooPkg(self, d):
assert d.project_name == "FooPkg" assert d.project_name == "FooPkg"
assert d.key == "foopkg" assert d.key == "foopkg"
assert d.version == "1.3.post1" assert d.version == "1.3.post1"
...@@ -97,7 +97,7 @@ class TestDistro: ...@@ -97,7 +97,7 @@ class TestDistro:
def testDistroBasics(self): def testDistroBasics(self):
d = Distribution( d = Distribution(
"/some/path", "/some/path",
project_name="FooPkg",version="1.3-1",py_version="2.4",platform="win32" project_name="FooPkg", version="1.3-1", py_version="2.4", platform="win32"
) )
self.checkFooPkg(d) self.checkFooPkg(d)
...@@ -115,7 +115,7 @@ class TestDistro: ...@@ -115,7 +115,7 @@ class TestDistro:
d = Distribution( d = Distribution(
"/some/path", project_name="FooPkg", py_version="2.4", platform="win32", "/some/path", project_name="FooPkg", py_version="2.4", platform="win32",
metadata=Metadata( metadata=Metadata(
('PKG-INFO',"Metadata-Version: 1.0\nVersion: 1.3-1\n") ('PKG-INFO', "Metadata-Version: 1.0\nVersion: 1.3-1\n")
) )
) )
self.checkFooPkg(d) self.checkFooPkg(d)
...@@ -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)
...@@ -218,7 +218,7 @@ class TestDistro: ...@@ -218,7 +218,7 @@ class TestDistro:
quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info") quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info")
ad.add(quux) ad.add(quux)
res = list(ws.resolve(parse_requirements("Foo[baz]"), ad)) res = list(ws.resolve(parse_requirements("Foo[baz]"), ad))
assert res == [Foo,quux] assert res == [Foo, quux]
def test_marker_evaluation_with_multiple_extras(self): def test_marker_evaluation_with_multiple_extras(self):
ad = pkg_resources.Environment([]) ad = pkg_resources.Environment([])
...@@ -238,7 +238,7 @@ class TestDistro: ...@@ -238,7 +238,7 @@ class TestDistro:
fred = Distribution.from_filename("/foo_dir/fred-0.1.dist-info") fred = Distribution.from_filename("/foo_dir/fred-0.1.dist-info")
ad.add(fred) ad.add(fred)
res = list(ws.resolve(parse_requirements("Foo[baz,bar]"), ad)) res = list(ws.resolve(parse_requirements("Foo[baz,bar]"), ad))
assert sorted(res) == [fred,quux,Foo] assert sorted(res) == [fred, quux, Foo]
def test_marker_evaluation_with_extras_loop(self): def test_marker_evaluation_with_extras_loop(self):
ad = pkg_resources.Environment([]) ad = pkg_resources.Environment([])
...@@ -274,19 +274,19 @@ class TestDistro: ...@@ -274,19 +274,19 @@ class TestDistro:
docutils>=0.3 docutils>=0.3
[fastcgi] [fastcgi]
fcgiapp>=0.1""") fcgiapp>=0.1""")
self.checkRequires(d,"Twisted>=1.5") self.checkRequires(d, "Twisted>=1.5")
self.checkRequires( self.checkRequires(
d,"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3".split(), ["docgen"] d, "Twisted>=1.5 ZConfig>=2.0 docutils>=0.3".split(), ["docgen"]
) )
self.checkRequires( self.checkRequires(
d,"Twisted>=1.5 fcgiapp>=0.1".split(), ["fastcgi"] d, "Twisted>=1.5 fcgiapp>=0.1".split(), ["fastcgi"]
) )
self.checkRequires( self.checkRequires(
d,"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3 fcgiapp>=0.1".split(), d, "Twisted>=1.5 ZConfig>=2.0 docutils>=0.3 fcgiapp>=0.1".split(),
["docgen","fastcgi"] ["docgen", "fastcgi"]
) )
self.checkRequires( self.checkRequires(
d,"Twisted>=1.5 fcgiapp>=0.1 ZConfig>=2.0 docutils>=0.3".split(), d, "Twisted>=1.5 fcgiapp>=0.1 ZConfig>=2.0 docutils>=0.3".split(),
["fastcgi", "docgen"] ["fastcgi", "docgen"]
) )
with pytest.raises(pkg_resources.UnknownExtra): with pytest.raises(pkg_resources.UnknownExtra):
...@@ -348,7 +348,7 @@ class TestEntryPoints: ...@@ -348,7 +348,7 @@ class TestEntryPoints:
def setup_method(self, method): def setup_method(self, method):
self.dist = Distribution.from_filename( self.dist = Distribution.from_filename(
"FooPkg-1.2-py2.4.egg", metadata=Metadata(('requires.txt','[x]'))) "FooPkg-1.2-py2.4.egg", metadata=Metadata(('requires.txt', '[x]')))
def testBasics(self): def testBasics(self):
ep = EntryPoint( ep = EntryPoint(
...@@ -405,7 +405,7 @@ class TestEntryPoints: ...@@ -405,7 +405,7 @@ class TestEntryPoints:
submap_expect = dict( submap_expect = dict(
feature1=EntryPoint('feature1', 'somemodule', ['somefunction']), feature1=EntryPoint('feature1', 'somemodule', ['somefunction']),
feature2=EntryPoint('feature2', 'another.module', ['SomeClass'], ['extra1','extra2']), feature2=EntryPoint('feature2', 'another.module', ['SomeClass'], ['extra1', 'extra2']),
feature3=EntryPoint('feature3', 'this.module', extras=['something']) feature3=EntryPoint('feature3', 'this.module', extras=['something'])
) )
submap_str = """ submap_str = """
...@@ -423,7 +423,7 @@ class TestEntryPoints: ...@@ -423,7 +423,7 @@ class TestEntryPoints:
EntryPoint.parse_group("x", ["foo=baz", "foo=bar"]) EntryPoint.parse_group("x", ["foo=baz", "foo=bar"])
def testParseMap(self): def testParseMap(self):
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)
...@@ -480,7 +480,7 @@ class TestRequirements: ...@@ -480,7 +480,7 @@ class TestRequirements:
hash(( hash((
"twisted", "twisted",
packaging.specifiers.SpecifierSet(">=1.2"), packaging.specifiers.SpecifierSet(">=1.2"),
frozenset(["foo","bar"]), frozenset(["foo", "bar"]),
None None
)) ))
) )
...@@ -521,9 +521,9 @@ class TestParsing: ...@@ -521,9 +521,9 @@ class TestParsing:
assert list(parse_requirements('')) == [] assert list(parse_requirements('')) == []
def testYielding(self): def testYielding(self):
for inp,out in [ for inp, out in [
([], []), ('x',['x']), ([[]],[]), (' x\n y', ['x','y']), ([], []), ('x', ['x']), ([[]], []), (' x\n y', ['x', 'y']),
(['x\n\n','y'], ['x','y']), (['x\n\n', 'y'], ['x', 'y']),
]: ]:
assert list(pkg_resources.yield_lines(inp)) == out assert list(pkg_resources.yield_lines(inp)) == out
...@@ -626,9 +626,9 @@ class TestParsing: ...@@ -626,9 +626,9 @@ class TestParsing:
req, = parse_requirements('foo >= 1.0, < 3') req, = parse_requirements('foo >= 1.0, < 3')
def testVersionEquality(self): def testVersionEquality(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('1.2-rc1', '1.2rc1') c('1.2-rc1', '1.2rc1')
c('0.4', '0.4.0') c('0.4', '0.4.0')
...@@ -642,13 +642,13 @@ class TestParsing: ...@@ -642,13 +642,13 @@ class TestParsing:
c('1.2.a', '1.2a') c('1.2.a', '1.2a')
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')
c('2a1','2.1') c('2a1', '2.1')
c('2.3a1', '2.3') c('2.3a1', '2.3')
c('2.1-1', '2.1-2') c('2.1-1', '2.1-2')
c('2.1-1', '2.1.1') c('2.1-1', '2.1.1')
...@@ -660,8 +660,8 @@ class TestParsing: ...@@ -660,8 +660,8 @@ class TestParsing:
c('0.4', '4.0') c('0.4', '4.0')
c('0.0.4', '0.4.0') c('0.0.4', '0.4.0')
c('0post1', '0.4post1') c('0post1', '0.4post1')
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
...@@ -669,9 +669,9 @@ class TestParsing: ...@@ -669,9 +669,9 @@ class TestParsing:
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):
""" """
......
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