summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAuke Booij (tulcod) <auke@tulcod.com>2010-06-26 17:45:51 +0200
committerAuke Booij (tulcod) <auke@tulcod.com>2010-06-26 17:45:51 +0200
commitb6e13d6603a926b90e38104b6c25cf29c45ee5dd (patch)
tree9687f9428ecab5f0b8fa24668e78ebec8a40612c
parentStill more python errors (diff)
downloadg-cran-b6e13d6603a926b90e38104b6c25cf29c45ee5dd.tar.gz
g-cran-b6e13d6603a926b90e38104b6c25cf29c45ee5dd.tar.bz2
g-cran-b6e13d6603a926b90e38104b6c25cf29c45ee5dd.zip
PMSify package names
-rw-r--r--g_cran/cran_read.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/g_cran/cran_read.py b/g_cran/cran_read.py
index 30afc8a..66e86c5 100644
--- a/g_cran/cran_read.py
+++ b/g_cran/cran_read.py
@@ -3,6 +3,15 @@ from ebuild import *
from filetricks import *
from settings import *
+def pmsify_package_name(name):
+ if len(name)==0:
+ return 'test'
+ name=re.sub('[^a-zA-Z0-9+_-]','',name) #name may only contain these characters
+ if not re.match('[a-zA-Z0-9+_].*',name): #package name must start with [a-zA-Z0-9+_]
+ name='_'+name
+ if re.match('.*-[0-9]+',name): #package name may not end in hyphen followed by integer
+ name=name+'_'
+
def pmsify_package_version(version_str):
return version_str.replace('-','.') #some CRAN-style versions have the form 0.1-1, which we transform into 0.1.1
@@ -36,14 +45,7 @@ def pmsify_package_data(data,remote_repository):
pms_pkg.cran_data=data
e_vars=pms_pkg.ebuild_vars
#fix settings:
- if 'package' not in data:
- e_vars['pn']='test'
- else:
- e_vars['pn']=data['package']
- if not re.match('[a-zA-Z0-9+_].*',e_vars['pn']): #package name may not be valid according to PMS
- e_vars['pn']='_'+e_vars.pn
- if re.match('.*-[0-9]+',e_vars['pn']):
- e_vars['pn']=e_vars.pn+'_'
+ e_vars['pn']=pmsify_package_name(data['package'])
if 'version' not in data: #set a version even if we have none
e_vars['pv']='0'
else:
@@ -85,5 +87,5 @@ def find_package(repo_location,package_name):
packages=read_packages(os.path.join(repo_location,REPO_MYDIR,'PACKAGES'),repo_location)
for package in packages:
if package.ebuild_vars['pn']==package_name:
- return package
+ return package
raise ValueError("Package not found")