<!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>[125795] users/gaurav/pypi2port</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/125795">125795</a></dd>
<dt>Author</dt> <dd>gaurav@macports.org</dd>
<dt>Date</dt> <dd>2014-09-26 08:27:58 -0700 (Fri, 26 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Removed Tcl magic and used usr/bin/env only</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#usersgauravpypi2portpypi2port">users/gaurav/pypi2port/pypi2port</a></li>
<li><a href="#usersgauravpypi2portpypi2portpy">users/gaurav/pypi2port/pypi2port.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="usersgauravpypi2portpypi2port"></a>
<div class="modfile"><h4>Modified: users/gaurav/pypi2port/pypi2port (125794 => 125795)</h4>
<pre class="diff"><span>
<span class="info">--- users/gaurav/pypi2port/pypi2port        2014-09-26 15:23:13 UTC (rev 125794)
+++ users/gaurav/pypi2port/pypi2port        2014-09-26 15:27:58 UTC (rev 125795)
</span><span class="lines">@@ -1,24 +1,18 @@
</span><del>-#! /bin/sh
-&quot;&quot;&quot;:&quot;
-exec python $0 ${1+&quot;$@&quot;}
-&quot;&quot;&quot;
-__doc__ = &quot;&quot;&quot;...Script for pypi2port module written for &quot;The Macports Project&quot;
-             participating in Google Summer of Code 2014...&quot;&quot;&quot;
-
</del><ins>+#!/usr/bin/env python
</ins><span class="cx"> # -*- coding: utf-8 -*-
</span><del>-# !/usr/bin/env python
</del><span class="cx"> 
</span><span class="cx"> import argparse
</span><span class="cx"> import sys
</span><span class="cx"> import os
</span><del>-import urllib2
</del><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><ins>+    from urllib2 import urlopen
</ins><span class="cx"> except ImportError:
</span><span class="cx">     import xmlrpc.client as xmlrpclib
</span><ins>+    from urllib.request import urlopen
</ins><span class="cx"> import textwrap
</span><span class="cx"> import string
</span><span class="cx"> import shutil
</span><span class="lines">@@ -26,53 +20,43 @@
</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="cx"> 
</span><del>-&quot;&quot;&quot; Lists all packages available in pypi database &quot;&quot;&quot;
-
-
</del><span class="cx"> def list_all():
</span><ins>+    &quot;&quot;&quot; Lists all packages available in pypi database &quot;&quot;&quot;
</ins><span class="cx">     list_packages = client.list_packages()
</span><span class="cx">     for package in list_packages:
</span><del>-        print package
</del><ins>+        print(package)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Searches for a particular package by the name classifier &quot;&quot;&quot;
-
-
</del><span class="cx"> def search(pkg_name):
</span><ins>+    &quot;&quot;&quot; Searches for a particular package by the name classifier &quot;&quot;&quot;
</ins><span class="cx">     values = client.search({'name': pkg_name})
</span><span class="cx">     for value in values:
</span><span class="cx">         for key in value.keys():
</span><span class="cx">             print key, '--&gt;', value[key]
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Fetches the release data for a paticular package based on
-    the package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def release_data(pkg_name, pkg_version):
</span><ins>+    &quot;&quot;&quot; Fetches the release data for a paticular package based on
+    the package_name and package_version &quot;&quot;&quot;
</ins><span class="cx">     if pkg_version:
</span><span class="cx">         values = client.release_data(pkg_name, pkg_version)
</span><span class="cx">         if values:
</span><span class="cx">             for key in values.keys():
</span><span class="cx">                 print key, '--&gt;', values[key]
</span><span class="cx">         else:
</span><del>-            print &quot;No such package found.&quot;
-            print &quot;Please specify the exact package name.&quot;
</del><ins>+            print(&quot;No such package found.&quot;)
+            print(&quot;Please specify the exact package name.&quot;)
</ins><span class="cx">         return
</span><span class="cx">     return
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Fetches the distfile for a particular package name and release_url &quot;&quot;&quot;
-
-
</del><span class="cx"> def fetch(pkg_name, dict):
</span><del>-    print &quot;Fetching distfiles...&quot;
</del><ins>+    &quot;&quot;&quot; Fetches the distfile for a particular package name and release_url &quot;&quot;&quot;
+    print(&quot;Fetching distfiles...&quot;)
</ins><span class="cx">     checksum_md5 = dict['md5_digest']
</span><span class="cx">     parent_dir = './sources'
</span><span class="cx">     home_dir = parent_dir + '/' + 'python'
</span><span class="lines">@@ -87,15 +71,15 @@
</span><span class="cx">     url = dict['url']
</span><span class="cx">     file_name = src_dir + '/' + dict['filename']
</span><span class="cx"> 
</span><del>-    u = urllib2.urlopen(url)
</del><ins>+    u = urlopen(url)
</ins><span class="cx">     with open(file_name, 'wb') as f:
</span><span class="cx">         meta = u.info()
</span><span class="cx">         file_size = int(meta.getheaders(&quot;Content-Length&quot;)[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">@@ -113,7 +97,7 @@
</span><span class="cx"> 
</span><span class="cx">     checksum_md5_calc = hashlib.md5(open(file_name).read()).hexdigest()
</span><span class="cx">     if str(checksum_md5) == str(checksum_md5_calc):
</span><del>-        print 'Successfully fetched'
</del><ins>+        print('Successfully fetched')
</ins><span class="cx">         ext = file_name.split('.')[-1]
</span><span class="cx">         if ext == 'egg':
</span><span class="cx">             zip = zipfile.ZipFile(file_name)
</span><span class="lines">@@ -122,41 +106,37 @@
</span><span class="cx">                     zip.extract(name, src_dir)
</span><span class="cx">         return file_name
</span><span class="cx">     else:
</span><del>-        print 'Aborting due to inconsistency on checksums\n'
</del><ins>+        print('Aborting due to inconsistency on checksums\n')
</ins><span class="cx">         try:
</span><span class="cx">             os.remove(file_name)
</span><del>-        except OSError, e:
-            print &quot;Error: %s - %s.&quot; % (e.filename, e.strerror)
</del><ins>+        except OSError as e:
+            print(&quot;Error: %s - %s.&quot; % (e.filename, e.strerror))
</ins><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Checks for the checksums and dependecies for a particular python package
-    on the basis of package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def fetch_url(pkg_name, pkg_version, checksum=False, deps=False):
</span><ins>+    &quot;&quot;&quot; Checks for the checksums and dependecies for a particular python package
+    on the basis of package_name and package_version &quot;&quot;&quot;
</ins><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="cx">             return fetch(pkg_name, value)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Finds dependencies for a particular package on the basis of
-    package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def dependencies(pkg_name, pkg_version, deps=False):
</span><ins>+    &quot;&quot;&quot; Finds dependencies for a particular package on the basis of
+    package_name and package_version &quot;&quot;&quot;
</ins><span class="cx">     flag = False
</span><span class="cx">     if not deps:
</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 +150,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 +166,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">@@ -196,10 +176,8 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Creates a diff file for an existent port &quot;&quot;&quot;
-
-
</del><span class="cx"> def create_diff(old_file, new_file, diff_file):
</span><ins>+    &quot;&quot;&quot; Creates a diff file for an existent port &quot;&quot;&quot;
</ins><span class="cx">     with open(old_file) as f:
</span><span class="cx">         a = f.readlines()
</span><span class="cx"> #    a = open(old_file).readlines()
</span><span class="lines">@@ -208,39 +186,31 @@
</span><span class="cx"> #    b = open(new_file).readlines()
</span><span class="cx">     diff_string = difflib.unified_diff(a, b, &quot;Portfile.orig&quot;, &quot;Portfile&quot;)
</span><span class="cx">     with open(diff_file, 'w') as d:
</span><del>-        try:
-            while 1:
-                d.write(diff_string.next())
-        except:
-            pass
</del><ins>+        d.writelines(diff_string)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Searches for an existent port by its name &quot;&quot;&quot;
-
-
</del><span class="cx"> def search_port(name):
</span><ins>+    &quot;&quot;&quot; Searches for an existent port by its name &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;port file name:^py-&quot; + name + &quot;$&quot;
</span><span class="cx">         command = command.split()
</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><del>-&quot;&quot;&quot; Generates checksums for a package on the basis of the distfile fetched by
-    its package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def checksums(pkg_name, pkg_version):
</span><ins>+    &quot;&quot;&quot; Generates checksums for a package on the basis of the distfile fetched by
+    its package_name and package_version &quot;&quot;&quot;
</ins><span class="cx">     flag = False
</span><del>-    print &quot;Attempting to fetch distfiles...&quot;
</del><ins>+    print(&quot;Attempting to fetch distfiles...&quot;)
</ins><span class="cx">     file_name = fetch_url(pkg_name, pkg_version, True)
</span><span class="cx">     if file_name:
</span><span class="cx">         checksums = []
</span><span class="cx">         try:
</span><del>-            print &quot;Generating checksums...&quot;
</del><ins>+            print(&quot;Generating checksums...&quot;)
</ins><span class="cx">             command = &quot;openssl rmd160 &quot;+file_name
</span><span class="cx">             command = command.split()
</span><span class="cx">             rmd160 = subprocess.check_output(command, stderr=subprocess.STDOUT)
</span><span class="lines">@@ -259,34 +229,30 @@
</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><del>-            print &quot;Error\n&quot;
</del><ins>+            print(&quot;Error\n&quot;)
</ins><span class="cx">             return
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Searches if the distfile listed is present or not &quot;&quot;&quot;
-
-
</del><span class="cx"> def search_distfile(name, version):
</span><ins>+    &quot;&quot;&quot; Searches if the distfile listed is present or not &quot;&quot;&quot;
</ins><span class="cx">     try:
</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><del>-        print &quot;No distfile found&quot;
-        print &quot;Please set a DISTFILE env var before generating the portfile&quot;
</del><ins>+        print(&quot;No distfile found&quot;)
+        print(&quot;Please set a DISTFILE env var before generating the portfile&quot;)
</ins><span class="cx">         sys.exit(0)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Maps the license passed to the already present list of
-    licences available in Macports &quot;&quot;&quot;
-
-
</del><span class="cx"> def search_license(license):
</span><ins>+    &quot;&quot;&quot; Maps the license passed to the already present list of
+    licences available in Macports &quot;&quot;&quot;
</ins><span class="cx">     license = license.lower()
</span><span class="cx">     patterns = ['.*mit.*', '.*apache.*2', '.*apache.*', '.*bsd.*', '.*agpl.*3',
</span><span class="cx">                 '.*agpl.*2', '.*agpl.*', '.*affero.*3', '.*affero.*2',
</span><span class="lines">@@ -305,10 +271,8 @@
</span><span class="cx">             return licenses[i]
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Port Testing function for various phase implementations &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_testing(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Port Testing function for various phase implementations &quot;&quot;&quot;
</ins><span class="cx">     euid = os.geteuid()
</span><span class="cx">     if euid:
</span><span class="cx">         args = ['sudo', sys.executable] + sys.argv + [os.environ]
</span><span class="lines">@@ -316,14 +280,14 @@
</span><span class="cx"> 
</span><span class="cx">     for phase in [port_fetch, port_checksum, port_extract, port_configure,
</span><span class="cx">                   port_build, port_destroot, port_clean]:
</span><del>-        print phase.__name__
</del><ins>+        print(phase.__name__)
</ins><span class="cx">         phase_output = phase(name, portv)
</span><span class="cx">         if phase_output:
</span><del>-            print phase.__name__ + &quot; - SUCCESS&quot;
</del><ins>+            print(phase.__name__ + &quot; - SUCCESS&quot;)
</ins><span class="cx">         else:
</span><del>-            print phase.__name__ + &quot; FAILED&quot;
</del><ins>+            print(phase.__name__ + &quot; FAILED&quot;)
</ins><span class="cx">             port_clean(name, portv)
</span><del>-            print &quot;Exiting&quot;
</del><ins>+            print(&quot;Exiting&quot;)
</ins><span class="cx">             sys.exit(1)
</span><span class="cx"> 
</span><span class="cx">         euid = os.geteuid()
</span><span class="lines">@@ -332,125 +296,107 @@
</span><span class="cx">             os.execlpe('sudo', *args)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Fetch phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_fetch(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Fetch phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t fetch dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_checksum(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t checksum dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_extract(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t extract dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Patch phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_patch(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Patch phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t patch dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Configure phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_configure(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Configure phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t configure dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Build phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_build(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Build phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t build dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Destroot phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_destroot(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Destroot phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t destroot dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Clean phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_clean(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Clean phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t clean dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Creates a portfile on the basis of the release_data and release_url fetched
-    on the basis of package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def create_portfile(dict, file_name, dict2):
</span><ins>+    &quot;&quot;&quot; Creates a portfile on the basis of the release_data and release_url fetched
+    on the basis of package_name and package_version &quot;&quot;&quot;
</ins><span class="cx">     search_distfile(dict['name'], dict['version'])
</span><del>-    print &quot;Creating Portfile for pypi package &quot; + dict['name'] + &quot;...&quot;
</del><ins>+    print(&quot;Creating Portfile for pypi package &quot; + dict['name'] + &quot;...&quot;)
</ins><span class="cx">     with open(file_name, 'w') as file:
</span><span class="cx">         file.write('# -*- coding: utf-8; mode: tcl; tab-width: 4; ')
</span><span class="cx">         file.write('indent-tabs-mode: nil; c-basic-offset: 4 ')
</span><span class="lines">@@ -475,8 +421,8 @@
</span><span class="cx">                 file.write('maintainers         {0}\n\n'.format(
</span><span class="cx">                            os.getenv('maintainer', 'nomaintainer')))
</span><span class="cx">         else:
</span><del>-            print &quot;No maintainers found...&quot;
-            print &quot;Looking for maintainers in environment variables...&quot;
</del><ins>+            print(&quot;No maintainers found...&quot;)
+            print(&quot;Looking for maintainers in environment variables...&quot;)
</ins><span class="cx">             file.write('maintainers         {0}\n\n'.format(
</span><span class="cx">                        os.getenv('maintainer', 'nomaintainer')))
</span><span class="cx"> 
</span><span class="lines">@@ -499,7 +445,7 @@
</span><span class="cx">                         file.write(&quot;{0} \\\n&quot;.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">@@ -526,8 +472,8 @@
</span><span class="cx">         if home_page and not home_page == 'UNKNOWN':
</span><span class="cx">             file.write('homepage            {0}\n'.format(home_page))
</span><span class="cx">         else:
</span><del>-            print &quot;No homepage found...&quot;
-            print &quot;Looking for homepage in environment variables...&quot;
</del><ins>+            print(&quot;No homepage found...&quot;)
+            print(&quot;Looking for homepage in environment variables...&quot;)
</ins><span class="cx">             file.write('homepage            {0}\n'.format(
</span><span class="cx">                        os.getenv('home_page', '')))
</span><span class="cx"> 
</span><span class="lines">@@ -541,8 +487,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">@@ -560,8 +506,8 @@
</span><span class="cx">                 master_site = dict['release_url']
</span><span class="cx"> #                print master_site
</span><span class="cx">             else:
</span><del>-                print &quot;No master site found...&quot;
-                print &quot;Looking for master site in environment variables...&quot;
</del><ins>+                print(&quot;No master site found...&quot;)
+                print(&quot;Looking for master site in environment variables...&quot;)
</ins><span class="cx">                 master_site = os.getenv('master_site', '')
</span><span class="cx">         if master_site:
</span><span class="cx">             file.write('master_sites        {0}\n'.format(master_site))
</span><span class="lines">@@ -576,7 +522,7 @@
</span><span class="cx">         file.write('distname            {0}-{1}\n\n'.format(
</span><span class="cx">                    dict['name'], dict['version']))
</span><span class="cx"> 
</span><del>-        print &quot;Attempting to generate checksums for &quot; + dict['name'] + &quot;...&quot;
</del><ins>+        print(&quot;Attempting to generate checksums for &quot; + dict['name'] + &quot;...&quot;)
</ins><span class="cx">         checksums_values = checksums(dict['name'], dict['version'])
</span><span class="cx">         if checksums_values:
</span><span class="cx">             file.write('checksums           rmd160  {0} \\\n'.format(
</span><span class="lines">@@ -591,16 +537,16 @@
</span><span class="cx">         else:
</span><span class="cx">             file.write('python.versions     25 26 27 32 33 34\n\n')
</span><span class="cx"> 
</span><del>-        print &quot;Finding dependencies...&quot;
</del><ins>+        print(&quot;Finding dependencies...&quot;)
</ins><span class="cx">         file.write('if {${name} ne ${subport}} {\n')
</span><span class="cx">         file.write('    depends_build-append \\\n')
</span><span class="cx">         file.write('                        ' +
</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('&gt;')[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">@@ -639,29 +585,27 @@
</span><span class="cx">             file.write('}\n')
</span><span class="cx">         else:
</span><span class="cx">             file.write('}\n')
</span><del>-    print &quot;Searching for existent port...&quot;
</del><ins>+    print(&quot;Searching for existent port...&quot;)
</ins><span class="cx">     port_exists = search_port(dict['name'])
</span><span class="cx">     if port_exists:
</span><del>-        print &quot;Creating diff...&quot;
</del><ins>+        print(&quot;Creating diff...&quot;)
</ins><span class="cx">         old_file = port_exists
</span><span class="cx">         new_file = './dports/python/py-'+dict['name']+'/Portfile'
</span><span class="cx">         diff_file = './dports/python/py-'+dict['name']+'/patch.Portfile.diff'
</span><span class="cx">         create_diff(old_file, new_file, diff_file)
</span><del>-        print str(os.path.abspath(diff_file))+&quot;\n&quot;
</del><ins>+        print(str(os.path.abspath(diff_file))+&quot;\n&quot;)
</ins><span class="cx"> #        with open(diff_file) as diff:
</span><span class="cx"> #            print diff.read()
</span><del>-        print &quot;\nIf you want to open a new ticket. Please visit&quot;
-        print &quot;https://trac.macports.org/auth/login/?next=/newticket&quot;
-        print &quot;to open a new ticket after logging in with your credentials.&quot;
</del><ins>+        print(&quot;\nIf you want to open a new ticket. Please visit&quot;)
+        print(&quot;https://trac.macports.org/auth/login/?next=/newticket&quot;)
+        print(&quot;to open a new ticket after logging in with your credentials.&quot;)
</ins><span class="cx">     else:
</span><del>-        print &quot;No port found.&quot;
</del><ins>+        print(&quot;No port found.&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Creates the directories and other commands necessary
-    for a development environment &quot;&quot;&quot;
-
-
</del><span class="cx"> def print_portfile(pkg_name, pkg_version=None):
</span><ins>+    &quot;&quot;&quot; Creates the directories and other commands necessary
+    for a development environment &quot;&quot;&quot;
</ins><span class="cx">     root_dir = os.path.abspath(&quot;./dports&quot;)
</span><span class="cx">     port_dir = os.path.join(root_dir, 'python')
</span><span class="cx">     home_dir = os.path.join(port_dir, 'py-'+pkg_name)
</span><span class="lines">@@ -678,28 +622,26 @@
</span><span class="cx">     if not os.path.exists(home_dir):
</span><span class="cx">         os.makedirs(home_dir)
</span><span class="cx"> 
</span><del>-    print &quot;Attempting to fetch data from pypi...&quot;
</del><ins>+    print(&quot;Attempting to fetch data from pypi...&quot;)
</ins><span class="cx"> 
</span><span class="cx">     dict = client.release_data(pkg_name, pkg_version)
</span><span class="cx">     dict2 = client.release_urls(pkg_name, pkg_version)
</span><span class="cx">     if dict and dict2:
</span><del>-        print &quot;Data fetched successfully.&quot;
</del><ins>+        print(&quot;Data fetched successfully.&quot;)
</ins><span class="cx">     elif dict:
</span><del>-        print &quot;Release Data fetched successfully.&quot;
</del><ins>+        print(&quot;Release Data fetched successfully.&quot;)
</ins><span class="cx">     elif dict2:
</span><del>-        print &quot;Release url fetched successfully.&quot;
</del><ins>+        print(&quot;Release url fetched successfully.&quot;)
</ins><span class="cx">     else:
</span><del>-        print &quot;No data found.&quot;
</del><ins>+        print(&quot;No data found.&quot;)
</ins><span class="cx"> 
</span><span class="cx">     file_name = os.path.join(home_dir, &quot;Portfile&quot;)
</span><span class="cx">     create_portfile(dict, file_name, dict2)
</span><del>-    print &quot;SUCCESS\n&quot;
</del><ins>+    print(&quot;SUCCESS\n&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Main function - Argument Parser &quot;&quot;&quot;
-
-
</del><span class="cx"> def main(argv):
</span><ins>+    &quot;&quot;&quot; Main function - Argument Parser &quot;&quot;&quot;
</ins><span class="cx">     parser = argparse.ArgumentParser(description=&quot;Pypi2Port Tester&quot;)
</span><span class="cx"> # Calls list_all() which lists al available python packages
</span><span class="cx">     parser.add_argument('-l', '--list', action='store_true', dest='list',
</span><span class="lines">@@ -731,13 +673,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) &gt; 1:
</span><span class="lines">@@ -748,10 +688,9 @@
</span><span class="cx">                 pkg_version = client.package_releases(pkg_name)[0]
</span><span class="cx">                 release_data(pkg_name, pkg_version)
</span><span class="cx">             else:
</span><del>-                print &quot;No release found\n&quot;
</del><ins>+                print(&quot;No release found\n&quot;)
</ins><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) &gt; 1:
</span><span class="lines">@@ -763,10 +702,9 @@
</span><span class="cx">                 pkg_version = releases[0]
</span><span class="cx">                 fetch_url(pkg_name, pkg_version)
</span><span class="cx">             else:
</span><del>-                print &quot;No release found\n&quot;
</del><ins>+                print(&quot;No release found\n&quot;)
</ins><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) &gt; 1:
</span><span class="lines">@@ -778,16 +716,15 @@
</span><span class="cx">                 pkg_version = vers[0]
</span><span class="cx">                 print_portfile(pkg_name, pkg_version)
</span><span class="cx">             else:
</span><del>-                print &quot;No release found\n&quot;
</del><ins>+                print(&quot;No release found\n&quot;)
</ins><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) &gt; 0:
</span><span class="cx">             pkg_name = options.package_test[0]
</span><span class="cx">             port_testing(pkg_name)
</span><span class="cx">         else:
</span><del>-            print &quot;No package name specified\n&quot;
</del><ins>+            print(&quot;No package name specified\n&quot;)
</ins><span class="cx">         return
</span><span class="cx"> 
</span><span class="cx">     parser.print_help()
</span></span></pre></div>
<a id="usersgauravpypi2portpypi2portpy"></a>
<div class="modfile"><h4>Modified: users/gaurav/pypi2port/pypi2port.py (125794 => 125795)</h4>
<pre class="diff"><span>
<span class="info">--- users/gaurav/pypi2port/pypi2port.py        2014-09-26 15:23:13 UTC (rev 125794)
+++ users/gaurav/pypi2port/pypi2port.py        2014-09-26 15:27:58 UTC (rev 125795)
</span><span class="lines">@@ -1,24 +1,18 @@
</span><del>-#! /bin/sh
-&quot;&quot;&quot;:&quot;
-exec python $0 ${1+&quot;$@&quot;}
-&quot;&quot;&quot;
-__doc__ = &quot;&quot;&quot;...Script for pypi2port module written for &quot;The Macports Project&quot;
-             participating in Google Summer of Code 2014...&quot;&quot;&quot;
-
</del><ins>+#!/usr/bin/env python
</ins><span class="cx"> # -*- coding: utf-8 -*-
</span><del>-# !/usr/bin/env python
</del><span class="cx"> 
</span><span class="cx"> import argparse
</span><span class="cx"> import sys
</span><span class="cx"> import os
</span><del>-import urllib2
</del><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><ins>+    from urllib2 import urlopen
</ins><span class="cx"> except ImportError:
</span><span class="cx">     import xmlrpc.client as xmlrpclib
</span><ins>+    from urllib.request import urlopen
</ins><span class="cx"> import textwrap
</span><span class="cx"> import string
</span><span class="cx"> import shutil
</span><span class="lines">@@ -26,53 +20,43 @@
</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="cx"> 
</span><del>-&quot;&quot;&quot; Lists all packages available in pypi database &quot;&quot;&quot;
-
-
</del><span class="cx"> def list_all():
</span><ins>+    &quot;&quot;&quot; Lists all packages available in pypi database &quot;&quot;&quot;
</ins><span class="cx">     list_packages = client.list_packages()
</span><span class="cx">     for package in list_packages:
</span><del>-        print package
</del><ins>+        print(package)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Searches for a particular package by the name classifier &quot;&quot;&quot;
-
-
</del><span class="cx"> def search(pkg_name):
</span><ins>+    &quot;&quot;&quot; Searches for a particular package by the name classifier &quot;&quot;&quot;
</ins><span class="cx">     values = client.search({'name': pkg_name})
</span><span class="cx">     for value in values:
</span><span class="cx">         for key in value.keys():
</span><span class="cx">             print key, '--&gt;', value[key]
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Fetches the release data for a paticular package based on
-    the package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def release_data(pkg_name, pkg_version):
</span><ins>+    &quot;&quot;&quot; Fetches the release data for a paticular package based on
+    the package_name and package_version &quot;&quot;&quot;
</ins><span class="cx">     if pkg_version:
</span><span class="cx">         values = client.release_data(pkg_name, pkg_version)
</span><span class="cx">         if values:
</span><span class="cx">             for key in values.keys():
</span><span class="cx">                 print key, '--&gt;', values[key]
</span><span class="cx">         else:
</span><del>-            print &quot;No such package found.&quot;
-            print &quot;Please specify the exact package name.&quot;
</del><ins>+            print(&quot;No such package found.&quot;)
+            print(&quot;Please specify the exact package name.&quot;)
</ins><span class="cx">         return
</span><span class="cx">     return
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Fetches the distfile for a particular package name and release_url &quot;&quot;&quot;
-
-
</del><span class="cx"> def fetch(pkg_name, dict):
</span><del>-    print &quot;Fetching distfiles...&quot;
</del><ins>+    &quot;&quot;&quot; Fetches the distfile for a particular package name and release_url &quot;&quot;&quot;
+    print(&quot;Fetching distfiles...&quot;)
</ins><span class="cx">     checksum_md5 = dict['md5_digest']
</span><span class="cx">     parent_dir = './sources'
</span><span class="cx">     home_dir = parent_dir + '/' + 'python'
</span><span class="lines">@@ -87,15 +71,15 @@
</span><span class="cx">     url = dict['url']
</span><span class="cx">     file_name = src_dir + '/' + dict['filename']
</span><span class="cx"> 
</span><del>-    u = urllib2.urlopen(url)
</del><ins>+    u = urlopen(url)
</ins><span class="cx">     with open(file_name, 'wb') as f:
</span><span class="cx">         meta = u.info()
</span><span class="cx">         file_size = int(meta.getheaders(&quot;Content-Length&quot;)[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">@@ -113,7 +97,7 @@
</span><span class="cx"> 
</span><span class="cx">     checksum_md5_calc = hashlib.md5(open(file_name).read()).hexdigest()
</span><span class="cx">     if str(checksum_md5) == str(checksum_md5_calc):
</span><del>-        print 'Successfully fetched'
</del><ins>+        print('Successfully fetched')
</ins><span class="cx">         ext = file_name.split('.')[-1]
</span><span class="cx">         if ext == 'egg':
</span><span class="cx">             zip = zipfile.ZipFile(file_name)
</span><span class="lines">@@ -122,41 +106,37 @@
</span><span class="cx">                     zip.extract(name, src_dir)
</span><span class="cx">         return file_name
</span><span class="cx">     else:
</span><del>-        print 'Aborting due to inconsistency on checksums\n'
</del><ins>+        print('Aborting due to inconsistency on checksums\n')
</ins><span class="cx">         try:
</span><span class="cx">             os.remove(file_name)
</span><del>-        except OSError, e:
-            print &quot;Error: %s - %s.&quot; % (e.filename, e.strerror)
</del><ins>+        except OSError as e:
+            print(&quot;Error: %s - %s.&quot; % (e.filename, e.strerror))
</ins><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Checks for the checksums and dependecies for a particular python package
-    on the basis of package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def fetch_url(pkg_name, pkg_version, checksum=False, deps=False):
</span><ins>+    &quot;&quot;&quot; Checks for the checksums and dependecies for a particular python package
+    on the basis of package_name and package_version &quot;&quot;&quot;
</ins><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="cx">             return fetch(pkg_name, value)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Finds dependencies for a particular package on the basis of
-    package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def dependencies(pkg_name, pkg_version, deps=False):
</span><ins>+    &quot;&quot;&quot; Finds dependencies for a particular package on the basis of
+    package_name and package_version &quot;&quot;&quot;
</ins><span class="cx">     flag = False
</span><span class="cx">     if not deps:
</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 +150,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 +166,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">@@ -196,10 +176,8 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Creates a diff file for an existent port &quot;&quot;&quot;
-
-
</del><span class="cx"> def create_diff(old_file, new_file, diff_file):
</span><ins>+    &quot;&quot;&quot; Creates a diff file for an existent port &quot;&quot;&quot;
</ins><span class="cx">     with open(old_file) as f:
</span><span class="cx">         a = f.readlines()
</span><span class="cx"> #    a = open(old_file).readlines()
</span><span class="lines">@@ -208,39 +186,31 @@
</span><span class="cx"> #    b = open(new_file).readlines()
</span><span class="cx">     diff_string = difflib.unified_diff(a, b, &quot;Portfile.orig&quot;, &quot;Portfile&quot;)
</span><span class="cx">     with open(diff_file, 'w') as d:
</span><del>-        try:
-            while 1:
-                d.write(diff_string.next())
-        except:
-            pass
</del><ins>+        d.writelines(diff_string)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Searches for an existent port by its name &quot;&quot;&quot;
-
-
</del><span class="cx"> def search_port(name):
</span><ins>+    &quot;&quot;&quot; Searches for an existent port by its name &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;port file name:^py-&quot; + name + &quot;$&quot;
</span><span class="cx">         command = command.split()
</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><del>-&quot;&quot;&quot; Generates checksums for a package on the basis of the distfile fetched by
-    its package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def checksums(pkg_name, pkg_version):
</span><ins>+    &quot;&quot;&quot; Generates checksums for a package on the basis of the distfile fetched by
+    its package_name and package_version &quot;&quot;&quot;
</ins><span class="cx">     flag = False
</span><del>-    print &quot;Attempting to fetch distfiles...&quot;
</del><ins>+    print(&quot;Attempting to fetch distfiles...&quot;)
</ins><span class="cx">     file_name = fetch_url(pkg_name, pkg_version, True)
</span><span class="cx">     if file_name:
</span><span class="cx">         checksums = []
</span><span class="cx">         try:
</span><del>-            print &quot;Generating checksums...&quot;
</del><ins>+            print(&quot;Generating checksums...&quot;)
</ins><span class="cx">             command = &quot;openssl rmd160 &quot;+file_name
</span><span class="cx">             command = command.split()
</span><span class="cx">             rmd160 = subprocess.check_output(command, stderr=subprocess.STDOUT)
</span><span class="lines">@@ -259,34 +229,30 @@
</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><del>-            print &quot;Error\n&quot;
</del><ins>+            print(&quot;Error\n&quot;)
</ins><span class="cx">             return
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Searches if the distfile listed is present or not &quot;&quot;&quot;
-
-
</del><span class="cx"> def search_distfile(name, version):
</span><ins>+    &quot;&quot;&quot; Searches if the distfile listed is present or not &quot;&quot;&quot;
</ins><span class="cx">     try:
</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><del>-        print &quot;No distfile found&quot;
-        print &quot;Please set a DISTFILE env var before generating the portfile&quot;
</del><ins>+        print(&quot;No distfile found&quot;)
+        print(&quot;Please set a DISTFILE env var before generating the portfile&quot;)
</ins><span class="cx">         sys.exit(0)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Maps the license passed to the already present list of
-    licences available in Macports &quot;&quot;&quot;
-
-
</del><span class="cx"> def search_license(license):
</span><ins>+    &quot;&quot;&quot; Maps the license passed to the already present list of
+    licences available in Macports &quot;&quot;&quot;
</ins><span class="cx">     license = license.lower()
</span><span class="cx">     patterns = ['.*mit.*', '.*apache.*2', '.*apache.*', '.*bsd.*', '.*agpl.*3',
</span><span class="cx">                 '.*agpl.*2', '.*agpl.*', '.*affero.*3', '.*affero.*2',
</span><span class="lines">@@ -305,10 +271,8 @@
</span><span class="cx">             return licenses[i]
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Port Testing function for various phase implementations &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_testing(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Port Testing function for various phase implementations &quot;&quot;&quot;
</ins><span class="cx">     euid = os.geteuid()
</span><span class="cx">     if euid:
</span><span class="cx">         args = ['sudo', sys.executable] + sys.argv + [os.environ]
</span><span class="lines">@@ -316,14 +280,14 @@
</span><span class="cx"> 
</span><span class="cx">     for phase in [port_fetch, port_checksum, port_extract, port_configure,
</span><span class="cx">                   port_build, port_destroot, port_clean]:
</span><del>-        print phase.__name__
</del><ins>+        print(phase.__name__)
</ins><span class="cx">         phase_output = phase(name, portv)
</span><span class="cx">         if phase_output:
</span><del>-            print phase.__name__ + &quot; - SUCCESS&quot;
</del><ins>+            print(phase.__name__ + &quot; - SUCCESS&quot;)
</ins><span class="cx">         else:
</span><del>-            print phase.__name__ + &quot; FAILED&quot;
</del><ins>+            print(phase.__name__ + &quot; FAILED&quot;)
</ins><span class="cx">             port_clean(name, portv)
</span><del>-            print &quot;Exiting&quot;
</del><ins>+            print(&quot;Exiting&quot;)
</ins><span class="cx">             sys.exit(1)
</span><span class="cx"> 
</span><span class="cx">         euid = os.geteuid()
</span><span class="lines">@@ -332,125 +296,107 @@
</span><span class="cx">             os.execlpe('sudo', *args)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Fetch phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_fetch(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Fetch phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t fetch dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_checksum(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t checksum dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_extract(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t extract dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Patch phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_patch(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Patch phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t patch dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Configure phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_configure(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Configure phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t configure dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Build phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_build(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Build phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t build dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Destroot phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_destroot(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Destroot phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t destroot dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Clean phase implementation &quot;&quot;&quot;
-
-
</del><span class="cx"> def port_clean(name, portv='27'):
</span><ins>+    &quot;&quot;&quot; Clean phase implementation &quot;&quot;&quot;
</ins><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t clean dports/python/py-&quot; + \
</span><span class="cx">                   name + &quot; subport=py&quot; + portv + &quot;-&quot; + 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="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Creates a portfile on the basis of the release_data and release_url fetched
-    on the basis of package_name and package_version &quot;&quot;&quot;
-
-
</del><span class="cx"> def create_portfile(dict, file_name, dict2):
</span><ins>+    &quot;&quot;&quot; Creates a portfile on the basis of the release_data and release_url fetched
+    on the basis of package_name and package_version &quot;&quot;&quot;
</ins><span class="cx">     search_distfile(dict['name'], dict['version'])
</span><del>-    print &quot;Creating Portfile for pypi package &quot; + dict['name'] + &quot;...&quot;
</del><ins>+    print(&quot;Creating Portfile for pypi package &quot; + dict['name'] + &quot;...&quot;)
</ins><span class="cx">     with open(file_name, 'w') as file:
</span><span class="cx">         file.write('# -*- coding: utf-8; mode: tcl; tab-width: 4; ')
</span><span class="cx">         file.write('indent-tabs-mode: nil; c-basic-offset: 4 ')
</span><span class="lines">@@ -475,8 +421,8 @@
</span><span class="cx">                 file.write('maintainers         {0}\n\n'.format(
</span><span class="cx">                            os.getenv('maintainer', 'nomaintainer')))
</span><span class="cx">         else:
</span><del>-            print &quot;No maintainers found...&quot;
-            print &quot;Looking for maintainers in environment variables...&quot;
</del><ins>+            print(&quot;No maintainers found...&quot;)
+            print(&quot;Looking for maintainers in environment variables...&quot;)
</ins><span class="cx">             file.write('maintainers         {0}\n\n'.format(
</span><span class="cx">                        os.getenv('maintainer', 'nomaintainer')))
</span><span class="cx"> 
</span><span class="lines">@@ -499,7 +445,7 @@
</span><span class="cx">                         file.write(&quot;{0} \\\n&quot;.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">@@ -526,8 +472,8 @@
</span><span class="cx">         if home_page and not home_page == 'UNKNOWN':
</span><span class="cx">             file.write('homepage            {0}\n'.format(home_page))
</span><span class="cx">         else:
</span><del>-            print &quot;No homepage found...&quot;
-            print &quot;Looking for homepage in environment variables...&quot;
</del><ins>+            print(&quot;No homepage found...&quot;)
+            print(&quot;Looking for homepage in environment variables...&quot;)
</ins><span class="cx">             file.write('homepage            {0}\n'.format(
</span><span class="cx">                        os.getenv('home_page', '')))
</span><span class="cx"> 
</span><span class="lines">@@ -541,8 +487,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">@@ -560,8 +506,8 @@
</span><span class="cx">                 master_site = dict['release_url']
</span><span class="cx"> #                print master_site
</span><span class="cx">             else:
</span><del>-                print &quot;No master site found...&quot;
-                print &quot;Looking for master site in environment variables...&quot;
</del><ins>+                print(&quot;No master site found...&quot;)
+                print(&quot;Looking for master site in environment variables...&quot;)
</ins><span class="cx">                 master_site = os.getenv('master_site', '')
</span><span class="cx">         if master_site:
</span><span class="cx">             file.write('master_sites        {0}\n'.format(master_site))
</span><span class="lines">@@ -576,7 +522,7 @@
</span><span class="cx">         file.write('distname            {0}-{1}\n\n'.format(
</span><span class="cx">                    dict['name'], dict['version']))
</span><span class="cx"> 
</span><del>-        print &quot;Attempting to generate checksums for &quot; + dict['name'] + &quot;...&quot;
</del><ins>+        print(&quot;Attempting to generate checksums for &quot; + dict['name'] + &quot;...&quot;)
</ins><span class="cx">         checksums_values = checksums(dict['name'], dict['version'])
</span><span class="cx">         if checksums_values:
</span><span class="cx">             file.write('checksums           rmd160  {0} \\\n'.format(
</span><span class="lines">@@ -591,16 +537,16 @@
</span><span class="cx">         else:
</span><span class="cx">             file.write('python.versions     25 26 27 32 33 34\n\n')
</span><span class="cx"> 
</span><del>-        print &quot;Finding dependencies...&quot;
</del><ins>+        print(&quot;Finding dependencies...&quot;)
</ins><span class="cx">         file.write('if {${name} ne ${subport}} {\n')
</span><span class="cx">         file.write('    depends_build-append \\\n')
</span><span class="cx">         file.write('                        ' +
</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('&gt;')[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">@@ -639,29 +585,27 @@
</span><span class="cx">             file.write('}\n')
</span><span class="cx">         else:
</span><span class="cx">             file.write('}\n')
</span><del>-    print &quot;Searching for existent port...&quot;
</del><ins>+    print(&quot;Searching for existent port...&quot;)
</ins><span class="cx">     port_exists = search_port(dict['name'])
</span><span class="cx">     if port_exists:
</span><del>-        print &quot;Creating diff...&quot;
</del><ins>+        print(&quot;Creating diff...&quot;)
</ins><span class="cx">         old_file = port_exists
</span><span class="cx">         new_file = './dports/python/py-'+dict['name']+'/Portfile'
</span><span class="cx">         diff_file = './dports/python/py-'+dict['name']+'/patch.Portfile.diff'
</span><span class="cx">         create_diff(old_file, new_file, diff_file)
</span><del>-        print str(os.path.abspath(diff_file))+&quot;\n&quot;
</del><ins>+        print(str(os.path.abspath(diff_file))+&quot;\n&quot;)
</ins><span class="cx"> #        with open(diff_file) as diff:
</span><span class="cx"> #            print diff.read()
</span><del>-        print &quot;\nIf you want to open a new ticket. Please visit&quot;
-        print &quot;https://trac.macports.org/auth/login/?next=/newticket&quot;
-        print &quot;to open a new ticket after logging in with your credentials.&quot;
</del><ins>+        print(&quot;\nIf you want to open a new ticket. Please visit&quot;)
+        print(&quot;https://trac.macports.org/auth/login/?next=/newticket&quot;)
+        print(&quot;to open a new ticket after logging in with your credentials.&quot;)
</ins><span class="cx">     else:
</span><del>-        print &quot;No port found.&quot;
</del><ins>+        print(&quot;No port found.&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Creates the directories and other commands necessary
-    for a development environment &quot;&quot;&quot;
-
-
</del><span class="cx"> def print_portfile(pkg_name, pkg_version=None):
</span><ins>+    &quot;&quot;&quot; Creates the directories and other commands necessary
+    for a development environment &quot;&quot;&quot;
</ins><span class="cx">     root_dir = os.path.abspath(&quot;./dports&quot;)
</span><span class="cx">     port_dir = os.path.join(root_dir, 'python')
</span><span class="cx">     home_dir = os.path.join(port_dir, 'py-'+pkg_name)
</span><span class="lines">@@ -678,28 +622,26 @@
</span><span class="cx">     if not os.path.exists(home_dir):
</span><span class="cx">         os.makedirs(home_dir)
</span><span class="cx"> 
</span><del>-    print &quot;Attempting to fetch data from pypi...&quot;
</del><ins>+    print(&quot;Attempting to fetch data from pypi...&quot;)
</ins><span class="cx"> 
</span><span class="cx">     dict = client.release_data(pkg_name, pkg_version)
</span><span class="cx">     dict2 = client.release_urls(pkg_name, pkg_version)
</span><span class="cx">     if dict and dict2:
</span><del>-        print &quot;Data fetched successfully.&quot;
</del><ins>+        print(&quot;Data fetched successfully.&quot;)
</ins><span class="cx">     elif dict:
</span><del>-        print &quot;Release Data fetched successfully.&quot;
</del><ins>+        print(&quot;Release Data fetched successfully.&quot;)
</ins><span class="cx">     elif dict2:
</span><del>-        print &quot;Release url fetched successfully.&quot;
</del><ins>+        print(&quot;Release url fetched successfully.&quot;)
</ins><span class="cx">     else:
</span><del>-        print &quot;No data found.&quot;
</del><ins>+        print(&quot;No data found.&quot;)
</ins><span class="cx"> 
</span><span class="cx">     file_name = os.path.join(home_dir, &quot;Portfile&quot;)
</span><span class="cx">     create_portfile(dict, file_name, dict2)
</span><del>-    print &quot;SUCCESS\n&quot;
</del><ins>+    print(&quot;SUCCESS\n&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot; Main function - Argument Parser &quot;&quot;&quot;
-
-
</del><span class="cx"> def main(argv):
</span><ins>+    &quot;&quot;&quot; Main function - Argument Parser &quot;&quot;&quot;
</ins><span class="cx">     parser = argparse.ArgumentParser(description=&quot;Pypi2Port Tester&quot;)
</span><span class="cx"> # Calls list_all() which lists al available python packages
</span><span class="cx">     parser.add_argument('-l', '--list', action='store_true', dest='list',
</span><span class="lines">@@ -731,13 +673,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) &gt; 1:
</span><span class="lines">@@ -748,10 +688,9 @@
</span><span class="cx">                 pkg_version = client.package_releases(pkg_name)[0]
</span><span class="cx">                 release_data(pkg_name, pkg_version)
</span><span class="cx">             else:
</span><del>-                print &quot;No release found\n&quot;
</del><ins>+                print(&quot;No release found\n&quot;)
</ins><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) &gt; 1:
</span><span class="lines">@@ -763,10 +702,9 @@
</span><span class="cx">                 pkg_version = releases[0]
</span><span class="cx">                 fetch_url(pkg_name, pkg_version)
</span><span class="cx">             else:
</span><del>-                print &quot;No release found\n&quot;
</del><ins>+                print(&quot;No release found\n&quot;)
</ins><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) &gt; 1:
</span><span class="lines">@@ -778,16 +716,15 @@
</span><span class="cx">                 pkg_version = vers[0]
</span><span class="cx">                 print_portfile(pkg_name, pkg_version)
</span><span class="cx">             else:
</span><del>-                print &quot;No release found\n&quot;
</del><ins>+                print(&quot;No release found\n&quot;)
</ins><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) &gt; 0:
</span><span class="cx">             pkg_name = options.package_test[0]
</span><span class="cx">             port_testing(pkg_name)
</span><span class="cx">         else:
</span><del>-            print &quot;No package name specified\n&quot;
</del><ins>+            print(&quot;No package name specified\n&quot;)
</ins><span class="cx">         return
</span><span class="cx"> 
</span><span class="cx">     parser.print_help()
</span></span></pre>
</div>
</div>

</body>
</html>