diff options
Diffstat (limited to 'g_cran/cran_read.py')
-rw-r--r-- | g_cran/cran_read.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/g_cran/cran_read.py b/g_cran/cran_read.py index 0906ec9..f648830 100644 --- a/g_cran/cran_read.py +++ b/g_cran/cran_read.py @@ -1,4 +1,4 @@ -import re, os +import re, os, tarfile, rfc822 from ebuild import * from filetricks import * from settings import * @@ -194,8 +194,19 @@ def read_packages(package_filename,local_repository): #find a package in this repository... we really should cache this #into some sqlite database once 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 - raise ValueError("Package not found") + database_tarball=tarfile.open(os.path.join(repo_location,REPO_MYDIR,'database.tgz'),'r') + package_file=database_tarball.extractfile(package_name) + if package_file==None: + raise DoesNotExist + + repository_file=open(os.path.join(repo_location,REPO_MYDIR,'remote_uri'),'r') + remote_uri=repository_file.read().strip() + + pms_package=pmsify_package_data(dict(rfc822.Message(package_file).items()),remote_uri) + return pms_package + + #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 + #raise ValueError("Package not found") |