[Python-checkins] r65942 - in sandbox/trunk/setuptools/setuptools: package_index.py tests/test_packageindex.py

phillip.eby python-checkins at python.org
Thu Aug 21 19:55:34 CEST 2008


Author: phillip.eby
Date: Thu Aug 21 19:55:32 2008
New Revision: 65942

Log:
Fix for http://bugs.python.org/setuptools/issue7


Modified:
   sandbox/trunk/setuptools/setuptools/package_index.py
   sandbox/trunk/setuptools/setuptools/tests/test_packageindex.py

Modified: sandbox/trunk/setuptools/setuptools/package_index.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/package_index.py	(original)
+++ sandbox/trunk/setuptools/setuptools/package_index.py	Thu Aug 21 19:55:32 2008
@@ -220,7 +220,8 @@
             map(self.add, dists)
 
     def url_ok(self, url, fatal=False):
-        if self.allows(urlparse.urlparse(url)[1]):
+        s = URL_SCHEME(url)
+        if (s and s.group(1).lower()=='file') or self.allows(urlparse.urlparse(url)[1]):
             return True
         msg = "\nLink to % s ***BLOCKED*** by --allow-hosts\n"
         if fatal:
@@ -243,7 +244,6 @@
                 dist.precedence = SOURCE_DIST
                 self.add(dist)
 
-
     def process_index(self,url,page):
         """Process the contents of a PyPI page"""
         def scan(link):

Modified: sandbox/trunk/setuptools/setuptools/tests/test_packageindex.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/tests/test_packageindex.py	(original)
+++ sandbox/trunk/setuptools/setuptools/tests/test_packageindex.py	Thu Aug 21 19:55:32 2008
@@ -17,3 +17,11 @@
             self.assert_(url in str(v))
         else:
             self.assert_(isinstance(v,urllib2.HTTPError))
+
+    def test_url_ok(self):
+        index = setuptools.package_index.PackageIndex(
+            hosts=('www.example.com',)
+        )
+        url = 'file:///tmp/test_package_index'
+        self.assert_(index.url_ok(url, True))
+


More information about the Python-checkins mailing list