diff options
author | 2013-07-17 16:42:10 +0200 | |
---|---|---|
committer | 2013-07-17 16:42:10 +0200 | |
commit | ccb0e1ea6cb6017040cde898425b0044e5ea27f7 (patch) | |
tree | 79ae4923b889fdc2f3b82042a8f1fb8fcd8cc836 | |
parent | g_elpa/data/g-elpa: consistent variable naming (diff) | |
download | gs-elpa-ccb0e1ea6cb6017040cde898425b0044e5ea27f7.tar.gz gs-elpa-ccb0e1ea6cb6017040cde898425b0044e5ea27f7.tar.bz2 gs-elpa-ccb0e1ea6cb6017040cde898425b0044e5ea27f7.zip |
load remote file functionality added
-rw-r--r-- | g_elpa/elpa_db.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/g_elpa/elpa_db.py b/g_elpa/elpa_db.py index 8e0554f..c2b7865 100644 --- a/g_elpa/elpa_db.py +++ b/g_elpa/elpa_db.py @@ -24,28 +24,25 @@ else: from g_sorcery.g_collections import Package from g_sorcery.package_db import PackageDB -from g_sorcery.fileutils import wget +from g_sorcery.fileutils import load_remote_file from g_sorcery.exceptions import SyncError class ElpaDB(PackageDB): def __init__(self, directory, repo_uri="", db_uri=""): super(ElpaDB, self).__init__(directory, repo_uri, db_uri) - def generate_tree(self): - tempdir = TemporaryDirectory() - - ac_uri = urljoin(self.repo_uri, 'archive-contents') - if wget(ac_uri, tempdir.name): - raise SyncError('sync failed: ' + self.repo_uri) - + def _load_archive_contents(self, archive_contents_f): try: - with open(os.path.join(tempdir.name, 'archive-contents')) as f: - archive_contents = sexpdata.load(f) + archive_contents = sexpdata.load(archive_contents_f) except Exception as e: raise SyncError('sync failed: ' + self.repo_uri + ': ' + str(e)) - - del tempdir + return archive_contents + def generate_tree(self): + ac_uri = urljoin(self.repo_uri, 'archive-contents') + + archive_contents = load_remote_file(ac_uri, self._load_archive_contents)['archive-contents'] + if sexpdata.car(archive_contents) != 1: raise SyncError('sync failed: ' + self.repo_uri + ' bad archive contents format') |