[jhbuild/desrt/packagedb] info files
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/desrt/packagedb] info files
- Date: Sat, 17 Jan 2015 22:28:00 +0000 (UTC)
commit 7994acde9ba2a7f1899bfdde4e9f454d56842695
Author: Ryan Lortie <desrt desrt ca>
Date: Sun Jan 4 11:16:10 2015 -0500
info files
jhbuild/utils/packagedb.py | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/jhbuild/utils/packagedb.py b/jhbuild/utils/packagedb.py
index b698e33..c3bfb87 100644
--- a/jhbuild/utils/packagedb.py
+++ b/jhbuild/utils/packagedb.py
@@ -49,11 +49,12 @@ def _format_isotime(tm):
return time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(tm))
class PackageEntry:
- def __init__(self, package, version, metadata, manifests_dir):
+ def __init__(self, package, version, metadata, manifests_dir, info_dir):
self.package = package # string
self.version = version # string
self.metadata = metadata # hash of string to value
self.manifests_dir = manifests_dir
+ self.info_dir = info_dir
_manifest = None
def get_manifest(self):
@@ -77,7 +78,7 @@ class PackageEntry:
manifest = property(get_manifest, set_manifest)
@classmethod
- def from_xml(cls, node, manifests_dir):
+ def from_xml(cls, node, manifests_dir, info_dir):
package = node.attrib['package']
version = node.attrib['version']
metadata = {}
@@ -89,16 +90,27 @@ class PackageEntry:
if configure_hash:
metadata['configure-hash'] = configure_hash
- dbentry = cls(package, version, metadata, manifests_dir)
+ dbentry = cls(package, version, metadata, manifests_dir, info_dir)
return dbentry
def write(self):
+ # write info file
+ writer = fileutils.SafeWriter(os.path.join(self.info_dir, self.package))
+ ET.ElementTree(self.to_xml()).write(writer.fp)
+ writer.fp.write('\n')
+ writer.commit()
+
+ # write manifest
writer = fileutils.SafeWriter(os.path.join(self.manifests_dir, self.package))
writer.fp.write('\n'.join(self.manifest) + '\n')
writer.commit()
def remove(self):
+ # remove info file
+ fileutils.ensure_unlinked(os.path.join(self.info_dir, self.package))
+
+ # remove manifest
fileutils.ensure_unlinked(os.path.join(self.manifests_dir, self.package))
def to_xml(self):
@@ -117,8 +129,11 @@ class PackageDB:
self.dbfile = dbfile
dirname = os.path.dirname(dbfile)
self.manifests_dir = os.path.join(dirname, 'manifests')
+ self.info_dir = os.path.join(dirname, 'info')
if not os.path.exists(self.manifests_dir):
os.makedirs(self.manifests_dir)
+ if not os.path.exists(self.info_dir):
+ os.makedirs(self.info_dir)
self.config = config
self._lock = lockfile.LockFile.get(os.path.join(dirname, 'packagedb.xml.lock'))
self._entries = None # hash
@@ -159,7 +174,7 @@ class PackageDB:
for node in root:
if node.tag != 'entry':
continue
- entry = PackageEntry.from_xml(node, self.manifests_dir)
+ entry = PackageEntry.from_xml(node, self.manifests_dir, self.info_dir)
self._entries[entry.package] = entry
self._entries_stat = os.fstat(f.fileno())
@@ -215,7 +230,7 @@ class PackageDB:
if configure_cmd:
metadata['configure-hash'] = hashlib.md5(configure_cmd).hexdigest()
self._entries[package] = PackageEntry(package, version, metadata,
- self.manifests_dir)
+ self.manifests_dir, self.info_dir)
self._entries[package].manifest = contents
self._entries[package].write()
self._write_cache()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]