summaryrefslogtreecommitdiff
path: root/distutils2
diff options
context:
space:
mode:
authorKelsey Hightower <kelsey.hightower@gmail.com>2011-02-09 16:48:07 -0500
committerKelsey Hightower <kelsey.hightower@gmail.com>2011-02-09 16:48:07 -0500
commit16c212fcd49076eea95bf0e69709eb070b258c0f (patch)
tree4ae3b9756c37a052b58e09734ef4a4677eda4043 /distutils2
parent74314e447d926f90225e4df7cdc8ff25b859b767 (diff)
downloaddisutils2-16c212fcd49076eea95bf0e69709eb070b258c0f.tar.gz
pep8 formatting of the distutils2.index package
Diffstat (limited to 'distutils2')
-rw-r--r--distutils2/index/__init__.py2
-rw-r--r--distutils2/index/dist.py3
-rw-r--r--distutils2/index/mirrors.py14
-rw-r--r--distutils2/index/wrapper.py5
-rw-r--r--distutils2/index/xmlrpc.py1
5 files changed, 14 insertions, 11 deletions
diff --git a/distutils2/index/__init__.py b/distutils2/index/__init__.py
index 312662f..c80b873 100644
--- a/distutils2/index/__init__.py
+++ b/distutils2/index/__init__.py
@@ -6,6 +6,6 @@ __all__ = ['simple',
'xmlrpc',
'dist',
'errors',
- 'mirrors',]
+ 'mirrors']
from dist import ReleaseInfo, ReleasesList, DistInfo
diff --git a/distutils2/index/dist.py b/distutils2/index/dist.py
index fe6c616..b03492b 100644
--- a/distutils2/index/dist.py
+++ b/distutils2/index/dist.py
@@ -109,7 +109,8 @@ class ReleaseInfo(IndexReference):
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
index 49d5dd1..885082c 100644
--- 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 @@ import socket
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 @@ def get_mirrors(hostname=None):
"""
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 @@ def get_mirrors(hostname=None):
# 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
index b2b5700..d032f95 100644
--- a/distutils2/index/wrapper.py
+++ b/distutils2/index/wrapper.py
@@ -9,6 +9,7 @@ _WRAPPER_MAPPINGS = {'get_release': 'simple',
_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 @@ class ClientWrapper(object):
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
index 54d7367..6264926 100644
--- a/distutils2/index/xmlrpc.py
+++ b/distutils2/index/xmlrpc.py
@@ -103,7 +103,6 @@ class Client(BaseClient):
project.sort_releases(prefer_final)
return project
-
def get_distributions(self, project_name, version):
"""Grab informations about distributions from XML-RPC.