[125609] users/g5pw/pypi2port/pypi2port.py

g5pw at macports.org g5pw at macports.org
Mon Sep 22 12:53:17 PDT 2014


Revision: 125609
          https://trac.macports.org/changeset/125609
Author:   g5pw at macports.org
Date:     2014-09-22 12:53:16 -0700 (Mon, 22 Sep 2014)
Log Message:
-----------
Conditionally import urllib

This should work for python3, too, although it is untested because of a missing
dependency.

Modified Paths:
--------------
    users/g5pw/pypi2port/pypi2port.py

Modified: users/g5pw/pypi2port/pypi2port.py
===================================================================
--- users/g5pw/pypi2port/pypi2port.py	2014-09-22 19:53:11 UTC (rev 125608)
+++ users/g5pw/pypi2port/pypi2port.py	2014-09-22 19:53:16 UTC (rev 125609)
@@ -11,14 +11,15 @@
 import argparse
 import sys
 import os
-import urllib2
 import hashlib
 import zipfile
 import progressbar as pb
 try:
     import xmlrpclib
+    from urllib2 import urlopen
 except ImportError:
     import xmlrpc.client as xmlrpclib
+    from urllib.request import urlopen
 import textwrap
 import string
 import shutil
@@ -77,7 +78,7 @@
     url = dict['url']
     file_name = src_dir + '/' + dict['filename']
 
-    u = urllib2.urlopen(url)
+    u = urlopen(url)
     with open(file_name, 'wb') as f:
         meta = u.info()
         file_size = int(meta.getheaders("Content-Length")[0])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140922/d21be3b5/attachment.html>


More information about the macports-changes mailing list