aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-19 17:51:31 +0200
committerJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-19 17:51:31 +0200
commit638776b91b65fb3e19f93be05b425f2eb6d71c5b (patch)
tree3816e0980864d1732f59cc9df3574397bcbe4584 /g_sorcery/package_db.py
parentg_sorcery/package_db: save config in db (diff)
downloadg-sorcery-638776b91b65fb3e19f93be05b425f2eb6d71c5b.tar.gz
g-sorcery-638776b91b65fb3e19f93be05b425f2eb6d71c5b.tar.bz2
g-sorcery-638776b91b65fb3e19f93be05b425f2eb6d71c5b.zip
common_config section in backend config
Diffstat (limited to 'g_sorcery/package_db.py')
-rw-r--r--g_sorcery/package_db.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 2a8ab25..d38a90d 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -109,7 +109,7 @@ class PackageDB(object):
return (Package(category, name, ver), ebuild_data)
- def __init__(self, directory, config = None):
+ def __init__(self, directory, config = None, common_config = None):
"""
Args:
directory: database directory.
@@ -118,6 +118,7 @@ class PackageDB(object):
"""
self.URI_NAME = 'uri.json'
self.CONFIG_NAME = 'config.json'
+ self.COMMON_CONFIG_NAME = 'common_config.json'
self.CATEGORIES_NAME = 'categories.json'
self.PACKAGES_NAME = 'packages.json'
self.VERSIONS_NAME = 'versions.json'
@@ -126,8 +127,13 @@ class PackageDB(object):
self.config = config
config_f = FileJSON(self.directory, self.CONFIG_NAME, [])
config_f.write(self.config)
+
+ self.common_config = common_config
+ config_f = FileJSON(self.directory, self.COMMON_CONFIG_NAME, [])
+ config_f.write(self.common_config)
else:
self.config = {}
+ self.common_config = {}
if "repo_uri" in self.config:
repo_uri = self.config["repo_uri"]
@@ -293,7 +299,7 @@ class PackageDB(object):
categories = FileJSON(self.directory, self.CATEGORIES_NAME, [])
categories = categories.read()
manifest = {}
- names = [self.CONFIG_NAME, self.CATEGORIES_NAME, self.URI_NAME]
+ names = [self.CONFIG_NAME, self.COMMON_CONFIG_NAME, self.CATEGORIES_NAME, self.URI_NAME]
for name in names:
manifest[name] = hash_file(os.path.join(self.directory, name),
hashlib.md5())
@@ -322,7 +328,7 @@ class PackageDB(object):
result = True
errors = []
- names = [self.CONFIG_NAME, self.CATEGORIES_NAME, self.URI_NAME]
+ names = [self.CONFIG_NAME, self.COMMON_CONFIG_NAME, self.CATEGORIES_NAME, self.URI_NAME]
for name in names:
if not name in manifest:
raise DBStructureError('Bad manifest: no ' + name + ' entry')
@@ -348,8 +354,10 @@ class PackageDB(object):
Write database.
"""
config_f = FileJSON(self.directory, self.CONFIG_NAME, [])
+ common_config_f = FileJSON(self.directory, self.COMMON_CONFIG_NAME, [])
categories_f = FileJSON(self.directory, self.CATEGORIES_NAME, [])
config_f.write(self.config)
+ common_config_f.write(self.common_config)
categories_f.write(self.categories)
for pkgname, versions in self.database.items():
@@ -410,8 +418,10 @@ class PackageDB(object):
if not sane:
raise IntegrityError('Manifest error: ' + str(errors))
config_f = FileJSON(self.directory, self.CONFIG_NAME, [])
+ common_config_f = FileJSON(self.directory, self.COMMON_CONFIG_NAME, [])
categories_f = FileJSON(self.directory, self.CATEGORIES_NAME, [])
self.config = config_f.read()
+ self.common_config = common_config_f.read()
self.categories = categories_f.read()
for category in self.categories:
category_path = os.path.join(self.directory, category)