[122983] branches/gsoc14-pip2port/pypi2port.py
gaurav at macports.org
gaurav at macports.org
Sat Aug 2 15:50:36 PDT 2014
Revision: 122983
https://trac.macports.org/changeset/122983
Author: gaurav at macports.org
Date: 2014-08-02 15:50:36 -0700 (Sat, 02 Aug 2014)
Log Message:
-----------
Support for ditfile checking before creating portfile
Modified Paths:
--------------
branches/gsoc14-pip2port/pypi2port.py
Modified: branches/gsoc14-pip2port/pypi2port.py
===================================================================
--- branches/gsoc14-pip2port/pypi2port.py 2014-08-02 22:06:17 UTC (rev 122982)
+++ branches/gsoc14-pip2port/pypi2port.py 2014-08-02 22:50:36 UTC (rev 122983)
@@ -24,6 +24,7 @@
import re
import difflib
import subprocess
+import requests
client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
@@ -223,8 +224,20 @@
print "Error\n"
return
+def search_distfile(name,version):
+ try:
+ url = client.release_urls(name,version)[0]['url']
+ r = requests.get(url, verify=False)
+ if not r.status_code == 200:
+ raise Error('No distfile')
+ except:
+ print "No distfile found"
+ print "Please set a DISTFILE env var before generating the portfile"
+ sys.exit(0)
def create_portfile(dict, file_name, dict2):
+ search_distfile(dict['name'],dict['version'])
+ print "Creating Portfile for pypi package "+dict['name']+"..."
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 ')
@@ -409,7 +422,6 @@
print "No data found."
file_name = os.path.join(home_dir, "Portfile")
- print "Creating Portfile for pypi package "+pkg_name+"..."
create_portfile(dict, file_name, dict2)
print "SUCCESS\n"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140802/fedc0f06/attachment.html>
More information about the macports-changes
mailing list