diff options
author | Auke Booij (tulcod) <auke@tulcod.com> | 2010-07-15 09:50:59 +0200 |
---|---|---|
committer | Auke Booij (tulcod) <auke@tulcod.com> | 2010-07-15 10:21:53 +0200 |
commit | 62238b0f1901fdb0602254da581e435515e04e9e (patch) | |
tree | af9de8d5e3a6c90125f6eae4fee3433d7720e877 | |
parent | Set HOMEPAGE to remote repository URI (diff) | |
download | g-cran-62238b0f1901fdb0602254da581e435515e04e9e.tar.gz g-cran-62238b0f1901fdb0602254da581e435515e04e9e.tar.bz2 g-cran-62238b0f1901fdb0602254da581e435515e04e9e.zip |
Adding support for CRAN's serialized package database
-rw-r--r-- | g_cran/convert_packages_rds.R | 5 | ||||
-rw-r--r-- | g_cran/cran_read.py | 13 | ||||
-rw-r--r-- | g_cran/g_cran.py | 11 | ||||
-rw-r--r-- | setup.py | 2 |
4 files changed, 26 insertions, 5 deletions
diff --git a/g_cran/convert_packages_rds.R b/g_cran/convert_packages_rds.R new file mode 100644 index 0000000..61c3494 --- /dev/null +++ b/g_cran/convert_packages_rds.R @@ -0,0 +1,5 @@ +args<-commandArgs(TRUE) +rdsfile<-args[1] +packagesfile<-args[2] +packages <- .readRDS(rdsfile) +write.dcf(packages,packagesfile) diff --git a/g_cran/cran_read.py b/g_cran/cran_read.py index 63c25ed..8e8f840 100644 --- a/g_cran/cran_read.py +++ b/g_cran/cran_read.py @@ -150,10 +150,17 @@ def pmsify_package_data(data,remote_repository): e_vars['rdepend']=deps e_vars['iuse']="doc" - e_vars['homepage']=remote_repository + try: + uri_regex="([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?" + find_first_url=re.finditer(uri_regex,data['url']) + e_vars['homepage']=find_first_url.next().group(0) + except: #error processing url from data['url'] + e_vars['homepage']=remote_repository e_vars['keywords']="~x86 ~amd64" - if 'description' in data: - e_vars['description']=data['description'].strip().replace('\n',' ') + if 'title' in data: + e_vars['description']=data['title'].strip().replace('\n',' ') + elif 'description' in data: + e_vars['description']=data['description'].split('. ')[0].strip().replace('\n',' ') #first sentence else: e_vars['description']=e_vars['pn'] if 'license' in data: #fixme parse license data diff --git a/g_cran/g_cran.py b/g_cran/g_cran.py index 51fa588..6898109 100644 --- a/g_cran/g_cran.py +++ b/g_cran/g_cran.py @@ -12,7 +12,16 @@ def action_sync(repo_location,remote_uri): if not os.path.isdir(os.path.join(repo_location, REPO_MYDIR)): os.mkdir(os.path.join(repo_location,REPO_MYDIR)) packages_filename=os.path.join(repo_location, REPO_MYDIR, 'PACKAGES') - urllib.urlretrieve(remote_uri+'/src/contrib/PACKAGES',packages_filename) + packages_rds_filename=os.path.join(repo_location, REPO_MYDIR, 'packages.rds') + try: + #we first try to get a serialized full database... this works for CRAN + urllib.urlretrieve(remote_uri+'/web/packages/packages.rds',packages_rds_filename) + R_script=os.path.join(os.path.dirname(__file__),'convert_packages_rds.R') + returncode=os.system('R --quiet --file='+R_script+' --args '+packages_rds_filename+' '+packages_filename) + if returncode: + raise RuntimeError('Could not convert packages.rds') + except: + urllib.urlretrieve(remote_uri+'/src/contrib/PACKAGES',packages_filename) repo_file=open(os.path.join(repo_location,REPO_MYDIR,'remote_uri'),'w') repo_file.write(remote_uri) @@ -10,5 +10,5 @@ setup(name='G-CRAN', url='http://git.overlays.gentoo.org/gitweb/?p=proj/g-cran.git ', packages=['g_cran'], scripts=['bin/g-cran'], - package_data={'g_cran':['cran.ebuild',]}, + package_data={'g_cran':['cran.ebuild','convert_packages_rds.R']}, ) |