[122370] branches/gsoc14-pip2port
gaurav at macports.org
gaurav at macports.org
Mon Jul 21 10:39:21 PDT 2014
Revision: 122370
https://trac.macports.org/changeset/122370
Author: gaurav at macports.org
Date: 2014-07-21 10:39:21 -0700 (Mon, 21 Jul 2014)
Log Message:
-----------
Updated license.py with pixilla's changes (csv writer)
Modified Paths:
--------------
branches/gsoc14-pip2port/license.py
Property Changed:
----------------
branches/gsoc14-pip2port/
Property changes on: branches/gsoc14-pip2port
___________________________________________________________________
Modified: svn:ignore
- dports
sources
+ patch-license.py.diff
Modified: branches/gsoc14-pip2port/license.py
===================================================================
--- branches/gsoc14-pip2port/license.py 2014-07-21 17:30:44 UTC (rev 122369)
+++ branches/gsoc14-pip2port/license.py 2014-07-21 17:39:21 UTC (rev 122370)
@@ -3,9 +3,22 @@
exec python $0 ${1+"$@"}
"""
-import xmlrpclib
+import argparse
import sys
+import os
+import urllib2
+import hashlib
+import zipfile
+from progressbar import *
+try:
+ import xmlrpclib
+except ImportError:
+ import xmlrpc.client as xmlrpclib
+import textwrap
import string
+import shutil
+import re
+import csv
#import pdb
#from datetime import datetime
@@ -19,22 +32,46 @@
else:
end = 5000
-for package_name in list_packages:
- vers = client.package_releases(package_name)
- if vers:
- data = client.release_data(package_name,vers[0])
- if data:
-# pdb.set_trace()
- license = data['license']
- license = filter(lambda x: x in string.printable, license)
- print package_name,vers,license
+with open('license_list.csv', 'wb') as csvfile:
+ licensewriter = csv.writer(csvfile, delimiter=',',
+ quotechar='"', quoting=csv.QUOTE_MINIMAL)
+ licensewriter.writerow(['license', 'license_mapped', 'package'])
+ for package_name in list_packages:
+ license_mapped = ''
+ vers = client.package_releases(package_name)
+ if vers:
+ data = client.release_data(package_name,vers[0])
+ if data:
+ # pdb.set_trace()
+ license = data['license']
+ try:
+ license = license.decode('utf-8','ignore')
+ license = license.encode('utf-8','ignore')
+ except:
+ license = 'UNMAPPED-ENCODE-ERROR'
+ license = filter(lambda x: x in string.printable, license)
+ license = re.sub(r'[\[\]\{\}\;\:\$\t\"\'\`\=(--)]+', ' ', license)
+ license = re.sub(r'\s(\s)+', ' ', license)
+ license = re.sub(r'([A-Z]*)([a-z]*)([\s]*v*)([0-9]\.*[0-9]*)',
+ r'\1\2-\4', license)
+ license = re.sub(r'v(-*)([0-9])', r'\1\2', license)
+ if re.search('.*MIT.*', license):
+ license_mapped = license_mapped+' MIT'
+ if re.search('.*apache.*2.*', license):
+ license_mapped = license_mapped+' Apache-2'
+ if re.search('.*GPL.?3.*', license):
+ license_mapped = license_mapped+' GPL-3'
+ if license.count('\n') > 0 or license.count('\r') > 0:
+ license = 'UNMAPPED-MULTI-LINE'
+ else:
+ license = 'UNMAPPED-NO-DATA'
else:
- print package_name,vers
- else:
- print package_name
- count = count + 1
- if count == end:
- break;
+ license = 'UNMAPPED-NO-VERSIONS'
+ print license,',',license_mapped,',',package_name
+ licensewriter.writerow([license, license_mapped, package_name])
+ count = count + 1
+ if count == end:
+ break;
#print "TIME TAKEN =",datetime.now()-startTime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140721/22d87408/attachment.html>
More information about the macports-changes
mailing list