Commits

Vinay Sajip committed 8a8a2b3

Minor tweaks.

  • Participants
  • Parent commits 070f49c

Comments (0)

Files changed (2)

distlib/locators.py

                 if info['ptype'] != 'sdist' or info['pyversion'] != 'source':
                     continue
                 md = Metadata()
-                md['Name'] = name
+                md['Name'] = data['name']
                 md['Version'] = version = info['version']
                 md['Download-URL'] = info['url']
                 dist = Distribution(md)
                     SimpleScrapingLocator('http://pypi.python.org/simple/',
                                           timeout=3.0))
 
-def locate(requirement, scheme='default'):
+def locate(requirement, scheme='default', locator=None):
     """
     Locate a downloadable distribution, given a requirement (project name and
     version constraints, if any).
     result = None
     scheme = get_scheme(scheme)
     matcher = scheme.matcher(requirement)
-    versions = default_locator.get_project(matcher.name)
+    if locator is None:
+        locator = default_locator
+    versions = locator.get_project(matcher.name)
     if versions:
         # sometimes, versions are invalid
         slist = []
         if headers.get('Content-Type') != 'application/json':
             logger.debug('Unexpected response for JSON request')
         else:
-            data = resp.read().decode('utf-8')
-            result = json.loads(data)
+            #data = resp.read().decode('utf-8')
+            #result = json.loads(data)
+            result = json.load(resp)
     except Exception as e:
         logger.exception('Failed to get external data for %s: %s', url, e)
     return result
 
 
 def get_release_data(name):
+    #logger.debug('get_release_data start: %s', name)
     url = ('http://www.red-dove.com/pypi/projects/'
            '%s/%s/project.json' % (name[0].upper(), name))
-    return _get_external_data(url)
+    result = _get_external_data(url)
+    #logger.debug('get_release_data done: %s', name)
+    return result