public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Jauhien Piatlicki" <piatlicki@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/, gs_ctan/, g_elpa/
Date: Fri, 19 Jul 2013 16:20:11 +0000 (UTC)	[thread overview]
Message-ID: <1374249091.638776b91b65fb3e19f93be05b425f2eb6d71c5b.jauhien@gentoo> (raw)

commit:     638776b91b65fb3e19f93be05b425f2eb6d71c5b
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Fri Jul 19 15:51:31 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Fri Jul 19 15:51:31 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=638776b9

common_config section in backend config

---
 g_elpa/elpa_db.py       |  4 ++--
 g_sorcery/backend.py    |  9 +++++++--
 g_sorcery/package_db.py | 16 +++++++++++++---
 gs_ctan/ctan_db.py      |  4 ++--
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/g_elpa/elpa_db.py b/g_elpa/elpa_db.py
index 12d56c7..7628502 100644
--- a/g_elpa/elpa_db.py
+++ b/g_elpa/elpa_db.py
@@ -28,8 +28,8 @@ from g_sorcery.fileutils import load_remote_file
 from g_sorcery.exceptions import SyncError
 
 class ElpaDB(PackageDB):
-    def __init__(self, directory, config = None):
-        super(ElpaDB, self).__init__(directory, config)
+    def __init__(self, directory, config = None, common_config = None):
+        super(ElpaDB, self).__init__(directory, config, common_config)
 
     def get_download_uries(self):
         ac_uri = urljoin(self.repo_uri, 'archive-contents')

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 08b7956..9dae652 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -114,6 +114,11 @@ class Backend(object):
         repository = args.repository
         repository_config = {}
 
+        if "common_config" in config:
+            common_config = config["common_config"]
+        else:
+            common_config = {}
+        
         if repository:
             if not "repositories" in config:
                 self.logger.error("repository " + repository + 
@@ -131,12 +136,12 @@ class Backend(object):
                 self.logger.error('no url given\n')
                 
         if self.sync_db:
-            pkg_db = self.package_db_class(db_path, repository_config)
+            pkg_db = self.package_db_class(db_path, repository_config, common_config)
             if not pkg_db.db_uri:
                 self.logger.error('no url given\n')
                 return -1
         else:
-            pkg_db = self.package_db_class(db_path, repository_config)
+            pkg_db = self.package_db_class(db_path, repository_config, common_config)
             if not pkg_db.repo_uri:
                 self.logger.error('no url given\n')
                 return -1

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)

diff --git a/gs_ctan/ctan_db.py b/gs_ctan/ctan_db.py
index e85e257..1aef53e 100644
--- a/gs_ctan/ctan_db.py
+++ b/gs_ctan/ctan_db.py
@@ -24,8 +24,8 @@ from g_sorcery.package_db import PackageDB
 from g_sorcery.exceptions import SyncError
 
 class CtanDB(PackageDB):
-    def __init__(self, directory, config = None):
-        super(CtanDB, self).__init__(directory, config)
+    def __init__(self, directory, config = None, common_config = None):
+        super(CtanDB, self).__init__(directory, config, common_config)
         
         logger = Logger()
         gentoo_arch = portage.settings['ARCH']


             reply	other threads:[~2013-07-19 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 16:20 Jauhien Piatlicki [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-07-19 16:20 [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/, gs_ctan/, g_elpa/ Jauhien Piatlicki
2013-07-17 23:19 Jauhien Piatlicki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374249091.638776b91b65fb3e19f93be05b425f2eb6d71c5b.jauhien@gentoo \
    --to=piatlicki@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox