<!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>[123708] branches/gsoc14-pip2port/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/123708">123708</a></dd>
<dt>Author</dt> <dd>gaurav@macports.org</dd>
<dt>Date</dt> <dd>2014-08-13 02:57:42 -0700 (Wed, 13 Aug 2014)</dd>
</dl>

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesgsoc14pip2portpypi2port">branches/gsoc14-pip2port/pypi2port</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesgsoc14pip2portpypi2port"></a>
<div class="modfile"><h4>Modified: branches/gsoc14-pip2port/pypi2port (123707 => 123708)</h4>
<pre class="diff"><span>
<span class="info">--- branches/gsoc14-pip2port/pypi2port        2014-08-13 09:57:11 UTC (rev 123707)
+++ branches/gsoc14-pip2port/pypi2port        2014-08-13 09:57:42 UTC (rev 123708)
</span><span class="lines">@@ -32,12 +32,18 @@
</span><span class="cx"> client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Lists all packages available in pypi database &quot;&quot;&quot;
+
+
</ins><span class="cx"> def list_all():
</span><span class="cx">     list_packages = client.list_packages()
</span><span class="cx">     for package in list_packages:
</span><span class="cx">         print package
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Searches for a particular package by the name classifier &quot;&quot;&quot;
+
+
</ins><span class="cx"> def search(pkg_name):
</span><span class="cx">     values = client.search({'name': pkg_name})
</span><span class="cx">     for value in values:
</span><span class="lines">@@ -45,6 +51,10 @@
</span><span class="cx">             print key, '--&gt;', value[key]
</span><span class="cx"> 
</span><span class="cx"> 
</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"> def release_data(pkg_name, pkg_version):
</span><span class="cx">     if pkg_version:
</span><span class="cx">         values = client.release_data(pkg_name, pkg_version)
</span><span class="lines">@@ -58,6 +68,9 @@
</span><span class="cx">     return
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Fetches the distfile for a particular package name and release_url &quot;&quot;&quot;
+
+
</ins><span class="cx"> def fetch(pkg_name, dict):
</span><span class="cx">     print &quot;Fetching distfiles...&quot;
</span><span class="cx">     checksum_md5 = dict['md5_digest']
</span><span class="lines">@@ -118,6 +131,10 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</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"> def fetch_url(pkg_name, pkg_version, checksum=False, deps=False):
</span><span class="cx">     values = client.release_urls(pkg_name, pkg_version)
</span><span class="cx">     if checksum:
</span><span class="lines">@@ -129,6 +146,10 @@
</span><span class="cx">             return fetch(pkg_name, value)
</span><span class="cx"> 
</span><span class="cx"> 
</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"> def dependencies(pkg_name, pkg_version, deps=False):
</span><span class="cx">     flag = False
</span><span class="cx">     if not deps:
</span><span class="lines">@@ -175,6 +196,9 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Creates a diff file for an existent port &quot;&quot;&quot;
+
+
</ins><span class="cx"> def create_diff(old_file, new_file, diff_file):
</span><span class="cx">     with open(old_file) as f:
</span><span class="cx">         a = f.readlines()
</span><span class="lines">@@ -191,6 +215,9 @@
</span><span class="cx">             pass
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Searches for an existent port by its name &quot;&quot;&quot;
+
+
</ins><span class="cx"> def search_port(name):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;port file name:^py-&quot; + name + &quot;$&quot;
</span><span class="lines">@@ -202,6 +229,10 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</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"> def checksums(pkg_name, pkg_version):
</span><span class="cx">     flag = False
</span><span class="cx">     print &quot;Attempting to fetch distfiles...&quot;
</span><span class="lines">@@ -237,6 +268,9 @@
</span><span class="cx">             return
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Searches if the distfile listed is present or not &quot;&quot;&quot;
+
+
</ins><span class="cx"> def search_distfile(name, version):
</span><span class="cx">     try:
</span><span class="cx">         url = client.release_urls(name, version)[0]['url']
</span><span class="lines">@@ -249,6 +283,10 @@
</span><span class="cx">         sys.exit(0)
</span><span class="cx"> 
</span><span class="cx"> 
</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"> def search_license(license):
</span><span class="cx">     license = license.lower()
</span><span class="cx">     patterns = ['.*mit.*', '.*apache.*2', '.*apache.*', '.*bsd.*', '.*agpl.*3',
</span><span class="lines">@@ -268,6 +306,9 @@
</span><span class="cx">             return licenses[i]
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Port Testing function for various phase implementations &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_testing(name, portv='27'):
</span><span class="cx">     euid = os.geteuid()
</span><span class="cx">     if euid:
</span><span class="lines">@@ -292,6 +333,9 @@
</span><span class="cx">             os.execlpe('sudo', *args)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Fetch phase implementation &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_fetch(name, portv='27'):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t fetch dports/python/py-&quot; + \
</span><span class="lines">@@ -303,6 +347,9 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_checksum(name, portv='27'):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t checksum dports/python/py-&quot; + \
</span><span class="lines">@@ -314,6 +361,9 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Checksum phase implementation &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_extract(name, portv='27'):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t extract dports/python/py-&quot; + \
</span><span class="lines">@@ -325,6 +375,9 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Patch phase implementation &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_patch(name, portv='27'):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t patch dports/python/py-&quot; + \
</span><span class="lines">@@ -336,6 +389,9 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Configure phase implementation &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_configure(name, portv='27'):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t configure dports/python/py-&quot; + \
</span><span class="lines">@@ -347,6 +403,9 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Build phase implementation &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_build(name, portv='27'):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t build dports/python/py-&quot; + \
</span><span class="lines">@@ -358,6 +417,9 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Destroot phase implementation &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_destroot(name, portv='27'):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t destroot dports/python/py-&quot; + \
</span><span class="lines">@@ -369,6 +431,9 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Clean phase implementation &quot;&quot;&quot;
+
+
</ins><span class="cx"> def port_clean(name, portv='27'):
</span><span class="cx">     try:
</span><span class="cx">         command = &quot;sudo port -t clean dports/python/py-&quot; + \
</span><span class="lines">@@ -380,6 +445,10 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</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"> def create_portfile(dict, file_name, dict2):
</span><span class="cx">     search_distfile(dict['name'], dict['version'])
</span><span class="cx">     print &quot;Creating Portfile for pypi package &quot; + dict['name'] + &quot;...&quot;
</span><span class="lines">@@ -546,6 +615,10 @@
</span><span class="cx">         print &quot;No port found.&quot;
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Creates the directories and other commands necessary
+    for a development environment &quot;&quot;&quot;
+
+
</ins><span class="cx"> def print_portfile(pkg_name, pkg_version=None):
</span><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="lines">@@ -555,7 +628,7 @@
</span><span class="cx">         try:
</span><span class="cx">             command = 'portindex dports/'
</span><span class="cx">             command = command.split()
</span><del>-            subprocess.call(command,stderr=subprocess.STDOUT)
</del><ins>+            subprocess.call(command, stderr=subprocess.STDOUT)
</ins><span class="cx">         except:
</span><span class="cx">             pass
</span><span class="cx">     if not os.path.exists(port_dir):
</span><span class="lines">@@ -581,6 +654,9 @@
</span><span class="cx">     print &quot;SUCCESS\n&quot;
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot; Main function - Argument Parser &quot;&quot;&quot;
+
+
</ins><span class="cx"> def main(argv):
</span><span class="cx">     parser = argparse.ArgumentParser(description=&quot;Pypi2Port Tester&quot;)
</span><span class="cx">     parser.add_argument('-l', '--list', action='store_true', dest='list',
</span></span></pre>
</div>
</div>

</body>
</html>