<!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>[130430] users/gaurav/pypi2port/pypi2port.py</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/130430">130430</a></dd>
<dt>Author</dt> <dd>gaurav@macports.org</dd>
<dt>Date</dt> <dd>2014-12-30 04:11:05 -0800 (Tue, 30 Dec 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Added Class structure for Package Search and Removed unnecessary Comments</pre>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="usersgauravpypi2portpypi2portpy"></a>
<div class="modfile"><h4>Modified: users/gaurav/pypi2port/pypi2port.py (130429 => 130430)</h4>
<pre class="diff"><span>
<span class="info">--- users/gaurav/pypi2port/pypi2port.py        2014-12-30 10:17:40 UTC (rev 130429)
+++ users/gaurav/pypi2port/pypi2port.py        2014-12-30 12:11:05 UTC (rev 130430)
</span><span class="lines">@@ -31,12 +31,24 @@
</span><span class="cx">         print(package)
</span><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><span class="cx">     &quot;&quot;&quot; Searches for a particular package by the name classifier &quot;&quot;&quot;
</span><span class="cx">     values = client.search({'name': pkg_name})
</span><span class="cx">     for value in values:
</span><del>-        for key in value.keys():
-            print key, '--&gt;', value[key]
</del><ins>+        package = Package_Search(value['name'], value['summary'], value['version'])
+        print(package)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def release_data(pkg_name, pkg_version):
</span><span class="lines">@@ -119,7 +131,6 @@
</span><span class="cx">     on the basis of package_name and package_version &quot;&quot;&quot;
</span><span class="cx">     values = client.release_urls(pkg_name, pkg_version)
</span><span class="cx">     if checksum:
</span><del>-        # print values
</del><span class="cx">         for value in values:
</span><span class="cx">             if value['filename'].split('.')[-1] in ('gz', 'zip'):
</span><span class="cx">                 return fetch(pkg_name, value)
</span><span class="lines">@@ -445,27 +456,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']
-#        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')
</del><ins>+
</ins><span class="cx">         file.write('long_description    ${description}\n\n')
</span><span class="cx">         home_page = dict['home_page']
</span><span class="cx"> 
</span><span class="lines">@@ -477,34 +468,20 @@
</span><span class="cx">             file.write('homepage            {0}\n'.format(
</span><span class="cx">                        os.getenv('home_page', '')))
</span><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><span class="cx">         try:
</span><del>-                # print dict2
-                # print dict2['url']
</del><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="cx">                         break
</span><del>-#                print master_var
</del><span class="cx">                 master_site = '/'.join(master_var.split('/')[0:-1])
</span><span class="cx">                 ext = master_var.split('/')[-1].split('.')[-1]
</span><span class="cx">                 if ext == 'zip':
</span><span class="cx">                     zip_set = True
</span><span class="cx">                 else:
</span><span class="cx">                     zip_set = False
</span><del>-#                print master_site
</del><span class="cx">         except:
</span><span class="cx">             if dict['release_url']:
</span><span class="cx">                 master_site = dict['release_url']
</span><del>-#                print master_site
</del><span class="cx">             else:
</span><span class="cx">                 print(&quot;No master site found...&quot;)
</span><span class="cx">                 print(&quot;Looking for master site in environment variables...&quot;)
</span><span class="lines">@@ -548,24 +525,14 @@
</span><span class="cx">                 dep = dep.split('&gt;')[0].split('=')[0]
</span><span class="cx">                 dep = dep.replace('[', '').replace(']', '')
</span><span class="cx">                 deps[i] = dep
</span><del>-#            print deps
</del><span class="cx">             for dep in deps:
</span><span class="cx">                 if dep in ['setuptools', '', '\n']:
</span><span class="cx">                     while deps.count(dep) &gt; 0:
</span><span class="cx">                         deps.remove(dep)
</span><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)
</del><span class="cx">             if len(deps) &gt; 0:
</span><span class="cx">                 file.write('    depends_run-append \\\n')
</span><del>-#                file.write('                        ' +
-#                           'port:py${python.version}-setuptools')
-#                file.write(&quot; \\\n&quot;)
</del><ins>+
</ins><span class="cx">                 for dep in deps[:-1]:
</span><span class="cx">                     file.write('                        ' +
</span><span class="cx">                                'port:py${python.version}-' +
</span><span class="lines">@@ -594,8 +561,6 @@
</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><span class="cx">         print(str(os.path.abspath(diff_file))+&quot;\n&quot;)
</span><del>-#        with open(diff_file) as diff:
-#            print diff.read()
</del><span class="cx">         print(&quot;\nIf you want to open a new ticket. Please visit&quot;)
</span><span class="cx">         print(&quot;https://trac.macports.org/auth/login/?next=/newticket&quot;)
</span><span class="cx">         print(&quot;to open a new ticket after logging in with your credentials.&quot;)
</span></span></pre>
</div>
</div>

</body>
</html>