<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[125591] users/g5pw/pypi2port/pypi2port.py</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/125591">125591</a></dd>
<dt>Author</dt> <dd>g5pw@macports.org</dd>
<dt>Date</dt> <dd>2014-09-22 02:54:09 -0700 (Mon, 22 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Remove flake8 errors
* Remove unused variables
* Remove unnecessary newlines
* Explicitly name imports (avoid from x import *)
* Adjust indentation (even with comments)
* Remove unused imports
* Fix name error (Error class doesn't exist, probably meant Exception?)
* Shorten some long lines, making them more "pythonic"</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#usersg5pwpypi2portpypi2portpy">users/g5pw/pypi2port/pypi2port.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="usersg5pwpypi2portpypi2portpy"></a>
<div class="modfile"><h4>Modified: users/g5pw/pypi2port/pypi2port.py (125590 => 125591)</h4>
<pre class="diff"><span>
<span class="info">--- users/g5pw/pypi2port/pypi2port.py        2014-09-22 08:39:10 UTC (rev 125590)
+++ users/g5pw/pypi2port/pypi2port.py        2014-09-22 09:54:09 UTC (rev 125591)
</span><span class="lines">@@ -14,7 +14,7 @@
</span><span class="cx"> import urllib2
</span><span class="cx"> import hashlib
</span><span class="cx"> import zipfile
</span><del>-from progressbar import *
</del><ins>+import progressbar as pb
</ins><span class="cx"> try:
</span><span class="cx"> import xmlrpclib
</span><span class="cx"> except ImportError:
</span><span class="lines">@@ -26,8 +26,6 @@
</span><span class="cx"> import difflib
</span><span class="cx"> import subprocess
</span><span class="cx"> import requests
</span><del>-import shlex
-import getpass
</del><span class="cx">
</span><span class="cx"> client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
</span><span class="cx">
</span><span class="lines">@@ -92,10 +90,10 @@
</span><span class="cx"> meta = u.info()
</span><span class="cx"> file_size = int(meta.getheaders("Content-Length")[0])
</span><span class="cx">
</span><del>- widgets = ['Fetching: ', Percentage(), ' ',
- Bar(marker=RotatingMarker(), left='[', right=']'),
- ' ', ETA(), ' ', FileTransferSpeed()]
- pbar = ProgressBar(widgets=widgets, maxval=int(file_size))
</del><ins>+ widgets = ['Fetching: ', pb.Percentage(), ' ',
+ pb.Bar(marker=pb.RotatingMarker(), left='[', right=']'),
+ ' ', pb.ETA(), ' ', pb.FileTransferSpeed()]
+ pbar = pb.ProgressBar(widgets=widgets, maxval=int(file_size))
</ins><span class="cx"> pbar.start()
</span><span class="cx">
</span><span class="cx"> file_size_dl = 0
</span><span class="lines">@@ -137,9 +135,9 @@
</span><span class="cx"> def fetch_url(pkg_name, pkg_version, checksum=False, deps=False):
</span><span class="cx"> values = client.release_urls(pkg_name, pkg_version)
</span><span class="cx"> if checksum:
</span><del>-# print values
</del><ins>+ # print values
</ins><span class="cx"> for value in values:
</span><del>- if value['filename'].split('.')[-1] == 'gz' or value['filename'].split('.')[-1] == 'zip':
</del><ins>+ if value['filename'].split('.')[-1] in ['gz', 'zip']:
</ins><span class="cx"> return fetch(pkg_name, value)
</span><span class="cx"> else:
</span><span class="cx"> for value in values:
</span><span class="lines">@@ -156,7 +154,7 @@
</span><span class="cx"> return
</span><span class="cx"> values = client.release_urls(pkg_name, pkg_version)
</span><span class="cx"> for value in values:
</span><del>- if not(value['filename'].split('.')[-1] == 'gz' or value['filename'].split('.')[-1] == 'zip'):
</del><ins>+ if value['filename'].split('.')[-1] in ['gz', 'zip']:
</ins><span class="cx"> fetch(pkg_name, value)
</span><span class="cx"> try:
</span><span class="cx"> with open('./sources/python/py-'
</span><span class="lines">@@ -170,7 +168,7 @@
</span><span class="cx"> ignore_errors=True)
</span><span class="cx"> items = os.listdir('./sources/python/py-' + pkg_name)
</span><span class="cx"> for item in items[:]:
</span><del>- if not(item.split('.')[-1] == 'gz' or item.split('.')[-1] == 'zip'):
</del><ins>+ if item.split('.')[-1] not in ['gz', 'zip']:
</ins><span class="cx"> os.remove('./sources/python/py-'
</span><span class="cx"> + pkg_name + '/' + item)
</span><span class="cx"> items.remove(item)
</span><span class="lines">@@ -186,7 +184,7 @@
</span><span class="cx"> ignore_errors=True)
</span><span class="cx"> items = os.listdir('./sources/python/py-'+pkg_name)
</span><span class="cx"> for item in items[:]:
</span><del>- if not(item.split('.')[-1] == 'gz' or item.split('.')[-1] == 'zip'):
</del><ins>+ if item.split('.')[-1] not in ['gz', 'zip']:
</ins><span class="cx"> os.remove('./sources/python/py-'+pkg_name+'/'+item)
</span><span class="cx"> items.remove(item)
</span><span class="cx"> if not items:
</span><span class="lines">@@ -225,7 +223,7 @@
</span><span class="cx"> existing_portfile = \
</span><span class="cx"> subprocess.check_output(command, stderr=subprocess.STDOUT).strip()
</span><span class="cx"> return existing_portfile
</span><del>- except Exception, e:
</del><ins>+ except Exception:
</ins><span class="cx"> return False
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -259,7 +257,7 @@
</span><span class="cx"> try:
</span><span class="cx"> if flag:
</span><span class="cx"> os.rmdir(dir)
</span><del>- except OSError as ex:
</del><ins>+ except OSError:
</ins><span class="cx"> pass
</span><span class="cx"> return checksums
</span><span class="cx"> except:
</span><span class="lines">@@ -275,7 +273,7 @@
</span><span class="cx"> url = client.release_urls(name, version)[0]['url']
</span><span class="cx"> r = requests.get(url, verify=False)
</span><span class="cx"> if not r.status_code == 200:
</span><del>- raise Error('No distfile')
</del><ins>+ raise Exception('No distfile')
</ins><span class="cx"> except:
</span><span class="cx"> print "No distfile found"
</span><span class="cx"> print "Please set a DISTFILE env var before generating the portfile"
</span><span class="lines">@@ -340,7 +338,7 @@
</span><span class="cx"> command = "sudo port -t fetch dports/python/py-" + \
</span><span class="cx"> name + " subport=py" + portv + "-" + name
</span><span class="cx"> command = command.split()
</span><del>- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
</del><ins>+ subprocess.check_call(command, stderr=subprocess.STDOUT)
</ins><span class="cx"> return True
</span><span class="cx"> except:
</span><span class="cx"> return False
</span><span class="lines">@@ -354,7 +352,7 @@
</span><span class="cx"> command = "sudo port -t checksum dports/python/py-" + \
</span><span class="cx"> name + " subport=py" + portv + "-" + name
</span><span class="cx"> command = command.split()
</span><del>- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
</del><ins>+ subprocess.check_call(command, stderr=subprocess.STDOUT)
</ins><span class="cx"> return True
</span><span class="cx"> except:
</span><span class="cx"> return False
</span><span class="lines">@@ -368,7 +366,7 @@
</span><span class="cx"> command = "sudo port -t extract dports/python/py-" + \
</span><span class="cx"> name + " subport=py" + portv + "-" + name
</span><span class="cx"> command = command.split()
</span><del>- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
</del><ins>+ subprocess.check_call(command, stderr=subprocess.STDOUT)
</ins><span class="cx"> return True
</span><span class="cx"> except:
</span><span class="cx"> return False
</span><span class="lines">@@ -382,7 +380,7 @@
</span><span class="cx"> command = "sudo port -t patch dports/python/py-" + \
</span><span class="cx"> name + " subport=py" + portv + "-" + name
</span><span class="cx"> command = command.split()
</span><del>- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
</del><ins>+ subprocess.check_call(command, stderr=subprocess.STDOUT)
</ins><span class="cx"> return True
</span><span class="cx"> except:
</span><span class="cx"> return False
</span><span class="lines">@@ -396,7 +394,7 @@
</span><span class="cx"> command = "sudo port -t configure dports/python/py-" + \
</span><span class="cx"> name + " subport=py" + portv + "-" + name
</span><span class="cx"> command = command.split()
</span><del>- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
</del><ins>+ subprocess.check_call(command, stderr=subprocess.STDOUT)
</ins><span class="cx"> return True
</span><span class="cx"> except:
</span><span class="cx"> return False
</span><span class="lines">@@ -410,7 +408,7 @@
</span><span class="cx"> command = "sudo port -t build dports/python/py-" + \
</span><span class="cx"> name + " subport=py" + portv + "-" + name
</span><span class="cx"> command = command.split()
</span><del>- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
</del><ins>+ subprocess.check_call(command, stderr=subprocess.STDOUT)
</ins><span class="cx"> return True
</span><span class="cx"> except:
</span><span class="cx"> return False
</span><span class="lines">@@ -424,7 +422,7 @@
</span><span class="cx"> command = "sudo port -t destroot dports/python/py-" + \
</span><span class="cx"> name + " subport=py" + portv + "-" + name
</span><span class="cx"> command = command.split()
</span><del>- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
</del><ins>+ subprocess.check_call(command, stderr=subprocess.STDOUT)
</ins><span class="cx"> return True
</span><span class="cx"> except:
</span><span class="cx"> return False
</span><span class="lines">@@ -438,7 +436,7 @@
</span><span class="cx"> command = "sudo port -t clean dports/python/py-" + \
</span><span class="cx"> name + " subport=py" + portv + "-" + name
</span><span class="cx"> command = command.split()
</span><del>- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
</del><ins>+ subprocess.check_call(command, stderr=subprocess.STDOUT)
</ins><span class="cx"> return True
</span><span class="cx"> except:
</span><span class="cx"> return False
</span><span class="lines">@@ -499,7 +497,7 @@
</span><span class="cx"> file.write("{0} \\\n".format(sum_line))
</span><span class="cx"> else:
</span><span class="cx"> file.write('description None\n\n')
</span><del>- description = dict['description']
</del><ins>+# description = dict['description']
</ins><span class="cx"> # if description:
</span><span class="cx"> # description = description.encode('utf-8')
</span><span class="cx"> # description = filter(lambda x: x in string.printable, description)
</span><span class="lines">@@ -541,8 +539,8 @@
</span><span class="cx"> # sys.exit(1)
</span><span class="cx">
</span><span class="cx"> try:
</span><del>-# print dict2
-# print dict2['url']
</del><ins>+ # print dict2
+ # print dict2['url']
</ins><span class="cx"> for item in dict2:
</span><span class="cx"> if item['python_version'] == 'source':
</span><span class="cx"> master_var = item['url']
</span><span class="lines">@@ -598,9 +596,9 @@
</span><span class="cx"> 'port:py${python.version}-setuptools\n')
</span><span class="cx"> deps = dependencies(dict['name'], dict['version'], True)
</span><span class="cx"> if deps:
</span><del>- for i,dep in enumerate(deps):
</del><ins>+ for i, dep in enumerate(deps):
</ins><span class="cx"> dep = dep.split('>')[0].split('=')[0]
</span><del>- dep = dep.replace('[','').replace(']','')
</del><ins>+ dep = dep.replace('[', '').replace(']', '')
</ins><span class="cx"> deps[i] = dep
</span><span class="cx"> # print deps
</span><span class="cx"> for dep in deps:
</span><span class="lines">@@ -731,13 +729,11 @@
</span><span class="cx"> list_all()
</span><span class="cx"> return
</span><span class="cx">
</span><del>-
</del><span class="cx"> if options.packages_search:
</span><span class="cx"> for pkg_name in options.packages_search:
</span><span class="cx"> search(pkg_name)
</span><span class="cx"> return
</span><span class="cx">
</span><del>-
</del><span class="cx"> if options.packages_data:
</span><span class="cx"> pkg_name = options.packages_data[0]
</span><span class="cx"> if len(options.packages_data) > 1:
</span><span class="lines">@@ -751,7 +747,6 @@
</span><span class="cx"> print "No release found\n"
</span><span class="cx"> return
</span><span class="cx">
</span><del>-
</del><span class="cx"> if options.package_fetch:
</span><span class="cx"> pkg_name = options.package_fetch[0]
</span><span class="cx"> if len(options.package_fetch) > 1:
</span><span class="lines">@@ -766,7 +761,6 @@
</span><span class="cx"> print "No release found\n"
</span><span class="cx"> return
</span><span class="cx">
</span><del>-
</del><span class="cx"> if options.package_portfile:
</span><span class="cx"> pkg_name = options.package_portfile[0]
</span><span class="cx"> if len(options.package_portfile) > 1:
</span><span class="lines">@@ -781,7 +775,6 @@
</span><span class="cx"> print "No release found\n"
</span><span class="cx"> return
</span><span class="cx">
</span><del>-
</del><span class="cx"> if options.package_test:
</span><span class="cx"> if len(options.package_test) > 0:
</span><span class="cx"> pkg_name = options.package_test[0]
</span></span></pre>
</div>
</div>
</body>
</html>