[122369] branches/gsoc14-pip2port/pypi2port
gaurav at macports.org
gaurav at macports.org
Mon Jul 21 10:30:44 PDT 2014
Revision: 122369
https://trac.macports.org/changeset/122369
Author: gaurav at macports.org
Date: 2014-07-21 10:30:44 -0700 (Mon, 21 Jul 2014)
Log Message:
-----------
Updated executable
Modified Paths:
--------------
branches/gsoc14-pip2port/pypi2port
Modified: branches/gsoc14-pip2port/pypi2port
===================================================================
--- branches/gsoc14-pip2port/pypi2port 2014-07-21 17:30:18 UTC (rev 122368)
+++ branches/gsoc14-pip2port/pypi2port 2014-07-21 17:30:44 UTC (rev 122369)
@@ -23,6 +23,7 @@
import shutil
import re
import difflib
+import subprocess
client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
@@ -176,13 +177,10 @@
print ""
return False
-def create_diff(name, port):
- diff_file = './dports/python/'+name+'/'+name+'.diff'
- fromfile = './dports/python/'+name+'/Portfile'
- tofile = '/opt/mports/trunk/dports/python/'+port+'/Portfile'
- a = open(fromfile).readlines()
- b = open(tofile).readlines()
- diff_string = difflib.ndiff(a,b)
+def create_diff(old_file, new_file, diff_file):
+ a = open(old_file).readlines()
+ b = open(new_file).readlines()
+ diff_string = difflib.unified_diff(a,b,"Portfile.orig","Portfile")
with open(diff_file, 'w') as d:
try:
while 1:
@@ -192,17 +190,12 @@
def search_port(name):
- for port in os.listdir('/opt/mports/trunk/dports/python'):
- if '-' in port:
- port = port.split('-')
- prefix = port[0]
- port = ''.join(port[1:])
- if port == name:
- if prefix:
- port = prefix+'-'+port
- create_diff(name, port)
- return True
- return False
+ try:
+ command = "port file name:^py-" + name + "$"
+ existing_portfile = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT).strip()
+ return existing_portfile
+ except Exception, e:
+ return False
def checksums(pkg_name, pkg_version):
flag = False
@@ -362,10 +355,14 @@
file.write('}\n')
else:
file.write('}\n')
+ port_exists = search_port(dict['name'])
+ if port_exists:
+ old_file = port_exists
+ new_file = './dports/python/'+dict['name']+'/Portfile'
+ diff_file = './dports/python/'+dict['name']+'/patch.Portfile.diff'
+ create_diff(old_file, new_file, diff_file)
- search_port(dict['name'])
-
def print_portfile(pkg_name, pkg_version=None):
print "\n"
root_dir = os.path.abspath("./dports")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140721/3ca8bffb/attachment.html>
More information about the macports-changes
mailing list