[Python-checkins] distutils2: pep8 formatting of the distutils2.index package
tarek.ziade
python-checkins at python.org
Wed Feb 16 22:23:56 CET 2011
tarek.ziade pushed 89b8e21129e6 to distutils2:
http://hg.python.org/distutils2/rev/89b8e21129e6
changeset: 1011:89b8e21129e6
user: Kelsey Hightower <kelsey.hightower at gmail.com>
date: Wed Feb 09 16:48:07 2011 -0500
summary:
pep8 formatting of the distutils2.index package
files:
distutils2/index/__init__.py
distutils2/index/dist.py
distutils2/index/mirrors.py
distutils2/index/wrapper.py
distutils2/index/xmlrpc.py
diff --git a/distutils2/index/__init__.py b/distutils2/index/__init__.py
--- a/distutils2/index/__init__.py
+++ b/distutils2/index/__init__.py
@@ -6,6 +6,6 @@
'xmlrpc',
'dist',
'errors',
- 'mirrors',]
+ 'mirrors']
from dist import ReleaseInfo, ReleasesList, DistInfo
diff --git a/distutils2/index/dist.py b/distutils2/index/dist.py
--- a/distutils2/index/dist.py
+++ b/distutils2/index/dist.py
@@ -109,7 +109,8 @@
self.dists = {}
return self.dists
- def add_distribution(self, dist_type='sdist', python_version=None, **params):
+ def add_distribution(self, dist_type='sdist', python_version=None,
+ **params):
"""Add distribution informations to this release.
If distribution information is already set for this distribution type,
add the given url paths to the distribution. This can be useful while
diff --git a/distutils2/index/mirrors.py b/distutils2/index/mirrors.py
--- a/distutils2/index/mirrors.py
+++ b/distutils2/index/mirrors.py
@@ -1,4 +1,4 @@
-"""Utilities related to the mirror infrastructure defined in PEP 381.
+"""Utilities related to the mirror infrastructure defined in PEP 381.
See http://www.python.org/dev/peps/pep-0381/
"""
@@ -7,6 +7,7 @@
DEFAULT_MIRROR_URL = "last.pypi.python.org"
+
def get_mirrors(hostname=None):
"""Return the list of mirrors from the last record found on the DNS
entry::
@@ -19,7 +20,7 @@
"""
if hostname is None:
hostname = DEFAULT_MIRROR_URL
-
+
# return the last mirror registered on PyPI.
try:
hostname = socket.gethostbyname_ex(hostname)[0]
@@ -30,23 +31,24 @@
# determine the list from the last one.
return ["%s.%s" % (s, end_letter[1]) for s in string_range(end_letter[0])]
+
def string_range(last):
"""Compute the range of string between "a" and last.
-
+
This works for simple "a to z" lists, but also for "a to zz" lists.
"""
for k in range(len(last)):
- for x in product(ascii_lowercase, repeat=k+1):
+ for x in product(ascii_lowercase, repeat=(k + 1)):
result = ''.join(x)
yield result
if result == last:
return
+
def product(*args, **kwds):
pools = map(tuple, args) * kwds.get('repeat', 1)
result = [[]]
for pool in pools:
- result = [x+[y] for x in result for y in pool]
+ result = [x + [y] for x in result for y in pool]
for prod in result:
yield tuple(prod)
-
diff --git a/distutils2/index/wrapper.py b/distutils2/index/wrapper.py
--- a/distutils2/index/wrapper.py
+++ b/distutils2/index/wrapper.py
@@ -9,6 +9,7 @@
_WRAPPER_INDEXES = {'xmlrpc': xmlrpc.Client,
'simple': simple.Crawler}
+
def switch_index_if_fails(func, wrapper):
"""Decorator that switch of index (for instance from xmlrpc to simple)
if the first mirror return an empty list or raises an exception.
@@ -82,11 +83,11 @@
other_indexes = [i for i in self._indexes
if i != self._default_index]
for index in other_indexes:
- real_method = getattr(self._indexes[index], method_name, None)
+ real_method = getattr(self._indexes[index], method_name,
+ None)
if real_method:
break
if real_method:
return switch_index_if_fails(real_method, self)
else:
raise AttributeError("No index have attribute '%s'" % method_name)
-
diff --git a/distutils2/index/xmlrpc.py b/distutils2/index/xmlrpc.py
--- a/distutils2/index/xmlrpc.py
+++ b/distutils2/index/xmlrpc.py
@@ -103,7 +103,6 @@
project.sort_releases(prefer_final)
return project
-
def get_distributions(self, project_name, version):
"""Grab informations about distributions from XML-RPC.
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list