<!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>[130752] users/gaurav/pypi2port/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/130752">130752</a></dd>
<dt>Author</dt> <dd>gaurav@macports.org</dd>
<dt>Date</dt> <dd>2015-01-02 04:06:59 -0800 (Fri, 02 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Updated executable</pre>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="usersgauravpypi2portpypi2port"></a>
<div class="modfile"><h4>Modified: users/gaurav/pypi2port/pypi2port (130751 => 130752)</h4>
<pre class="diff"><span>
<span class="info">--- users/gaurav/pypi2port/pypi2port        2015-01-02 12:03:33 UTC (rev 130751)
+++ users/gaurav/pypi2port/pypi2port        2015-01-02 12:06:59 UTC (rev 130752)
</span><span class="lines">@@ -7,728 +7,748 @@
</span><span class="cx"> import hashlib
</span><span class="cx"> import zipfile
</span><span class="cx"> import progressbar as pb
</span><ins>+# progressbar3000 for python3
+import requests
</ins><span class="cx"> try:
</span><del>-    import xmlrpclib
-    from urllib2 import urlopen
</del><ins>+        import xmlrpclib
</ins><span class="cx"> except ImportError:
</span><del>-    import xmlrpc.client as xmlrpclib
-    from urllib.request import urlopen
</del><ins>+        import xmlrpc.client as xmlrpclib
</ins><span class="cx"> import textwrap
</span><span class="cx"> import string
</span><span class="cx"> import shutil
</span><span class="cx"> import re
</span><span class="cx"> import difflib
</span><span class="cx"> import subprocess
</span><del>-import requests
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx"> client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def list_all():
</span><del>-    &quot;&quot;&quot; Lists all packages available in pypi database &quot;&quot;&quot;
-    list_packages = client.list_packages()
-    for package in list_packages:
-        print(package)
</del><ins>+        &quot;&quot;&quot; Lists all packages available in pypi database &quot;&quot;&quot;
+        list_packages = client.list_packages()
+        for package in list_packages:
+                print(package)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class Package_Search:
+        def __init__(self, name, summary, version):
+                self.name = name
+                self.version = version
+                self.summary = &quot;&quot;
+                for i in range(0, len(summary), 62):
+                        self.summary += summary[i:62+i] + '\n\t\t'
+
+        def __str__(self):
+                return &quot;Name\t\t&quot; + self.name + &quot;\nVersion\t\t&quot; + self.version + &quot;\nSummary\t\t&quot; + self.summary + &quot;\n&quot;
+                
+
</ins><span class="cx"> def search(pkg_name):
</span><del>-    &quot;&quot;&quot; Searches for a particular package by the name classifier &quot;&quot;&quot;
-    values = client.search({'name': pkg_name})
-    for value in values:
-        for key in value.keys():
-            print key, '--&gt;', value[key]
</del><ins>+        &quot;&quot;&quot; Searches for a particular package by the name classifier &quot;&quot;&quot;
+        values = client.search({'name': pkg_name})
+        for value in values:
+                package = Package_Search(value['name'], value['summary'], value['version'])
+                print(package)
</ins><span class="cx"> 
</span><ins>+class Package_release_data:
+        def __init__(self, attributes):
+                # self.name = name
+                # self.version = version
+                # self.home_page = attributes['home_page']
+                # self.license = attributes['license']
+                # self.summary = attributes['summary']
+                # self.maintainer = attributes['maintainer']
+                # self.docs_url = attributes['docs_url']
+                # self.requires_python = attributes['requires_python']
+                # self.maintainer_email = attributes['maintainer_email']
+                # self.cheesecake_code_kwalitee_id = attributes['cheesecake_code_kwalitee_id']
+                # self.keywords = attributes['keywords']
+                # self.package_url = attributes['package_url']
+                # self.author = attributes['author']
+                # self.author_email = attributes['author_email']
+                # self.download_url = attributes['download_url']
+                # self.platform = attributes['platform']
+                # self.cheesecake_documentation_id = attributes['cheesecake_documentation_id']
+                # self._pypi_hidden = attributes['_pypi_hidden']
+                # self.description = attributes['description']
+                # self.release_url = attributes['release_url']
+                # self.downloads = attributes['downloads']
+                # self._pypi_ordering = attributes['_pypi_ordering']
+                # self.classifiers = attributes['classifiers']
+                # self.bugtrack_url = attributes['bugtrack_url']
+                # self.stable_version = attributes['stable_version']
+                # self.cheesecake_installability_id = attributes['cheesecake_installability_id']
</ins><span class="cx"> 
</span><ins>+                variables = attributes.keys()
+                for v in variables:
+                        setattr(self, v, attributes[v])
+
+        def __str__(self):
+                output = &quot;Name\t\t&quot; + self.name + &quot;\nVersion\t\t&quot; + self.version
+                if self.maintainer and self.maintainer != 'UNKNOWN':
+                        output += &quot;\nMaintainter\t&quot; + self.maintainer
+                output += &quot;\nHome_page\t&quot; + self.home_page
+                output += &quot;\nPackage_url\t&quot; + self.package_url
+                if self.download_url and self.download_url != 'UNKNOWN':
+                        output += &quot;\nDownload_url\t&quot; + self.download_url
+                output += &quot;\nRelease_url\t&quot; + self.release_url
+                if self.docs_url and self.docs_url != 'UNKNOWN':
+                        output += &quot;\nDocs_url\t&quot; + self.docs_url
+                output += &quot;\nDescription\t&quot; + self.description
+                return output
+
</ins><span class="cx"> def release_data(pkg_name, pkg_version):
</span><del>-    &quot;&quot;&quot; Fetches the release data for a paticular package based on
-    the package_name and package_version &quot;&quot;&quot;
-    if pkg_version:
-        values = client.release_data(pkg_name, pkg_version)
-        if values:
-            for key in values.keys():
-                print key, '--&gt;', values[key]
-        else:
-            print(&quot;No such package found.&quot;)
-            print(&quot;Please specify the exact package name.&quot;)
-        return
-    return
</del><ins>+        &quot;&quot;&quot; Fetches the release data for a paticular package based on
+        the package_name and package_version &quot;&quot;&quot;
+        # if pkg_version:
+        values = client.release_data(pkg_name, pkg_version)
+        if values:
+                package = Package_release_data(values)
+                print(package)
+        else:
+                print(&quot;No such package found.&quot;)
+                print(&quot;Please specify the exact package name.&quot;)
+        return
+        # return
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def fetch(pkg_name, dict):
</span><del>-    &quot;&quot;&quot; Fetches the distfile for a particular package name and release_url &quot;&quot;&quot;
-    print(&quot;Fetching distfiles...&quot;)
-    checksum_md5 = dict['md5_digest']
-    parent_dir = './sources'
-    home_dir = parent_dir + '/' + 'python'
-    src_dir = home_dir + '/py-' + pkg_name
-    if not os.path.exists(parent_dir):
-        os.makedirs(parent_dir)
-    if not os.path.exists(home_dir):
-        os.makedirs(home_dir)
-    if not os.path.exists(src_dir):
-        os.makedirs(src_dir)
</del><ins>+        &quot;&quot;&quot; Fetches the distfile for a particular package name and release_url &quot;&quot;&quot;
+        print(&quot;Fetching distfiles...&quot;)
+        checksum_md5 = dict['md5_digest']
+        parent_dir = './sources'
+        home_dir = parent_dir + '/' + 'python'
+        src_dir = home_dir + '/py-' + pkg_name
+        if not os.path.exists(parent_dir):
+                os.makedirs(parent_dir)
+        if not os.path.exists(home_dir):
+                os.makedirs(home_dir)
+        if not os.path.exists(src_dir):
+                os.makedirs(src_dir)
</ins><span class="cx"> 
</span><del>-    url = dict['url']
-    file_name = src_dir + '/' + dict['filename']
</del><ins>+        url = dict['url']
+        file_name = src_dir + '/' + dict['filename']
</ins><span class="cx"> 
</span><del>-    u = urlopen(url)
-    with open(file_name, 'wb') as f:
-        meta = u.info()
-        file_size = int(meta.getheaders(&quot;Content-Length&quot;)[0])
</del><ins>+        r = requests.get(url)
+        if r.status_code == 200        :
+                with open(file_name, 'wb') as f:
+                        meta = r.headers['content-length']
+                        file_size = int(meta)
</ins><span class="cx"> 
</span><del>-        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()
</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))
+                        pbar.start()
</ins><span class="cx"> 
</span><del>-        file_size_dl = 0
-        block_sz = 1024
-        while True:
-            buffer = u.read(block_sz)
-            if not buffer:
-                break
</del><ins>+                        file_size_dl = 0
+                        block_sz = 1024
</ins><span class="cx"> 
</span><del>-            file_size_dl += len(buffer)
-            f.write(buffer)
-            pbar.update(file_size_dl)
</del><ins>+                        for chunk in r.iter_content(block_sz):
+                                if file_size_dl+block_sz &gt; file_size:
+                                        file_size_dl = file_size
+                                else:
+                                        file_size_dl += block_sz
+                                f.write(chunk)
+                                pbar.update(file_size_dl)
</ins><span class="cx"> 
</span><del>-        pbar.finish()
</del><ins>+                        pbar.finish()
</ins><span class="cx"> 
</span><del>-    checksum_md5_calc = hashlib.md5(open(file_name).read()).hexdigest()
-    if str(checksum_md5) == str(checksum_md5_calc):
-        print('Successfully fetched')
-        ext = file_name.split('.')[-1]
-        if ext == 'egg':
-            zip = zipfile.ZipFile(file_name)
-            for name in zip.namelist():
-                if name.split(&quot;/&quot;)[0] == &quot;EGG-INFO&quot;:
-                    zip.extract(name, src_dir)
-        return file_name
-    else:
-        print('Aborting due to inconsistency on checksums\n')
-        try:
-            os.remove(file_name)
-        except OSError as e:
-            print(&quot;Error: %s - %s.&quot; % (e.filename, e.strerror))
-        return False
</del><ins>+        checksum_md5_calc = hashlib.md5(open(file_name).read()).hexdigest()
+        if str(checksum_md5) == str(checksum_md5_calc):
+                print('Successfully fetched')
+                ext = file_name.split('.')[-1]
+                if ext == 'egg':
+                        zip = zipfile.ZipFile(file_name)
+                        for name in zip.namelist():
+                                if name.split(&quot;/&quot;)[0] == &quot;EGG-INFO&quot;:
+                                        zip.extract(name, src_dir)
+                return file_name
+        else:
+                print('Aborting due to inconsistency on checksums\n')
+                try:
+                        os.remove(file_name)
+                except OSError as e:
+                        print(&quot;Error: %s - %s.&quot; % (e.filename, e.strerror))
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def fetch_url(pkg_name, pkg_version, checksum=False, deps=False):
</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;
-    values = client.release_urls(pkg_name, pkg_version)
-    if checksum:
-        # print values
-        for value in values:
-            if value['filename'].split('.')[-1] in ('gz', 'zip'):
-                return fetch(pkg_name, value)
-    else:
-        for value in values:
-            return fetch(pkg_name, value)
</del><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;
+        values = client.release_urls(pkg_name, pkg_version)
+        if checksum:
+                for value in values:
+                        if value['filename'].split('.')[-1] in ('gz', 'zip'):
+                                return fetch(pkg_name, value)
+        else:
+                for value in values:
+                        return fetch(pkg_name, value)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def dependencies(pkg_name, pkg_version, deps=False):
</span><del>-    &quot;&quot;&quot; Finds dependencies for a particular package on the basis of
-    package_name and package_version &quot;&quot;&quot;
-    flag = False
-    if not deps:
-        return
-    values = client.release_urls(pkg_name, pkg_version)
-    for value in values:
-        if value['filename'].split('.')[-1] in ('gz', 'zip'):
-            fetch(pkg_name, value)
-    try:
-        with open('./sources/python/py-'
-                  + pkg_name + '/EGG-INFO/requires.txt') as f:
-            list = f.readlines()
-            list = [x.strip('\n') for x in list]
-        f.close()
-        try:
-            if flag:
-                shutil.rmtree('./sources/python/py-' + pkg_name + '/EGG-INFO',
-                              ignore_errors=True)
-                items = os.listdir('./sources/python/py-' + pkg_name)
-                for item in items[:]:
-                    if item.split('.')[-1] not in ('gz', 'zip'):
-                        os.remove('./sources/python/py-'
-                                  + pkg_name + '/' + item)
-                        items.remove(item)
-                if not items:
-                    os.rmdir('./sources/python/py-' + pkg_name)
-        except:
-            pass
-        return list
-    except:
-        try:
-            if flag:
-                shutil.rmtree('./sources/python/py-'+pkg_name+'/EGG-INFO',
-                              ignore_errors=True)
-                items = os.listdir('./sources/python/py-'+pkg_name)
-                for item in items[:]:
-                    if item.split('.')[-1] not in ('gz', 'zip'):
-                        os.remove('./sources/python/py-'+pkg_name+'/'+item)
-                        items.remove(item)
-                if not items:
-                    os.rmdir('./sources/python/py-'+pkg_name)
-        except:
-            pass
-        return False
</del><ins>+        &quot;&quot;&quot; Finds dependencies for a particular package on the basis of
+        package_name and package_version &quot;&quot;&quot;
+        flag = False
+        if not deps:
+                return
+        values = client.release_urls(pkg_name, pkg_version)
+        for value in values:
+                if value['filename'].split('.')[-1] in ('gz', 'zip'):
+                        fetch(pkg_name, value)
+        try:
+                with open('./sources/python/py-'
+                                  + pkg_name + '/EGG-INFO/requires.txt') as f:
+                        list = f.readlines()
+                        list = [x.strip('\n') for x in list]
+                f.close()
+                try:
+                        if flag:
+                                shutil.rmtree('./sources/python/py-' + pkg_name + '/EGG-INFO',
+                                                          ignore_errors=True)
+                                items = os.listdir('./sources/python/py-' + pkg_name)
+                                for item in items[:]:
+                                        if item.split('.')[-1] not in ('gz', 'zip'):
+                                                os.remove('./sources/python/py-'
+                                                                  + pkg_name + '/' + item)
+                                                items.remove(item)
+                                if not items:
+                                        os.rmdir('./sources/python/py-' + pkg_name)
+                except:
+                        pass
+                return list
+        except:
+                try:
+                        if flag:
+                                shutil.rmtree('./sources/python/py-'+pkg_name+'/EGG-INFO',
+                                                          ignore_errors=True)
+                                items = os.listdir('./sources/python/py-'+pkg_name)
+                                for item in items[:]:
+                                        if item.split('.')[-1] not in ('gz', 'zip'):
+                                                os.remove('./sources/python/py-'+pkg_name+'/'+item)
+                                                items.remove(item)
+                                if not items:
+                                        os.rmdir('./sources/python/py-'+pkg_name)
+                except:
+                        pass
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def create_diff(old_file, new_file, diff_file):
</span><del>-    &quot;&quot;&quot; Creates a diff file for an existent port &quot;&quot;&quot;
-    with open(old_file) as f:
-        a = f.readlines()
</del><ins>+        &quot;&quot;&quot; Creates a diff file for an existent port &quot;&quot;&quot;
+        with open(old_file) as f:
+                a = f.readlines()
</ins><span class="cx"> #    a = open(old_file).readlines()
</span><del>-    with open(new_file) as f:
-        b = f.readlines()
</del><ins>+        with open(new_file) as f:
+                b = f.readlines()
</ins><span class="cx"> #    b = open(new_file).readlines()
</span><del>-    diff_string = difflib.unified_diff(a, b, &quot;Portfile.orig&quot;, &quot;Portfile&quot;)
-    with open(diff_file, 'w') as d:
-        d.writelines(diff_string)
</del><ins>+        diff_string = difflib.unified_diff(a, b, &quot;Portfile.orig&quot;, &quot;Portfile&quot;)
+        with open(diff_file, 'w') as d:
+                d.writelines(diff_string)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def search_port(name):
</span><del>-    &quot;&quot;&quot; Searches for an existent port by its name &quot;&quot;&quot;
-    try:
-        command = &quot;port file name:^py-&quot; + name + &quot;$&quot;
-        command = command.split()
-        existing_portfile = \
-            subprocess.check_output(command, stderr=subprocess.STDOUT).strip()
-        return existing_portfile
-    except Exception:
-        return False
</del><ins>+        &quot;&quot;&quot; Searches for an existent port by its name &quot;&quot;&quot;
+        try:
+                command = &quot;port file name:^py-&quot; + name + &quot;$&quot;
+                command = command.split()
+                existing_portfile = \
+                        subprocess.check_output(command, stderr=subprocess.STDOUT).strip()
+                return existing_portfile
+        except Exception:
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def checksums(pkg_name, pkg_version):
</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;
-    flag = False
-    print(&quot;Attempting to fetch distfiles...&quot;)
-    file_name = fetch_url(pkg_name, pkg_version, True)
-    if file_name:
-        checksums = []
-        try:
-            print(&quot;Generating checksums...&quot;)
-            command = &quot;openssl rmd160 &quot;+file_name
-            command = command.split()
-            rmd160 = subprocess.check_output(command, stderr=subprocess.STDOUT)
-            rmd160 = rmd160.split('=')[1].strip()
-            checksums.insert(0, rmd160)
</del><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;
+        flag = False
+        print(&quot;Attempting to fetch distfiles...&quot;)
+        file_name = fetch_url(pkg_name, pkg_version, True)
+        if file_name:
+                checksums = []
+                try:
+                        print(&quot;Generating checksums...&quot;)
+                        command = &quot;openssl rmd160 &quot;+file_name
+                        command = command.split()
+                        rmd160 = subprocess.check_output(command, stderr=subprocess.STDOUT)
+                        rmd160 = rmd160.split('=')[1].strip()
+                        checksums.insert(0, rmd160)
</ins><span class="cx"> 
</span><del>-            command = &quot;openssl sha256 &quot;+file_name
-            command = command.split()
-            sha256 = subprocess.check_output(command, stderr=subprocess.STDOUT)
-            sha256 = sha256.split('=')[1].strip()
-            checksums.insert(1, sha256)
</del><ins>+                        command = &quot;openssl sha256 &quot;+file_name
+                        command = command.split()
+                        sha256 = subprocess.check_output(command, stderr=subprocess.STDOUT)
+                        sha256 = sha256.split('=')[1].strip()
+                        checksums.insert(1, sha256)
</ins><span class="cx"> 
</span><del>-            dir = '/'.join(file_name.split('/')[0:-1])
-            if flag:
-                os.remove(file_name)
-            try:
-                if flag:
-                    os.rmdir(dir)
-            except OSError:
-                pass
-            return checksums
-        except:
-            print(&quot;Error\n&quot;)
-            return
</del><ins>+                        dir = '/'.join(file_name.split('/')[0:-1])
+                        if flag:
+                                os.remove(file_name)
+                        try:
+                                if flag:
+                                        os.rmdir(dir)
+                        except OSError:
+                                pass
+                        return checksums
+                except:
+                        print(&quot;Error\n&quot;)
+                        return
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def search_distfile(name, version):
</span><del>-    &quot;&quot;&quot; Searches if the distfile listed is present or not &quot;&quot;&quot;
-    try:
-        url = client.release_urls(name, version)[0]['url']
-        r = requests.get(url, verify=False)
-        if not r.status_code == 200:
-            raise Exception('No distfile')
-    except:
-        print(&quot;No distfile found&quot;)
-        print(&quot;Please set a DISTFILE env var before generating the portfile&quot;)
-        sys.exit(0)
</del><ins>+        &quot;&quot;&quot; Searches if the distfile listed is present or not &quot;&quot;&quot;
+        try:
+                url = client.release_urls(name, version)[0]['url']
+                r = requests.get(url, verify=False)
+                if not r.status_code == 200:
+                        raise Exception('No distfile')
+        except:
+                print(&quot;No distfile found&quot;)
+                print(&quot;Please set a DISTFILE env var before generating the portfile&quot;)
+                sys.exit(0)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def search_license(license):
</span><del>-    &quot;&quot;&quot; Maps the license passed to the already present list of
-    licences available in Macports &quot;&quot;&quot;
-    license = license.lower()
-    patterns = ['.*mit.*', '.*apache.*2', '.*apache.*', '.*bsd.*', '.*agpl.*3',
-                '.*agpl.*2', '.*agpl.*', '.*affero.*3', '.*affero.*2',
-                '.*affero.*', '.*lgpl.*3', '.*lgpl.*2', '.*lgpl.*', '.*gpl.*3',
-                '.*gpl.*2', '.*gpl.*', '.*general.*public.*license.*3',
-                '.*general.*public.*license.*2',
-                '.*general.*public.*license.*', '.*mpl.*3', '.*mpl.*2',
-                '.*mpl.*', '.*python.*license.*', '^python$', '.*']
-    licenses = ['MIT', 'Apache-2', 'Apache', 'BSD', 'AGPL-3', 'AGPL-2', 'AGPL',
-                'AGPL-3', 'AGPL-2', 'AGPL', 'LGPL-3', 'LGPL-2', 'LGPL',
-                'GPL-3', 'GPL-2', 'GPL', 'GPL-3', 'GPL-2', 'GPL', 'MPL-3',
-                'MPL-2', 'MPL', 'Python', 'Python', 'NULL']
-    for i in range(len(patterns)):
-        match = re.search(patterns[i], license)
-        if match:
-            return licenses[i]
</del><ins>+        &quot;&quot;&quot; Maps the license passed to the already present list of
+        licences available in Macports &quot;&quot;&quot;
+        license = license.lower()
+        patterns = ['.*mit.*', '.*apache.*2', '.*apache.*', '.*bsd.*', '.*agpl.*3',
+                                '.*agpl.*2', '.*agpl.*', '.*affero.*3', '.*affero.*2',
+                                '.*affero.*', '.*lgpl.*3', '.*lgpl.*2', '.*lgpl.*', '.*gpl.*3',
+                                '.*gpl.*2', '.*gpl.*', '.*general.*public.*license.*3',
+                                '.*general.*public.*license.*2',
+                                '.*general.*public.*license.*', '.*mpl.*3', '.*mpl.*2',
+                                '.*mpl.*', '.*python.*license.*', '^python$', '.*']
+        licenses = ['MIT', 'Apache-2', 'Apache', 'BSD', 'AGPL-3', 'AGPL-2', 'AGPL',
+                                'AGPL-3', 'AGPL-2', 'AGPL', 'LGPL-3', 'LGPL-2', 'LGPL',
+                                'GPL-3', 'GPL-2', 'GPL', 'GPL-3', 'GPL-2', 'GPL', 'MPL-3',
+                                'MPL-2', 'MPL', 'Python', 'Python', 'NULL']
+        for i in range(len(patterns)):
+                match = re.search(patterns[i], license)
+                if match:
+                        return licenses[i]
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_testing(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Port Testing function for various phase implementations &quot;&quot;&quot;
-    euid = os.geteuid()
-    if euid:
-        args = ['sudo', sys.executable] + sys.argv + [os.environ]
-        os.execlpe('sudo', *args)
</del><ins>+        &quot;&quot;&quot; Port Testing function for various phase implementations &quot;&quot;&quot;
+        euid = os.geteuid()
+        if euid:
+                args = ['sudo', sys.executable] + sys.argv + [os.environ]
+                os.execlpe('sudo', *args)
</ins><span class="cx"> 
</span><del>-    for phase in [port_fetch, port_checksum, port_extract, port_configure,
-                  port_build, port_destroot, port_clean]:
-        print(phase.__name__)
-        phase_output = phase(name, portv)
-        if phase_output:
-            print(phase.__name__ + &quot; - SUCCESS&quot;)
-        else:
-            print(phase.__name__ + &quot; FAILED&quot;)
-            port_clean(name, portv)
-            print(&quot;Exiting&quot;)
-            sys.exit(1)
</del><ins>+        for phase in [port_fetch, port_checksum, port_extract, port_configure,
+                                  port_build, port_destroot, port_clean]:
+                print(phase.__name__)
+                phase_output = phase(name, portv)
+                if phase_output:
+                        print(phase.__name__ + &quot; - SUCCESS&quot;)
+                else:
+                        print(phase.__name__ + &quot; FAILED&quot;)
+                        port_clean(name, portv)
+                        print(&quot;Exiting&quot;)
+                        sys.exit(1)
</ins><span class="cx"> 
</span><del>-        euid = os.geteuid()
-        if euid:
-            args = ['sudo', sys.executable] + sys.argv + [os.environ]
-            os.execlpe('sudo', *args)
</del><ins>+                euid = os.geteuid()
+                if euid:
+                        args = ['sudo', sys.executable] + sys.argv + [os.environ]
+                        os.execlpe('sudo', *args)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_fetch(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Fetch phase implementation &quot;&quot;&quot;
-    try:
-        command = &quot;sudo port -t fetch dports/python/py-&quot; + \
-                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
-        command = command.split()
-        subprocess.check_call(command, stderr=subprocess.STDOUT)
-        return True
-    except:
-        return False
</del><ins>+        &quot;&quot;&quot; Fetch phase implementation &quot;&quot;&quot;
+        try:
+                command = &quot;sudo port -t fetch dports/python/py-&quot; + \
+                                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
+                command = command.split()
+                subprocess.check_call(command, stderr=subprocess.STDOUT)
+                return True
+        except:
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_checksum(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
-    try:
-        command = &quot;sudo port -t checksum dports/python/py-&quot; + \
-                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
-        command = command.split()
-        subprocess.check_call(command, stderr=subprocess.STDOUT)
-        return True
-    except:
-        return False
</del><ins>+        &quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
+        try:
+                command = &quot;sudo port -t checksum dports/python/py-&quot; + \
+                                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
+                command = command.split()
+                subprocess.check_call(command, stderr=subprocess.STDOUT)
+                return True
+        except:
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_extract(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
-    try:
-        command = &quot;sudo port -t extract dports/python/py-&quot; + \
-                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
-        command = command.split()
-        subprocess.check_call(command, stderr=subprocess.STDOUT)
-        return True
-    except:
-        return False
</del><ins>+        &quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
+        try:
+                command = &quot;sudo port -t extract dports/python/py-&quot; + \
+                                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
+                command = command.split()
+                subprocess.check_call(command, stderr=subprocess.STDOUT)
+                return True
+        except:
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_patch(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Patch phase implementation &quot;&quot;&quot;
-    try:
-        command = &quot;sudo port -t patch dports/python/py-&quot; + \
-                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
-        command = command.split()
-        subprocess.check_call(command, stderr=subprocess.STDOUT)
-        return True
-    except:
-        return False
</del><ins>+        &quot;&quot;&quot; Patch phase implementation &quot;&quot;&quot;
+        try:
+                command = &quot;sudo port -t patch dports/python/py-&quot; + \
+                                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
+                command = command.split()
+                subprocess.check_call(command, stderr=subprocess.STDOUT)
+                return True
+        except:
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_configure(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Configure phase implementation &quot;&quot;&quot;
-    try:
-        command = &quot;sudo port -t configure dports/python/py-&quot; + \
-                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
-        command = command.split()
-        subprocess.check_call(command, stderr=subprocess.STDOUT)
-        return True
-    except:
-        return False
</del><ins>+        &quot;&quot;&quot; Configure phase implementation &quot;&quot;&quot;
+        try:
+                command = &quot;sudo port -t configure dports/python/py-&quot; + \
+                                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
+                command = command.split()
+                subprocess.check_call(command, stderr=subprocess.STDOUT)
+                return True
+        except:
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_build(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Build phase implementation &quot;&quot;&quot;
-    try:
-        command = &quot;sudo port -t build dports/python/py-&quot; + \
-                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
-        command = command.split()
-        subprocess.check_call(command, stderr=subprocess.STDOUT)
-        return True
-    except:
-        return False
</del><ins>+        &quot;&quot;&quot; Build phase implementation &quot;&quot;&quot;
+        try:
+                command = &quot;sudo port -t build dports/python/py-&quot; + \
+                                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
+                command = command.split()
+                subprocess.check_call(command, stderr=subprocess.STDOUT)
+                return True
+        except:
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_destroot(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Destroot phase implementation &quot;&quot;&quot;
-    try:
-        command = &quot;sudo port -t destroot dports/python/py-&quot; + \
-                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
-        command = command.split()
-        subprocess.check_call(command, stderr=subprocess.STDOUT)
-        return True
-    except:
-        return False
</del><ins>+        &quot;&quot;&quot; Destroot phase implementation &quot;&quot;&quot;
+        try:
+                command = &quot;sudo port -t destroot dports/python/py-&quot; + \
+                                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
+                command = command.split()
+                subprocess.check_call(command, stderr=subprocess.STDOUT)
+                return True
+        except:
+                return False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def port_clean(name, portv='27'):
</span><del>-    &quot;&quot;&quot; Clean phase implementation &quot;&quot;&quot;
-    try:
-        command = &quot;sudo port -t clean dports/python/py-&quot; + \
-                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
-        command = command.split()
-        subprocess.check_call(command, stderr=subprocess.STDOUT)
-        return True
-    except:
-        return False
</del><ins>+        &quot;&quot;&quot; Clean phase implementation &quot;&quot;&quot;
+        try:
+                command = &quot;sudo port -t clean dports/python/py-&quot; + \
+                                  name + &quot; subport=py&quot; + portv + &quot;-&quot; + name
+                command = command.split()
+                subprocess.check_call(command, stderr=subprocess.STDOUT)
+                return True
+        except:
+                return False
</ins><span class="cx"> 
</span><ins>+# class Package_portfile:
+#         def __init__(self, dict, filename, dict2):
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> def create_portfile(dict, file_name, dict2):
</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;
-    search_distfile(dict['name'], dict['version'])
-    print(&quot;Creating Portfile for pypi package &quot; + dict['name'] + &quot;...&quot;)
-    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 ')
-        file.write('-*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4\n')
-        file.write('# $Id$\n\n')
-        file.write('PortSystem          1.0\n')
-        file.write('PortGroup           python 1.0\n\n')
</del><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;
+        search_distfile(dict['name'], dict['version'])
+        print(&quot;Creating Portfile for pypi package &quot; + dict['name'] + &quot;...&quot;)
+        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 ')
+                file.write('-*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4\n')
+                file.write('# $Id$\n\n')
+                file.write('PortSystem          1.0\n')
+                file.write('PortGroup           python 1.0\n\n')
</ins><span class="cx"> 
</span><del>-        file.write('name                py-{0}\n'.format(dict['name']))
-        file.write('version             {0}\n'.format(dict['version']))
</del><ins>+                file.write('name                py-{0}\n'.format(dict['name']))
+                file.write('version             {0}\n'.format(dict['version']))
</ins><span class="cx"> 
</span><del>-        file.write('platforms           darwin\n')
-        license = dict['license']
-        license = search_license(license)
-        file.write('license             {0}\n'.format(license))
</del><ins>+                file.write('platforms           darwin\n')
+                license = dict['license']
+                license = search_license(license)
+                file.write('license             {0}\n'.format(license))
</ins><span class="cx"> 
</span><del>-        if dict['maintainer']:
-            maintainers = ' '.join(dict['maintainer'])
-            if not maintainers == &quot;UNKNOWN&quot;:
-                file.write('maintainers         {0}\n\n'.format(maintainers))
-            else:
-                file.write('maintainers         {0}\n\n'.format(
-                           os.getenv('maintainer', 'nomaintainer')))
-        else:
-            print(&quot;No maintainers found...&quot;)
-            print(&quot;Looking for maintainers in environment variables...&quot;)
-            file.write('maintainers         {0}\n\n'.format(
-                       os.getenv('maintainer', 'nomaintainer')))
</del><ins>+                if dict['maintainer']:
+                        maintainers = ' '.join(dict['maintainer'])
+                        if not maintainers == &quot;UNKNOWN&quot;:
+                                file.write('maintainers         {0}\n\n'.format(maintainers))
+                        else:
+                                file.write('maintainers         {0}\n\n'.format(
+                                                   os.getenv('maintainer', 'nomaintainer')))
+                else:
+                        print(&quot;No maintainers found...&quot;)
+                        print(&quot;Looking for maintainers in environment variables...&quot;)
+                        file.write('maintainers         {0}\n\n'.format(
+                                           os.getenv('maintainer', 'nomaintainer')))
</ins><span class="cx"> 
</span><del>-        summary = dict['summary']
-        if summary:
-            summary = re.sub(r'[\[\]\{\}\;\:\$\t\&quot;\'\`\=(--)]+',
-                             ' ', summary)
-            summary = re.sub(r'\s(\s)+', ' ', summary)
-            summary = summary.encode('utf-8')
-            summary = filter(lambda x: x in string.printable, summary)
-            sum_lines = textwrap.wrap(summary)
-            file.write('description         ')
-            for sum_line in sum_lines:
-                if sum_line:
-                    if not sum_lines.index(sum_line) == 0:
-                        file.write('                    ')
-                    if sum_line == sum_lines[-1]:
-                        file.write(&quot;{0}\n&quot;.format(sum_line))
-                    else:
-                        file.write(&quot;{0} \\\n&quot;.format(sum_line))
-        else:
-            file.write('description         None\n\n')
-#        description = dict['description']
-#        if description:
-#            description = description.encode('utf-8')
-#            description = filter(lambda x: x in string.printable, description)
-#            description = re.sub(r'[\[\]\{\}\;\:\$\t\&quot;\'\`\=(--)]+',
-#                                 ' ', description)
-#            description = re.sub(r'\s(\s)+', ' ', description)
-#            lines = textwrap.wrap(description, width=70)
-#            file.write('long_description    ')
-#            for line in lines:
-#                if line and lines.index(line) &lt; 4:
-#                    if not lines.index(line) == 0:
-#                        file.write('                    ')
-#                    if lines.index(line) &gt;= 3:
-#                        file.write(&quot;{0}...\n&quot;.format(line))
-#                    elif line == lines[-1]:
-#                        file.write(&quot;{0}\n&quot;.format(line))
-#                    else:
-#                        file.write(&quot;{0} \\\n&quot;.format(line))
-#        else:
-#            file.write('long_description    ${description}\n\n')
-        file.write('long_description    ${description}\n\n')
-        home_page = dict['home_page']
</del><ins>+                summary = dict['summary']
+                if summary:
+                        summary = re.sub(r'[\[\]\{\}\;\:\$\t\&quot;\'\`\=(--)]+',
+                                                         ' ', summary)
+                        summary = re.sub(r'\s(\s)+', ' ', summary)
+                        summary = summary.encode('utf-8')
+                        summary = filter(lambda x: x in string.printable, summary)
+                        sum_lines = textwrap.wrap(summary)
+                        file.write('description         ')
+                        for sum_line in sum_lines:
+                                if sum_line:
+                                        if not sum_lines.index(sum_line) == 0:
+                                                file.write('                    ')
+                                        if sum_line == sum_lines[-1]:
+                                                file.write(&quot;{0}\n&quot;.format(sum_line))
+                                        else:
+                                                file.write(&quot;{0} \\\n&quot;.format(sum_line))
+                else:
+                        file.write('description         None\n\n')
</ins><span class="cx"> 
</span><del>-        if home_page and not home_page == 'UNKNOWN':
-            file.write('homepage            {0}\n'.format(home_page))
-        else:
-            print(&quot;No homepage found...&quot;)
-            print(&quot;Looking for homepage in environment variables...&quot;)
-            file.write('homepage            {0}\n'.format(
-                       os.getenv('home_page', '')))
</del><ins>+                file.write('long_description    ${description}\n\n')
+                home_page = dict['home_page']
</ins><span class="cx"> 
</span><del>-#        for item in dict2:
-#            if item['python_version'] == 'source':
-#                master_var = item['url']
-#                break
-#        print master_var
-#        master_site = '/'.join(master_var.split('/')[0:-1])
-#        print master_site
-#        sys.exit(1)
</del><ins>+                if home_page and not home_page == 'UNKNOWN':
+                        file.write('homepage            {0}\n'.format(home_page))
+                else:
+                        print(&quot;No homepage found...&quot;)
+                        print(&quot;Looking for homepage in environment variables...&quot;)
+                        file.write('homepage            {0}\n'.format(
+                                           os.getenv('home_page', '')))
</ins><span class="cx"> 
</span><del>-        try:
-                # print dict2
-                # print dict2['url']
-                for item in dict2:
-                    if item['python_version'] == 'source':
-                        master_var = item['url']
-                        break
-#                print master_var
-                master_site = '/'.join(master_var.split('/')[0:-1])
-                ext = master_var.split('/')[-1].split('.')[-1]
-                if ext == 'zip':
-                    zip_set = True
-                else:
-                    zip_set = False
-#                print master_site
-        except:
-            if dict['release_url']:
-                master_site = dict['release_url']
-#                print master_site
-            else:
-                print(&quot;No master site found...&quot;)
-                print(&quot;Looking for master site in environment variables...&quot;)
-                master_site = os.getenv('master_site', '')
-        if master_site:
-            file.write('master_sites        {0}\n'.format(master_site))
-            master_site_exists = True
-        else:
-            master_site_exists = False
</del><ins>+                try:
+                        for item in dict2:
+                                if item['python_version'] == 'source':
+                                        master_var = item['url']
+                                        break
</ins><span class="cx"> 
</span><del>-        if zip_set:
-            file.write('use_zip             yes\n')
-            file.write('extract.mkdir       yes\n')
</del><ins>+                        if master_var:
+                                master_site = '/'.join(master_var.split('/')[0:-1])
+                                ext = master_var.split('/')[-1].split('.')[-1]
+                                if ext == 'zip':
+                                        zip_set = True
+                                else:
+                                        zip_set = False
+                except:
+                        if dict['release_url']:
+                                master_site = dict['release_url']
+                                zip_set = False
+                        else:
+                                print(&quot;No master site found...&quot;)
+                                print(&quot;Looking for master site in environment variables...&quot;)
+                                master_site = os.getenv('master_site', '')
+                                zip_set = False
</ins><span class="cx"> 
</span><del>-        file.write('distname            {0}-{1}\n\n'.format(
-                   dict['name'], dict['version']))
</del><ins>+                if master_site:
+                        file.write('master_sites        {0}\n'.format(master_site))
+                        master_site_exists = True
+                else:
+                        master_site_exists = False
</ins><span class="cx"> 
</span><del>-        print(&quot;Attempting to generate checksums for &quot; + dict['name'] + &quot;...&quot;)
-        checksums_values = checksums(dict['name'], dict['version'])
-        if checksums_values:
-            file.write('checksums           rmd160  {0} \\\n'.format(
-                       checksums_values[0]))
-            file.write('                    sha256  {0}\n\n'.format(
-                       checksums_values[1]))
</del><ins>+                if zip_set:
+                        file.write('use_zip             yes\n')
+                        file.write('extract.mkdir       yes\n')
</ins><span class="cx"> 
</span><del>-        python_vers = dict['requires_python']
-        if python_vers:
-            file.write('python.versions     25 26 27 {0}\n\n'.format(
-                       dict['requires_python']))
-        else:
-            file.write('python.versions     25 26 27 32 33 34\n\n')
</del><ins>+                file.write('distname            {0}-{1}\n\n'.format(
+                                   dict['name'], dict['version']))
</ins><span class="cx"> 
</span><del>-        print(&quot;Finding dependencies...&quot;)
-        file.write('if {${name} ne ${subport}} {\n')
-        file.write('    depends_build-append \\\n')
-        file.write('                        ' +
-                   'port:py${python.version}-setuptools\n')
-        deps = dependencies(dict['name'], dict['version'], True)
-        if deps:
-            for i, dep in enumerate(deps):
-                dep = dep.split('&gt;')[0].split('=')[0]
-                dep = dep.replace('[', '').replace(']', '')
-                deps[i] = dep
-#            print deps
-            for dep in deps:
-                if dep in ['setuptools', '', '\n']:
-                    while deps.count(dep) &gt; 0:
-                        deps.remove(dep)
</del><ins>+                print(&quot;Attempting to generate checksums for &quot; + dict['name'] + &quot;...&quot;)
+                checksums_values = checksums(dict['name'], dict['version'])
+                if checksums_values:
+                        file.write('checksums           rmd160  {0} \\\n'.format(
+                                           checksums_values[0]))
+                        file.write('                    sha256  {0}\n\n'.format(
+                                           checksums_values[1]))
</ins><span class="cx"> 
</span><ins>+                python_vers = dict['requires_python']
+                if python_vers:
+                        file.write('python.versions     25 26 27 {0}\n\n'.format(
+                                           dict['requires_python']))
+                else:
+                        file.write('python.versions     25 26 27 32 33 34\n\n')
</ins><span class="cx"> 
</span><del>-#            for dep in deps:
-#                dep = dep.split('&gt;')[0].split('=')[0]
-#                dep = dep.replace('[','').replace(']','')
-#            for item in ['setuptools', '', '\n']:
-#                while deps.count(item) &gt; 0:
-#                    deps.remove(item)
-            if len(deps) &gt; 0:
-                file.write('    depends_run-append \\\n')
-#                file.write('                        ' +
-#                           'port:py${python.version}-setuptools')
-#                file.write(&quot; \\\n&quot;)
-                for dep in deps[:-1]:
-                    file.write('                        ' +
-                               'port:py${python.version}-' +
-                               dep + ' \\\n')
-                else:
-                    file.write('                        ' +
-                               'port:py${python.version}-' +
-                               deps[-1] + '\n')
-            else:
-                file.write(&quot;\n&quot;)
-        file.write('\n')
-        file.write('    livecheck.type      none\n')
-        if master_site_exists:
-            file.write('} else {\n')
-            file.write('    livecheck.type      regex\n')
-            file.write('    livecheck.url       ${master_sites}\n')
-            file.write('}\n')
-        else:
-            file.write('}\n')
-    print(&quot;Searching for existent port...&quot;)
-    port_exists = search_port(dict['name'])
-    if port_exists:
-        print(&quot;Creating diff...&quot;)
-        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))+&quot;\n&quot;)
-#        with open(diff_file) as diff:
-#            print diff.read()
-        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;)
-    else:
-        print(&quot;No port found.&quot;)
</del><ins>+                print(&quot;Finding dependencies...&quot;)
+                file.write('if {${name} ne ${subport}} {\n')
+                file.write('    depends_build-append \\\n')
+                file.write('                        ' +
+                                   'port:py${python.version}-setuptools\n')
+                deps = dependencies(dict['name'], dict['version'], True)
+                if deps:
+                        for i, dep in enumerate(deps):
+                                dep = dep.split('&gt;')[0].split('=')[0]
+                                dep = dep.replace('[', '').replace(']', '')
+                                deps[i] = dep
+                        for dep in deps:
+                                if dep in ['setuptools', '', '\n']:
+                                        while deps.count(dep) &gt; 0:
+                                                deps.remove(dep)
</ins><span class="cx"> 
</span><ins>+                        if len(deps) &gt; 0:
+                                file.write('    depends_run-append \\\n')
</ins><span class="cx"> 
</span><ins>+                                for dep in deps[:-1]:
+                                        file.write('                        ' +
+                                                           'port:py${python.version}-' +
+                                                           dep + ' \\\n')
+                                else:
+                                        file.write('                        ' +
+                                                           'port:py${python.version}-' +
+                                                           deps[-1] + '\n')
+                        else:
+                                file.write(&quot;\n&quot;)
+                file.write('\n')
+                file.write('    livecheck.type      none\n')
+                if master_site_exists:
+                        file.write('} else {\n')
+                        file.write('    livecheck.type      regex\n')
+                        file.write('    livecheck.url       ${master_sites}\n')
+                        file.write('}\n')
+                else:
+                        file.write('}\n')
+        print(&quot;Searching for existent port...&quot;)
+        port_exists = search_port(dict['name'])
+        if port_exists:
+                print(&quot;Creating diff...&quot;)
+                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))+&quot;\n&quot;)
+                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;)
+        else:
+                print(&quot;No port found.&quot;)
+
+
</ins><span class="cx"> def print_portfile(pkg_name, pkg_version=None):
</span><del>-    &quot;&quot;&quot; Creates the directories and other commands necessary
-    for a development environment &quot;&quot;&quot;
-    root_dir = os.path.abspath(&quot;./dports&quot;)
-    port_dir = os.path.join(root_dir, 'python')
-    home_dir = os.path.join(port_dir, 'py-'+pkg_name)
-    if not os.path.exists(root_dir):
-        os.makedirs(root_dir)
-        try:
-            command = 'portindex dports/'
-            command = command.split()
-            subprocess.call(command, stderr=subprocess.STDOUT)
-        except:
-            pass
-    if not os.path.exists(port_dir):
-        os.makedirs(port_dir)
-    if not os.path.exists(home_dir):
-        os.makedirs(home_dir)
</del><ins>+        &quot;&quot;&quot; Creates the directories and other commands necessary
+        for a development environment &quot;&quot;&quot;
+        root_dir = os.path.abspath(&quot;./dports&quot;)
+        port_dir = os.path.join(root_dir, 'python')
+        home_dir = os.path.join(port_dir, 'py-'+pkg_name)
+        if not os.path.exists(root_dir):
+                os.makedirs(root_dir)
+                try:
+                        command = 'portindex dports/'
+                        command = command.split()
+                        subprocess.call(command, stderr=subprocess.STDOUT)
+                except:
+                        pass
+        if not os.path.exists(port_dir):
+                os.makedirs(port_dir)
+        if not os.path.exists(home_dir):
+                os.makedirs(home_dir)
</ins><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><del>-    dict = client.release_data(pkg_name, pkg_version)
-    dict2 = client.release_urls(pkg_name, pkg_version)
-    if dict and dict2:
-        print(&quot;Data fetched successfully.&quot;)
-    elif dict:
-        print(&quot;Release Data fetched successfully.&quot;)
-    elif dict2:
-        print(&quot;Release url fetched successfully.&quot;)
-    else:
-        print(&quot;No data found.&quot;)
</del><ins>+        dict = client.release_data(pkg_name, pkg_version)
+        dict2 = client.release_urls(pkg_name, pkg_version)
+        if dict and dict2:
+                print(&quot;Data fetched successfully.&quot;)
+        elif dict:
+                print(&quot;Release Data fetched successfully.&quot;)
+        elif dict2:
+                print(&quot;Release url fetched successfully.&quot;)
+        else:
+                print(&quot;No data found.&quot;)
</ins><span class="cx"> 
</span><del>-    file_name = os.path.join(home_dir, &quot;Portfile&quot;)
-    create_portfile(dict, file_name, dict2)
-    print(&quot;SUCCESS\n&quot;)
</del><ins>+        file_name = os.path.join(home_dir, &quot;Portfile&quot;)
+        create_portfile(dict, file_name, dict2)
+        print(&quot;SUCCESS\n&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def main(argv):
</span><del>-    &quot;&quot;&quot; Main function - Argument Parser &quot;&quot;&quot;
-    parser = argparse.ArgumentParser(description=&quot;Pypi2Port Tester&quot;)
</del><ins>+        &quot;&quot;&quot; Main function - Argument Parser &quot;&quot;&quot;
+        parser = argparse.ArgumentParser(description=&quot;Pypi2Port Tester&quot;)
</ins><span class="cx"> # Calls list_all() which lists al available python packages
</span><del>-    parser.add_argument('-l', '--list', action='store_true', dest='list',
-                        default=False, required=False,
-                        help='List all packages')
</del><ins>+        parser.add_argument('-l', '--list', action='store_true', dest='list',
+                                                default=False, required=False,
+                                                help='List all packages')
</ins><span class="cx"> # Calls search with the package_name
</span><del>-    parser.add_argument('-s', '--search', action='store', type=str,
-                        dest='packages_search', nargs='*', required=False,
-                        help='Search for a package')
</del><ins>+        parser.add_argument('-s', '--search', action='store', type=str,
+                                                dest='packages_search', nargs='*', required=False,
+                                                help='Search for a package')
</ins><span class="cx"> # Calls release_data with package_name and package_version
</span><del>-    parser.add_argument('-d', '--data', action='store',
-                        dest='packages_data', nargs='*', type=str,
-                        help='Releases data for a package')
</del><ins>+        parser.add_argument('-d', '--data', action='store',
+                                                dest='packages_data', nargs='*', type=str,
+                                                help='Releases data for a package')
</ins><span class="cx"> # Calls fetch_url with the various package_releases
</span><del>-    parser.add_argument('-f', '--fetch', action='store', type=str,
-                        dest='package_fetch', nargs='*', required=False,
-                        help='Fetches distfiles for a package')
</del><ins>+        parser.add_argument('-f', '--fetch', action='store', type=str,
+                                                dest='package_fetch', nargs='*', required=False,
+                                                help='Fetches distfiles for a package')
</ins><span class="cx"> # Calls print_portfile with the release data available
</span><del>-    parser.add_argument('-p', '--portfile', action='store', type=str,
-                        dest='package_portfile', nargs='*', required=False,
-                        help='Prints the portfile for a package')
</del><ins>+        parser.add_argument('-p', '--portfile', action='store', type=str,
+                                                dest='package_portfile', nargs='*', required=False,
+                                                help='Prints the portfile for a package')
</ins><span class="cx"> # Calls port_testing
</span><del>-    parser.add_argument('-t', '--test', action='store', type=str,
-                        dest='package_test', nargs='*', required=False,
-                        help='Tests the portfile for various phase tests')
-    options = parser.parse_args()
</del><ins>+        parser.add_argument('-t', '--test', action='store', type=str,
+                                                dest='package_test', nargs='*', required=False,
+                                                help='Tests the portfile for various phase tests')
+        options = parser.parse_args()
</ins><span class="cx"> 
</span><del>-    if options.list:
-        list_all()
-        return
</del><ins>+        if options.list:
+                list_all()
+                return
</ins><span class="cx"> 
</span><del>-    if options.packages_search:
-        for pkg_name in options.packages_search:
-            search(pkg_name)
-        return
</del><ins>+        if options.packages_search:
+                for pkg_name in options.packages_search:
+                        search(pkg_name)
+                return
</ins><span class="cx"> 
</span><del>-    if options.packages_data:
-        pkg_name = options.packages_data[0]
-        if len(options.packages_data) &gt; 1:
-            pkg_version = options.packages_data[1]
-            release_data(pkg_name, pkg_version)
-        else:
-            if client.package_releases(pkg_name):
-                pkg_version = client.package_releases(pkg_name)[0]
-                release_data(pkg_name, pkg_version)
-            else:
-                print(&quot;No release found\n&quot;)
-        return
</del><ins>+        if options.packages_data:
+                pkg_name = options.packages_data[0]
+                if len(options.packages_data) &gt; 1:
+                        pkg_version = options.packages_data[1]
+                        release_data(pkg_name, pkg_version)
+                else:
+                        if client.package_releases(pkg_name):
+                                pkg_version = client.package_releases(pkg_name)[0]
+                                release_data(pkg_name, pkg_version)
+                        else:
+                                print(&quot;No release found\n&quot;)
+                return
</ins><span class="cx"> 
</span><del>-    if options.package_fetch:
-        pkg_name = options.package_fetch[0]
-        if len(options.package_fetch) &gt; 1:
-            pkg_version = options.package_fetch[1]
-            fetch_url(pkg_name, pkg_version)
-        else:
-            releases = client.package_releases(pkg_name)
-            if releases:
-                pkg_version = releases[0]
-                fetch_url(pkg_name, pkg_version)
-            else:
-                print(&quot;No release found\n&quot;)
-        return
</del><ins>+        if options.package_fetch:
+                pkg_name = options.package_fetch[0]
+                if len(options.package_fetch) &gt; 1:
+                        pkg_version = options.package_fetch[1]
+                        fetch_url(pkg_name, pkg_version)
+                else:
+                        releases = client.package_releases(pkg_name)
+                        if releases:
+                                pkg_version = releases[0]
+                                fetch_url(pkg_name, pkg_version)
+                        else:
+                                print(&quot;No release found\n&quot;)
+                return
</ins><span class="cx"> 
</span><del>-    if options.package_portfile:
-        pkg_name = options.package_portfile[0]
-        if len(options.package_portfile) &gt; 1:
-            pkg_version = options.package_portfile[1]
-            print_portfile(pkg_name, pkg_version)
-        else:
-            vers = client.package_releases(pkg_name)
-            if vers:
-                pkg_version = vers[0]
-                print_portfile(pkg_name, pkg_version)
-            else:
-                print(&quot;No release found\n&quot;)
-        return
</del><ins>+        if options.package_portfile:
+                pkg_name = options.package_portfile[0]
+                if len(options.package_portfile) &gt; 1:
+                        pkg_version = options.package_portfile[1]
+                        print_portfile(pkg_name, pkg_version)
+                else:
+                        vers = client.package_releases(pkg_name)
+                        if vers:
+                                pkg_version = vers[0]
+                                print_portfile(pkg_name, pkg_version)
+                        else:
+                                print(&quot;No release found\n&quot;)
+                return
</ins><span class="cx"> 
</span><del>-    if options.package_test:
-        if len(options.package_test) &gt; 0:
-            pkg_name = options.package_test[0]
-            port_testing(pkg_name)
-        else:
-            print(&quot;No package name specified\n&quot;)
-        return
</del><ins>+        if options.package_test:
+                if len(options.package_test) &gt; 0:
+                        pkg_name = options.package_test[0]
+                        port_testing(pkg_name)
+                else:
+                        print(&quot;No package name specified\n&quot;)
+                return
</ins><span class="cx"> 
</span><del>-    parser.print_help()
-    parser.error(&quot;No input specified&quot;)
</del><ins>+        parser.print_help()
+        parser.error(&quot;No input specified&quot;)
</ins><span class="cx"> 
</span><span class="cx"> if __name__ == &quot;__main__&quot;:
</span><del>-    main(sys.argv[1:])
</del><ins>+        main(sys.argv[1:])
</ins></span></pre>
</div>
</div>

</body>
</html>