[125591] users/g5pw/pypi2port/pypi2port.py
g5pw at macports.org
g5pw at macports.org
Mon Sep 22 02:54:09 PDT 2014
Revision: 125591
https://trac.macports.org/changeset/125591
Author: g5pw at macports.org
Date: 2014-09-22 02:54:09 -0700 (Mon, 22 Sep 2014)
Log Message:
-----------
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"
Modified Paths:
--------------
users/g5pw/pypi2port/pypi2port.py
Modified: users/g5pw/pypi2port/pypi2port.py
===================================================================
--- 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)
@@ -14,7 +14,7 @@
import urllib2
import hashlib
import zipfile
-from progressbar import *
+import progressbar as pb
try:
import xmlrpclib
except ImportError:
@@ -26,8 +26,6 @@
import difflib
import subprocess
import requests
-import shlex
-import getpass
client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
@@ -92,10 +90,10 @@
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
- widgets = ['Fetching: ', Percentage(), ' ',
- Bar(marker=RotatingMarker(), left='[', right=']'),
- ' ', ETA(), ' ', FileTransferSpeed()]
- pbar = ProgressBar(widgets=widgets, maxval=int(file_size))
+ widgets = ['Fetching: ', pb.Percentage(), ' ',
+ pb.Bar(marker=pb.RotatingMarker(), left='[', right=']'),
+ ' ', pb.ETA(), ' ', pb.FileTransferSpeed()]
+ pbar = pb.ProgressBar(widgets=widgets, maxval=int(file_size))
pbar.start()
file_size_dl = 0
@@ -137,9 +135,9 @@
def fetch_url(pkg_name, pkg_version, checksum=False, deps=False):
values = client.release_urls(pkg_name, pkg_version)
if checksum:
-# print values
+ # print values
for value in values:
- if value['filename'].split('.')[-1] == 'gz' or value['filename'].split('.')[-1] == 'zip':
+ if value['filename'].split('.')[-1] in ['gz', 'zip']:
return fetch(pkg_name, value)
else:
for value in values:
@@ -156,7 +154,7 @@
return
values = client.release_urls(pkg_name, pkg_version)
for value in values:
- if not(value['filename'].split('.')[-1] == 'gz' or value['filename'].split('.')[-1] == 'zip'):
+ if value['filename'].split('.')[-1] in ['gz', 'zip']:
fetch(pkg_name, value)
try:
with open('./sources/python/py-'
@@ -170,7 +168,7 @@
ignore_errors=True)
items = os.listdir('./sources/python/py-' + pkg_name)
for item in items[:]:
- if not(item.split('.')[-1] == 'gz' or item.split('.')[-1] == 'zip'):
+ if item.split('.')[-1] not in ['gz', 'zip']:
os.remove('./sources/python/py-'
+ pkg_name + '/' + item)
items.remove(item)
@@ -186,7 +184,7 @@
ignore_errors=True)
items = os.listdir('./sources/python/py-'+pkg_name)
for item in items[:]:
- if not(item.split('.')[-1] == 'gz' or item.split('.')[-1] == 'zip'):
+ if item.split('.')[-1] not in ['gz', 'zip']:
os.remove('./sources/python/py-'+pkg_name+'/'+item)
items.remove(item)
if not items:
@@ -225,7 +223,7 @@
existing_portfile = \
subprocess.check_output(command, stderr=subprocess.STDOUT).strip()
return existing_portfile
- except Exception, e:
+ except Exception:
return False
@@ -259,7 +257,7 @@
try:
if flag:
os.rmdir(dir)
- except OSError as ex:
+ except OSError:
pass
return checksums
except:
@@ -275,7 +273,7 @@
url = client.release_urls(name, version)[0]['url']
r = requests.get(url, verify=False)
if not r.status_code == 200:
- raise Error('No distfile')
+ raise Exception('No distfile')
except:
print "No distfile found"
print "Please set a DISTFILE env var before generating the portfile"
@@ -340,7 +338,7 @@
command = "sudo port -t fetch dports/python/py-" + \
name + " subport=py" + portv + "-" + name
command = command.split()
- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
+ subprocess.check_call(command, stderr=subprocess.STDOUT)
return True
except:
return False
@@ -354,7 +352,7 @@
command = "sudo port -t checksum dports/python/py-" + \
name + " subport=py" + portv + "-" + name
command = command.split()
- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
+ subprocess.check_call(command, stderr=subprocess.STDOUT)
return True
except:
return False
@@ -368,7 +366,7 @@
command = "sudo port -t extract dports/python/py-" + \
name + " subport=py" + portv + "-" + name
command = command.split()
- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
+ subprocess.check_call(command, stderr=subprocess.STDOUT)
return True
except:
return False
@@ -382,7 +380,7 @@
command = "sudo port -t patch dports/python/py-" + \
name + " subport=py" + portv + "-" + name
command = command.split()
- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
+ subprocess.check_call(command, stderr=subprocess.STDOUT)
return True
except:
return False
@@ -396,7 +394,7 @@
command = "sudo port -t configure dports/python/py-" + \
name + " subport=py" + portv + "-" + name
command = command.split()
- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
+ subprocess.check_call(command, stderr=subprocess.STDOUT)
return True
except:
return False
@@ -410,7 +408,7 @@
command = "sudo port -t build dports/python/py-" + \
name + " subport=py" + portv + "-" + name
command = command.split()
- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
+ subprocess.check_call(command, stderr=subprocess.STDOUT)
return True
except:
return False
@@ -424,7 +422,7 @@
command = "sudo port -t destroot dports/python/py-" + \
name + " subport=py" + portv + "-" + name
command = command.split()
- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
+ subprocess.check_call(command, stderr=subprocess.STDOUT)
return True
except:
return False
@@ -438,7 +436,7 @@
command = "sudo port -t clean dports/python/py-" + \
name + " subport=py" + portv + "-" + name
command = command.split()
- phase_output = subprocess.check_call(command, stderr=subprocess.STDOUT)
+ subprocess.check_call(command, stderr=subprocess.STDOUT)
return True
except:
return False
@@ -499,7 +497,7 @@
file.write("{0} \\\n".format(sum_line))
else:
file.write('description None\n\n')
- description = dict['description']
+# description = dict['description']
# if description:
# description = description.encode('utf-8')
# description = filter(lambda x: x in string.printable, description)
@@ -541,8 +539,8 @@
# sys.exit(1)
try:
-# print dict2
-# print dict2['url']
+ # print dict2
+ # print dict2['url']
for item in dict2:
if item['python_version'] == 'source':
master_var = item['url']
@@ -598,9 +596,9 @@
'port:py${python.version}-setuptools\n')
deps = dependencies(dict['name'], dict['version'], True)
if deps:
- for i,dep in enumerate(deps):
+ for i, dep in enumerate(deps):
dep = dep.split('>')[0].split('=')[0]
- dep = dep.replace('[','').replace(']','')
+ dep = dep.replace('[', '').replace(']', '')
deps[i] = dep
# print deps
for dep in deps:
@@ -731,13 +729,11 @@
list_all()
return
-
if options.packages_search:
for pkg_name in options.packages_search:
search(pkg_name)
return
-
if options.packages_data:
pkg_name = options.packages_data[0]
if len(options.packages_data) > 1:
@@ -751,7 +747,6 @@
print "No release found\n"
return
-
if options.package_fetch:
pkg_name = options.package_fetch[0]
if len(options.package_fetch) > 1:
@@ -766,7 +761,6 @@
print "No release found\n"
return
-
if options.package_portfile:
pkg_name = options.package_portfile[0]
if len(options.package_portfile) > 1:
@@ -781,7 +775,6 @@
print "No release found\n"
return
-
if options.package_test:
if len(options.package_test) > 0:
pkg_name = options.package_test[0]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140922/37a56925/attachment-0001.html>
More information about the macports-changes
mailing list