mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Style change in packaging: use “not in” over “not x in”.
Such tests are IMO easier to read if both operators are grouped.
This commit is contained in:
parent
46bdcf7d4b
commit
df8ef02488
5 changed files with 16 additions and 16 deletions
|
@ -175,11 +175,11 @@ def convert_yn_to_bool(yn, yes=True, no=False):
|
||||||
def _build_classifiers_dict(classifiers):
|
def _build_classifiers_dict(classifiers):
|
||||||
d = {}
|
d = {}
|
||||||
for key in classifiers:
|
for key in classifiers:
|
||||||
subDict = d
|
subdict = d
|
||||||
for subkey in key.split(' :: '):
|
for subkey in key.split(' :: '):
|
||||||
if not subkey in subDict:
|
if subkey not in subdict:
|
||||||
subDict[subkey] = {}
|
subdict[subkey] = {}
|
||||||
subDict = subDict[subkey]
|
subdict = subdict[subkey]
|
||||||
return d
|
return d
|
||||||
|
|
||||||
CLASSIFIERS = _build_classifiers_dict(_CLASSIFIERS_LIST)
|
CLASSIFIERS = _build_classifiers_dict(_CLASSIFIERS_LIST)
|
||||||
|
|
|
@ -104,12 +104,12 @@ def _generate_cache(use_egg_info=False, paths=sys.path):
|
||||||
for dist in _yield_distributions(gen_dist, gen_egg, paths):
|
for dist in _yield_distributions(gen_dist, gen_egg, paths):
|
||||||
if isinstance(dist, Distribution):
|
if isinstance(dist, Distribution):
|
||||||
_cache_path[dist.path] = dist
|
_cache_path[dist.path] = dist
|
||||||
if not dist.name in _cache_name:
|
if dist.name not in _cache_name:
|
||||||
_cache_name[dist.name] = []
|
_cache_name[dist.name] = []
|
||||||
_cache_name[dist.name].append(dist)
|
_cache_name[dist.name].append(dist)
|
||||||
else:
|
else:
|
||||||
_cache_path_egg[dist.path] = dist
|
_cache_path_egg[dist.path] = dist
|
||||||
if not dist.name in _cache_name_egg:
|
if dist.name not in _cache_name_egg:
|
||||||
_cache_name_egg[dist.name] = []
|
_cache_name_egg[dist.name] = []
|
||||||
_cache_name_egg[dist.name].append(dist)
|
_cache_name_egg[dist.name].append(dist)
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ class Distribution:
|
||||||
self.version = self.metadata['Version']
|
self.version = self.metadata['Version']
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
if _cache_enabled and not path in _cache_path:
|
if _cache_enabled and path not in _cache_path:
|
||||||
_cache_path[path] = self
|
_cache_path[path] = self
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
|
@ -58,7 +58,7 @@ class DependencyGraph:
|
||||||
"""
|
"""
|
||||||
self.adjacency_list[x].append((y, label))
|
self.adjacency_list[x].append((y, label))
|
||||||
# multiple edges are allowed, so be careful
|
# multiple edges are allowed, so be careful
|
||||||
if not x in self.reverse_list[y]:
|
if x not in self.reverse_list[y]:
|
||||||
self.reverse_list[y].append(x)
|
self.reverse_list[y].append(x)
|
||||||
|
|
||||||
def add_missing(self, distribution, requirement):
|
def add_missing(self, distribution, requirement):
|
||||||
|
@ -157,7 +157,7 @@ def generate_graph(dists):
|
||||||
raise PackagingError('distribution %r has ill-formed'
|
raise PackagingError('distribution %r has ill-formed'
|
||||||
'provides field: %r' % (dist.name, p))
|
'provides field: %r' % (dist.name, p))
|
||||||
version = version[1:-1] # trim off parenthesis
|
version = version[1:-1] # trim off parenthesis
|
||||||
if not name in provided:
|
if name not in provided:
|
||||||
provided[name] = []
|
provided[name] = []
|
||||||
provided[name].append((version, dist))
|
provided[name].append((version, dist))
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ def generate_graph(dists):
|
||||||
|
|
||||||
name = predicate.name
|
name = predicate.name
|
||||||
|
|
||||||
if not name in provided:
|
if name not in provided:
|
||||||
graph.add_missing(dist, req)
|
graph.add_missing(dist, req)
|
||||||
else:
|
else:
|
||||||
matched = False
|
matched = False
|
||||||
|
@ -216,7 +216,7 @@ def dependent_dists(dists, dist):
|
||||||
node = fringe.pop()
|
node = fringe.pop()
|
||||||
dep.append(node)
|
dep.append(node)
|
||||||
for prev in graph.reverse_list[node]:
|
for prev in graph.reverse_list[node]:
|
||||||
if not prev in dep:
|
if prev not in dep:
|
||||||
fringe.append(prev)
|
fringe.append(prev)
|
||||||
|
|
||||||
dep.pop(0) # remove dist from dep, was there to prevent infinite loops
|
dep.pop(0) # remove dist from dep, was there to prevent infinite loops
|
||||||
|
|
|
@ -256,7 +256,7 @@ class DistInfo(IndexReference):
|
||||||
hashlib.new(hashname)
|
hashlib.new(hashname)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise UnsupportedHashName(hashname)
|
raise UnsupportedHashName(hashname)
|
||||||
if not url in [u['url'] for u in self.urls]:
|
if url not in [u['url'] for u in self.urls]:
|
||||||
self.urls.append({
|
self.urls.append({
|
||||||
'url': url,
|
'url': url,
|
||||||
'hashname': hashname,
|
'hashname': hashname,
|
||||||
|
@ -329,7 +329,7 @@ class DistInfo(IndexReference):
|
||||||
url param"""
|
url param"""
|
||||||
hashname = self.url['hashname']
|
hashname = self.url['hashname']
|
||||||
expected_hashval = self.url['hashval']
|
expected_hashval = self.url['hashval']
|
||||||
if not None in (expected_hashval, hashname):
|
if None not in (expected_hashval, hashname):
|
||||||
with open(filename, 'rb') as f:
|
with open(filename, 'rb') as f:
|
||||||
hashval = hashlib.new(hashname)
|
hashval = hashlib.new(hashname)
|
||||||
hashval.update(f.read())
|
hashval.update(f.read())
|
||||||
|
@ -409,7 +409,7 @@ class ReleasesList(IndexReference):
|
||||||
(release.name, self.name))
|
(release.name, self.name))
|
||||||
version = str(release.version)
|
version = str(release.version)
|
||||||
|
|
||||||
if not version in self.get_versions():
|
if version not in self.get_versions():
|
||||||
# append only if not already exists
|
# append only if not already exists
|
||||||
self.releases.append(release)
|
self.releases.append(release)
|
||||||
for dist in release.dists.values():
|
for dist in release.dists.values():
|
||||||
|
|
|
@ -283,7 +283,7 @@ class Crawler(BaseClient):
|
||||||
name = release.name
|
name = release.name
|
||||||
else:
|
else:
|
||||||
name = release_info['name']
|
name = release_info['name']
|
||||||
if not name.lower() in self._projects:
|
if name.lower() not in self._projects:
|
||||||
self._projects[name.lower()] = ReleasesList(name, index=self._index)
|
self._projects[name.lower()] = ReleasesList(name, index=self._index)
|
||||||
|
|
||||||
if release:
|
if release:
|
||||||
|
@ -321,7 +321,7 @@ class Crawler(BaseClient):
|
||||||
# it's a distribution, so create a dist object
|
# it's a distribution, so create a dist object
|
||||||
try:
|
try:
|
||||||
infos = get_infos_from_url(link, project_name,
|
infos = get_infos_from_url(link, project_name,
|
||||||
is_external=not self.index_url in url)
|
is_external=self.index_url not in url)
|
||||||
except CantParseArchiveName as e:
|
except CantParseArchiveName as e:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue