[133045] contrib/pypi2port/pypi2port
mojca at macports.org
mojca at macports.org
Wed Feb 18 15:06:14 PST 2015
Revision: 133045
https://trac.macports.org/changeset/133045
Author: mojca at macports.org
Date: 2015-02-18 15:06:14 -0800 (Wed, 18 Feb 2015)
Log Message:
-----------
pypi2port: use parenthesis for print arguments
Modified Paths:
--------------
contrib/pypi2port/pypi2port
Modified: contrib/pypi2port/pypi2port
===================================================================
--- contrib/pypi2port/pypi2port 2015-02-18 21:16:02 UTC (rev 133044)
+++ contrib/pypi2port/pypi2port 2015-02-18 23:06:14 UTC (rev 133045)
@@ -38,7 +38,7 @@
def list_all():
list_packages = client.list_packages()
for package in list_packages:
- print package
+ print (package)
""" Searches for a particular package by the name classifier """
@@ -48,7 +48,7 @@
values = client.search({'name': pkg_name})
for value in values:
for key in value.keys():
- print key, '-->', value[key]
+ print (key, '-->', value[key])
""" Fetches the release data for a paticular package based on
@@ -60,10 +60,10 @@
values = client.release_data(pkg_name, pkg_version)
if values:
for key in values.keys():
- print key, '-->', values[key]
+ print (key, '-->', values[key])
else:
- print "No such package found."
- print "Please specify the exact package name."
+ print ("No such package found.")
+ print ("Please specify the exact package name.")
return
return
@@ -72,7 +72,7 @@
def fetch(pkg_name, dict):
- print "Fetching distfiles..."
+ print ("Fetching distfiles...")
checksum_md5 = dict['md5_digest']
parent_dir = './sources'
home_dir = parent_dir + '/' + 'python'
@@ -113,7 +113,7 @@
checksum_md5_calc = hashlib.md5(open(file_name).read()).hexdigest()
if str(checksum_md5) == str(checksum_md5_calc):
- print 'Successfully fetched'
+ print ('Successfully fetched')
ext = file_name.split('.')[-1]
if ext == 'egg':
zip = zipfile.ZipFile(file_name)
@@ -122,11 +122,11 @@
zip.extract(name, src_dir)
return file_name
else:
- print 'Aborting due to inconsistency on checksums\n'
+ print ('Aborting due to inconsistency on checksums\n')
try:
os.remove(file_name)
- except OSError, e:
- print "Error: %s - %s." % (e.filename, e.strerror)
+ except (OSError, e):
+ print ("Error: {:s} - {:s}.".format(e.filename, e.strerror))
return False
@@ -225,7 +225,7 @@
existing_portfile = \
subprocess.check_output(command, stderr=subprocess.STDOUT).strip()
return existing_portfile
- except Exception, e:
+ except (Exception, e):
return False
@@ -235,12 +235,12 @@
def checksums(pkg_name, pkg_version):
flag = False
- print "Attempting to fetch distfiles..."
+ print ("Attempting to fetch distfiles...")
file_name = fetch_url(pkg_name, pkg_version, True)
if file_name:
checksums = []
try:
- print "Generating checksums..."
+ print ("Generating checksums...")
command = "openssl rmd160 "+file_name
command = command.split()
rmd160 = subprocess.check_output(command, stderr=subprocess.STDOUT)
@@ -263,7 +263,7 @@
pass
return checksums
except:
- print "Error\n"
+ print ("Error\n")
return
@@ -277,8 +277,8 @@
if not r.status_code == 200:
raise Error('No distfile')
except:
- print "No distfile found"
- print "Please set a DISTFILE env var before generating the portfile"
+ print ("No distfile found")
+ print ("Please set a DISTFILE env var before generating the portfile")
sys.exit(0)
@@ -316,14 +316,14 @@
for phase in [port_fetch, port_checksum, port_extract, port_configure,
port_build, port_destroot, port_clean]:
- print phase.__name__
+ print (phase.__name__)
phase_output = phase(name, portv)
if phase_output:
- print phase.__name__ + " - SUCCESS"
+ print (phase.__name__ + " - SUCCESS")
else:
- print phase.__name__ + " FAILED"
+ print (phase.__name__ + " FAILED")
port_clean(name, portv)
- print "Exiting"
+ print ("Exiting")
sys.exit(1)
euid = os.geteuid()
@@ -450,7 +450,7 @@
def create_portfile(dict, file_name, dict2):
search_distfile(dict['name'], dict['version'])
- print "Creating Portfile for pypi package " + dict['name'] + "..."
+ print ("Creating Portfile for pypi package " + dict['name'] + "...")
with open(file_name, 'w') as file:
file.write('# -*- coding: utf-8; mode: tcl; tab-width: 4; ')
file.write('indent-tabs-mode: nil; c-basic-offset: 4 ')
@@ -475,8 +475,8 @@
file.write('maintainers {0}\n\n'.format(
os.getenv('maintainer', 'nomaintainer')))
else:
- print "No maintainers found..."
- print "Looking for maintainers in environment variables..."
+ print ("No maintainers found...")
+ print ("Looking for maintainers in environment variables...")
file.write('maintainers {0}\n\n'.format(
os.getenv('maintainer', 'nomaintainer')))
@@ -526,8 +526,8 @@
if home_page and not home_page == 'UNKNOWN':
file.write('homepage {0}\n'.format(home_page))
else:
- print "No homepage found..."
- print "Looking for homepage in environment variables..."
+ print ("No homepage found...")
+ print ("Looking for homepage in environment variables...")
file.write('homepage {0}\n'.format(
os.getenv('home_page', '')))
@@ -560,8 +560,8 @@
master_site = dict['release_url']
# print master_site
else:
- print "No master site found..."
- print "Looking for master site in environment variables..."
+ print ("No master site found...")
+ print ("Looking for master site in environment variables...")
master_site = os.getenv('master_site', '')
if master_site:
file.write('master_sites {0}\n'.format(master_site))
@@ -576,7 +576,7 @@
file.write('distname {0}-{1}\n\n'.format(
dict['name'], dict['version']))
- print "Attempting to generate checksums for " + dict['name'] + "..."
+ print ("Attempting to generate checksums for " + dict['name'] + "...")
checksums_values = checksums(dict['name'], dict['version'])
if checksums_values:
file.write('checksums rmd160 {0} \\\n'.format(
@@ -591,7 +591,7 @@
else:
file.write('python.versions 25 26 27 32 33 34\n\n')
- print "Finding dependencies..."
+ print ("Finding dependencies...")
file.write('if {${name} ne ${subport}} {\n')
file.write(' depends_build-append \\\n')
file.write(' ' +
@@ -639,22 +639,22 @@
file.write('}\n')
else:
file.write('}\n')
- print "Searching for existent port..."
+ print ("Searching for existent port...")
port_exists = search_port(dict['name'])
if port_exists:
- print "Creating diff..."
+ print ("Creating diff...")
old_file = port_exists
new_file = './dports/python/py-'+dict['name']+'/Portfile'
diff_file = './dports/python/py-'+dict['name']+'/patch.Portfile.diff'
create_diff(old_file, new_file, diff_file)
- print str(os.path.abspath(diff_file))+"\n"
+ print (str(os.path.abspath(diff_file))+"\n")
# with open(diff_file) as diff:
# print diff.read()
- print "\nIf you want to open a new ticket. Please visit"
- print "https://trac.macports.org/auth/login/?next=/newticket"
- print "to open a new ticket after logging in with your credentials."
+ print ("\nIf you want to open a new ticket. Please visit")
+ print ("https://trac.macports.org/auth/login/?next=/newticket")
+ print ("to open a new ticket after logging in with your credentials.")
else:
- print "No port found."
+ print ("No port found.")
""" Creates the directories and other commands necessary
@@ -678,22 +678,22 @@
if not os.path.exists(home_dir):
os.makedirs(home_dir)
- print "Attempting to fetch data from pypi..."
+ print ("Attempting to fetch data from pypi...")
dict = client.release_data(pkg_name, pkg_version)
dict2 = client.release_urls(pkg_name, pkg_version)
if dict and dict2:
- print "Data fetched successfully."
+ print ("Data fetched successfully.")
elif dict:
- print "Release Data fetched successfully."
+ print ("Release Data fetched successfully.")
elif dict2:
- print "Release url fetched successfully."
+ print ("Release url fetched successfully.")
else:
- print "No data found."
+ print ("No data found.")
file_name = os.path.join(home_dir, "Portfile")
create_portfile(dict, file_name, dict2)
- print "SUCCESS\n"
+ print ("SUCCESS\n")
""" Main function - Argument Parser """
@@ -748,7 +748,7 @@
pkg_version = client.package_releases(pkg_name)[0]
release_data(pkg_name, pkg_version)
else:
- print "No release found\n"
+ print ("No release found\n")
return
@@ -763,7 +763,7 @@
pkg_version = releases[0]
fetch_url(pkg_name, pkg_version)
else:
- print "No release found\n"
+ print ("No release found\n")
return
@@ -778,7 +778,7 @@
pkg_version = vers[0]
print_portfile(pkg_name, pkg_version)
else:
- print "No release found\n"
+ print ("No release found\n")
return
@@ -787,7 +787,7 @@
pkg_name = options.package_test[0]
port_testing(pkg_name)
else:
- print "No package name specified\n"
+ print ("No package name specified\n")
return
parser.print_help()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150218/035a9785/attachment.html>
More information about the macports-changes
mailing list