[Python-3000-checkins] r64479 - in python/branches/py3k/Tools: faqwiz/faqwiz.py versioncheck/pyversioncheck.py webchecker/webchecker.py webchecker/websucker.py

georg.brandl python-3000-checkins at python.org
Mon Jun 23 13:45:20 CEST 2008


Author: georg.brandl
Date: Mon Jun 23 13:45:20 2008
New Revision: 64479

Log:
More old urllib usage.


Modified:
   python/branches/py3k/Tools/faqwiz/faqwiz.py
   python/branches/py3k/Tools/versioncheck/pyversioncheck.py
   python/branches/py3k/Tools/webchecker/webchecker.py
   python/branches/py3k/Tools/webchecker/websucker.py

Modified: python/branches/py3k/Tools/faqwiz/faqwiz.py
==============================================================================
--- python/branches/py3k/Tools/faqwiz/faqwiz.py	(original)
+++ python/branches/py3k/Tools/faqwiz/faqwiz.py	Mon Jun 23 13:45:20 2008
@@ -138,8 +138,8 @@
         value = cookies[COOKIE_NAME]
     except KeyError:
         return {}
-    import urllib
-    value = urllib.unquote(value)
+    import urllib.parse
+    value = urllib.parse.unquote(value)
     words = value.split('/')
     while len(words) < 3:
         words.append('')
@@ -153,8 +153,8 @@
 def send_my_cookie(ui):
     name = COOKIE_NAME
     value = "%s/%s/%s" % (ui.author, ui.email, ui.password)
-    import urllib
-    value = urllib.quote(value)
+    import urllib.parse
+    value = urllib.parse.quote(value)
     then = now + COOKIE_LIFETIME
     gmt = time.gmtime(then)
     path = os.environ.get('SCRIPT_NAME', '/cgi-bin/')

Modified: python/branches/py3k/Tools/versioncheck/pyversioncheck.py
==============================================================================
--- python/branches/py3k/Tools/versioncheck/pyversioncheck.py	(original)
+++ python/branches/py3k/Tools/versioncheck/pyversioncheck.py	Mon Jun 23 13:45:20 2008
@@ -1,5 +1,5 @@
 """pyversioncheck - Module to help with checking versions"""
-import urllib
+import urllib.request
 import email
 import sys
 
@@ -47,7 +47,7 @@
     if verbose >= VERBOSE_EACHFILE:
         print('  Checking %s'%url)
     try:
-        fp = urllib.urlopen(url)
+        fp = urllib.request.urlopen(url)
     except IOError as arg:
         if verbose >= VERBOSE_EACHFILE:
             print('    Cannot open:', arg)

Modified: python/branches/py3k/Tools/webchecker/webchecker.py
==============================================================================
--- python/branches/py3k/Tools/webchecker/webchecker.py	(original)
+++ python/branches/py3k/Tools/webchecker/webchecker.py	Mon Jun 23 13:45:20 2008
@@ -113,13 +113,13 @@
 import getopt
 import pickle
 
-import urllib
-import urlparse
+import urllib.request
+import urllib.parse as urlparse
 import sgmllib
 import cgi
 
 import mimetypes
-import robotparser
+from urllib import robotparser
 
 # Extract real version number if necessary
 if __version__[0] == '$':
@@ -487,7 +487,7 @@
         if url in self.name_table:
             return self.name_table[url]
 
-        scheme, path = urllib.splittype(url)
+        scheme, path = urllib.request.splittype(url)
         if scheme in ('mailto', 'news', 'javascript', 'telnet'):
             self.note(1, " Not checking %s URL" % scheme)
             return None
@@ -733,13 +733,13 @@
         return self.__url
 
 
-class MyURLopener(urllib.FancyURLopener):
+class MyURLopener(urllib.request.FancyURLopener):
 
-    http_error_default = urllib.URLopener.http_error_default
+    http_error_default = urllib.request.URLopener.http_error_default
 
     def __init__(*args):
         self = args[0]
-        urllib.FancyURLopener.__init__(*args)
+        urllib.request.FancyURLopener.__init__(*args)
         self.addheaders = [
             ('User-agent', 'Python-webchecker/%s' % __version__),
             ]
@@ -769,7 +769,7 @@
                 s.write('<A HREF="%s">%s</A>\n' % (q, q))
             s.seek(0)
             return s
-        return urllib.FancyURLopener.open_file(self, url)
+        return urllib.request.FancyURLopener.open_file(self, url)
 
 
 class MyHTMLParser(sgmllib.SGMLParser):

Modified: python/branches/py3k/Tools/webchecker/websucker.py
==============================================================================
--- python/branches/py3k/Tools/webchecker/websucker.py	(original)
+++ python/branches/py3k/Tools/webchecker/websucker.py	Mon Jun 23 13:45:20 2008
@@ -6,8 +6,8 @@
 
 import os
 import sys
-import urllib
 import getopt
+import urllib.parse
 
 import webchecker
 
@@ -87,11 +87,11 @@
             self.message("didn't save %s: %s", path, str(msg))
 
     def savefilename(self, url):
-        type, rest = urllib.splittype(url)
-        host, path = urllib.splithost(rest)
+        type, rest = urllib.parse.splittype(url)
+        host, path = urllib.parse.splithost(rest)
         path = path.lstrip("/")
-        user, host = urllib.splituser(host)
-        host, port = urllib.splitnport(host)
+        user, host = urllib.parse.splituser(host)
+        host, port = urllib.parse.splitnport(host)
         host = host.lower()
         if not path or path[-1] == "/":
             path = path + "index.html"


More information about the Python-3000-checkins mailing list