public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-20 22:53 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-20 22:53 UTC (permalink / raw
  To: gentoo-commits

commit:     0da13d1665f622546d3608c84e1a737552cbcaba
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jun 19 20:58:46 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jun 19 20:58:46 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=0da13d16

g_sorcery/backend.py: initial commit

---
 g_sorcery/backend.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
new file mode 100644
index 0000000..0fb194d
--- /dev/null
+++ b/g_sorcery/backend.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+    backend.py
+    ~~~~~~~~~~
+    
+    base class for backends
+    
+    :copyright: (c) 2013 by Jauhien Piatlicki
+    :license: GPL-2, see LICENSE for more details.
+"""
+
+class Backend:
+    def __init__(self):
+        pass


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-20 23:21 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-20 23:21 UTC (permalink / raw
  To: gentoo-commits

commit:     07f3d62dc7e4753e442564cd61869d47d7f367a5
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Jun 20 23:22:04 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Jun 20 23:22:04 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=07f3d62d

g_sorcery/package_db.py: sync, initial commit

---
 g_sorcery/package_db.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 0a2bdfb..a5b73c1 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -116,6 +116,22 @@ class PackageDB:
         """
         pass
 
+    def sync(self, repo_uri="", db_uri=""):
+        if repo_uri:
+            self.repo_uri = repo_uri
+        if db_uri:
+            self.db_uri = db_uri
+        self.clean()
+        real_db_uri = self.get_real_db_uri()
+        """
+        TODO
+        code that downloads tarball from the real_db_uri
+        and unpacks it
+        """
+
+    def get_real_db_uri():
+        return self.db_uri
+            
     def manifest(self):
         categories = FileJSON(self.directory, self.CATEGORIES_NAME, [])
         categories = categories.read()


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-20 23:44 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-20 23:44 UTC (permalink / raw
  To: gentoo-commits

commit:     feefb8e6b73b0e8d33b6f61048d7267df6b5ed14
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Jun 20 23:45:59 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Jun 20 23:45:59 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=feefb8e6

g_sorcery/package_db.py: generate_tree, fix doc string

---
 g_sorcery/package_db.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index a5b73c1..9c477f7 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -106,13 +106,9 @@ class PackageDB:
 
     def generate_tree(self):
         """
-        Generate tree with JSON files containing info
-        about packages in a repository
+        Generate tree
 
         Should be implemented in a subclass
-
-        repo_uri -- repository uri
-        if repo_uri is an empty string should use self.repo_uri
         """
         pass
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-23  0:44 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-23  0:44 UTC (permalink / raw
  To: gentoo-commits

commit:     8ce63dcb5fc8e4c56273d62ddc867482a5e22cdf
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jun 22 22:21:23 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 22:21:23 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=8ce63dcb

g_sorcery/__init__

---
 g_sorcery/__init__.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/g_sorcery/__init__.py b/g_sorcery/__init__.py
new file mode 100644
index 0000000..cf529d7
--- /dev/null
+++ b/g_sorcery/__init__.py
@@ -0,0 +1,2 @@
+#!/usr/bin/env python
+


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-23  0:44 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-23  0:44 UTC (permalink / raw
  To: gentoo-commits

commit:     069fc871e5e00e8f4bff041f5b45a95fdf1cc9c4
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jun 22 22:57:42 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 22:57:42 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=069fc871

g_sorcery/package_db: get_package_description

---
 g_sorcery/package_db.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index b97a688..48101a2 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -320,3 +320,7 @@ class PackageDB:
         if not name in self.db['packages'][category]:
             raise Exception('No such package: ' + name)
         return list(self.db['packages'][category][name])
+
+    def get_package_description(self, package):
+        #a possible exception should be catched in the caller
+        return self.db['packages'][package.category][package.name][package.version]


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-23  0:44 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-23  0:44 UTC (permalink / raw
  To: gentoo-commits

commit:     c6f8894af05759513b3baf8b97d1f4805fb2aab3
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jun 22 22:59:04 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 23:00:03 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=c6f8894a

g_sorcery/ebuild.py: initial commit

---
 g_sorcery/ebuild.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
new file mode 100644
index 0000000..47c727a
--- /dev/null
+++ b/g_sorcery/ebuild.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+    ebuild.py
+    ~~~~~~~~~~~~~
+    
+    ebuild generation
+    
+    :copyright: (c) 2013 by Jauhien Piatlicki
+    :license: GPL-2, see LICENSE for more details.
+"""


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-24 21:09 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-24 21:09 UTC (permalink / raw
  To: gentoo-commits

commit:     5614a06b63770e93447a5fb93aada06902775393
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Jun 24 21:10:47 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Jun 24 21:10:47 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=5614a06b

g_sorcery/package_db: fixes, thanks to dolsen

---
 g_sorcery/package_db.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 7d7c901..1fe4b38 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -296,17 +296,21 @@ class PackageDB:
     def additional_read(self):
         pass
         
-    def add_category(self, category, description={}):
+    def add_category(self, category, description=None):
+        if not description:
+            description = {}
         self.db['categories'][category] = description;
         self.db['packages'][category] = {}
 
-    def add_package(self, package, description={}):
+    def add_package(self, package, description=None):
+        if not description:
+            description = {}
         category = package.category
         name = package.name
         version = package.version
-        if not category in self.db['packages']:
+        if category and not category in self.db['packages']:
             raise Exception('Non-existent category: ' + category)
-        if not name in self.db['packages'][category]:
+        if name and not name in self.db['packages'][category]:
             self.db['packages'][category][name] = {}
         self.db['packages'][category][name][version] = description
 
@@ -314,14 +318,14 @@ class PackageDB:
         return list(self.db['categories'])
 
     def list_package_names(self, category):
-        if not category in self.db['packages']:
+        if category and not category in self.db['packages']:
             raise Exception('No such category: ' + category)
         return list(self.db['packages'][category])
 
     def list_package_versions(self, category, name):
-        if not category in self.db['packages']:
+        if category and not category in self.db['packages']:
             raise Exception('No such category: ' + category)
-        if not name in self.db['packages'][category]:
+        if name and not name in self.db['packages'][category]:
             raise Exception('No such package: ' + name)
         return list(self.db['packages'][category][name])
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-24 21:09 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-24 21:09 UTC (permalink / raw
  To: gentoo-commits

commit:     7ad03f2f78787da0f9f795584c96f91e61c4d35b
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Jun 24 21:02:35 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Jun 24 21:02:35 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=7ad03f2f

g_sorcery/package_db: remove .keys() as deprecated, thanks to dolsen

---
 g_sorcery/package_db.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index a85a704..7d7c901 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -225,11 +225,11 @@ class PackageDB:
                     self.additional_write_version(category, package, version)
                 f = FileJSON(os.path.join(self.directory, category, package),
                                      self.VERSIONS_NAME, [])
-                f.write(list(versions.keys()))
+                f.write(list(versions))
                 self.additional_write_package(category, package)
             f = FileJSON(os.path.join(self.directory, category),
                                      self.PACKAGES_NAME, [])
-            f.write(list(self.db['packages'][category].keys()))
+            f.write(list(self.db['packages'][category]))
             self.additional_write_category(category)
         self.additional_write()
 
@@ -311,12 +311,12 @@ class PackageDB:
         self.db['packages'][category][name][version] = description
 
     def list_categories(self):
-        return list(self.db['categories'].keys())
+        return list(self.db['categories'])
 
     def list_package_names(self, category):
         if not category in self.db['packages']:
             raise Exception('No such category: ' + category)
-        return list(self.db['packages'][category].keys())
+        return list(self.db['packages'][category])
 
     def list_package_versions(self, category, name):
         if not category in self.db['packages']:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-29 12:13 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-29 12:13 UTC (permalink / raw
  To: gentoo-commits

commit:     4913f74fca5e720c7d5c0d7cc502deab62259052
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jun 29 12:12:08 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jun 29 12:12:08 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=4913f74f

g_sorcery/package_db: self.db['info'] -> self.info

---
 g_sorcery/package_db.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index e2cd40d..fcf2267 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -102,7 +102,7 @@ class PackageDB:
 
     def reset_db(self):
         self.db = {}
-        self.db['info'] = {}
+        self.info = {}
         self.db['categories'] = {}
         self.db['packages'] = {}
 
@@ -215,7 +215,7 @@ class PackageDB:
     def write(self):
         info_f = FileJSON(self.directory, self.INFO_NAME, [])
         categories_f = FileJSON(self.directory, self.CATEGORIES_NAME, [])
-        info_f.write(self.db['info'])
+        info_f.write(self.info)
         categories_f.write(self.db['categories'])
         for category in self.db['categories']:
             if not category in self.db['packages']:
@@ -254,7 +254,7 @@ class PackageDB:
             raise IntegrityError('Manifest error: ' + str(errors))
         info_f = FileJSON(self.directory, self.INFO_NAME, [])
         categories_f = FileJSON(self.directory, self.CATEGORIES_NAME, [])
-        self.db['info'] = info_f.read()
+        self.info = info_f.read()
         self.db['categories'] = categories_f.read()
         for category in self.db['categories']:
             category_path = os.path.join(self.directory, category)


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-29 12:13 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-29 12:13 UTC (permalink / raw
  To: gentoo-commits

commit:     6bcd4e629c64b3f16166e0d53ed8820a9cbbfe11
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jun 29 12:14:21 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jun 29 12:14:21 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=6bcd4e62

g_sorcery/package_db: self.db['categories'] -> self.categories

---
 g_sorcery/package_db.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index fcf2267..629f4ce 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -103,7 +103,7 @@ class PackageDB:
     def reset_db(self):
         self.db = {}
         self.info = {}
-        self.db['categories'] = {}
+        self.categories = {}
         self.db['packages'] = {}
 
     def generate(self, repo_uri=""):
@@ -216,8 +216,8 @@ class PackageDB:
         info_f = FileJSON(self.directory, self.INFO_NAME, [])
         categories_f = FileJSON(self.directory, self.CATEGORIES_NAME, [])
         info_f.write(self.info)
-        categories_f.write(self.db['categories'])
-        for category in self.db['categories']:
+        categories_f.write(self.categories)
+        for category in self.categories:
             if not category in self.db['packages']:
                 raise DBStructureError('Empty category: ' + category)
             for package, versions in self.db['packages'][category].items():
@@ -255,8 +255,8 @@ class PackageDB:
         info_f = FileJSON(self.directory, self.INFO_NAME, [])
         categories_f = FileJSON(self.directory, self.CATEGORIES_NAME, [])
         self.info = info_f.read()
-        self.db['categories'] = categories_f.read()
-        for category in self.db['categories']:
+        self.categories = categories_f.read()
+        for category in self.categories:
             category_path = os.path.join(self.directory, category)
             if not os.path.isdir(category_path):
                 raise DBStructureError('Empty category: ' + category)
@@ -302,7 +302,7 @@ class PackageDB:
     def add_category(self, category, description=None):
         if not description:
             description = {}
-        self.db['categories'][category] = description;
+        self.categories[category] = description;
         self.db['packages'][category] = {}
 
     def add_package(self, package, description=None):
@@ -318,7 +318,7 @@ class PackageDB:
         self.db['packages'][category][name][version] = description
 
     def list_categories(self):
-        return list(self.db['categories'])
+        return list(self.categories)
 
     def list_package_names(self, category):
         if category and not category in self.db['packages']:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-29 14:16 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-29 14:16 UTC (permalink / raw
  To: gentoo-commits

commit:     eb4228138d87ab2196b847fe8d480412db24010c
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jun 29 14:17:37 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jun 29 14:17:37 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=eb422813

g_sorcery/package_db: self.db['packages'] -> self.db

---
 g_sorcery/package_db.py | 82 +++++++++++++++++++++++++++----------------------
 1 file changed, 46 insertions(+), 36 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 629f4ce..b4f6193 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -104,7 +104,7 @@ class PackageDB:
         self.db = {}
         self.info = {}
         self.categories = {}
-        self.db['packages'] = {}
+        self.db = {}
 
     def generate(self, repo_uri=""):
         """
@@ -217,23 +217,31 @@ class PackageDB:
         categories_f = FileJSON(self.directory, self.CATEGORIES_NAME, [])
         info_f.write(self.info)
         categories_f.write(self.categories)
-        for category in self.categories:
-            if not category in self.db['packages']:
-                raise DBStructureError('Empty category: ' + category)
-            for package, versions in self.db['packages'][category].items():
-                for version, content in versions.items():
-                    f = FileJSON(os.path.join(self.directory, category, package),
-                                 version + '.json', [])
-                    f.write(content)
-                    self.additional_write_version(category, package, version)
-                f = FileJSON(os.path.join(self.directory, category, package),
-                                     self.VERSIONS_NAME, [])
-                f.write(list(versions))
-                self.additional_write_package(category, package)
+
+        for pkgname, versions in self.db.items():
+            category, name = pkgname.split('/')
+            if not category or (not category in self.categories):
+                raise DBStructureError('Non existent: ' + category)
+            for version, content in versions.items():
+                f = FileJSON(os.path.join(self.directory, category, name),
+                    version + '.json', [])
+                f.write(content)
+                self.additional_write_version(category, name, version)
+            f = FileJSON(os.path.join(self.directory, category, name),
+                self.VERSIONS_NAME, [])
+            f.write(list(versions))
+            self.additional_write_package(category, name)
             f = FileJSON(os.path.join(self.directory, category),
-                                     self.PACKAGES_NAME, [])
-            f.write(list(self.db['packages'][category]))
+                self.PACKAGES_NAME, [])
+            pkgs = f.read()
+            if not pkgs:
+                pkgs = []
+            pkgs.append(name)
+            f.write(pkgs)
+
+        for category in self.categories:
             self.additional_write_category(category)
+            
         self.additional_write()
 
     def additional_write_version(self, category, package, version):
@@ -266,7 +274,6 @@ class PackageDB:
             if not packages:
                 raise DBStructureError('Empty category: ' + category)
             
-            self.db['packages'][category] = {}
             for name in packages:
                 package_path = os.path.join(category_path, name)
                 if not os.path.isdir(category_path):
@@ -276,12 +283,13 @@ class PackageDB:
                 versions = f.read()
                 if not versions:
                     raise DBStructureError('Empty package: ' + category + '/' + name)
-                
-                self.db['packages'][category][name] = {}
+
+                pkgname = category + '/' + name
+                self.db[pkgname] = {}
                 for version in versions:
                     f = FileJSON(package_path, version + '.json', [])
                     description = f.read()
-                    self.db['packages'][category][name][version] = description
+                    self.db[pkgname][version] = description
                     self.additional_read_version(category, name, version)
                 self.additional_read_package(category, name)
             self.additional_read_category(category)
@@ -303,7 +311,6 @@ class PackageDB:
         if not description:
             description = {}
         self.categories[category] = description;
-        self.db['packages'][category] = {}
 
     def add_package(self, package, description=None):
         if not description:
@@ -311,35 +318,38 @@ class PackageDB:
         category = package.category
         name = package.name
         version = package.version
-        if category and not category in self.db['packages']:
+        pkgname = category + '/' + name
+        if category and not category in self.categories:
             raise InvalidKeyError('Non-existent category: ' + category)
-        if name and not name in self.db['packages'][category]:
-            self.db['packages'][category][name] = {}
-        self.db['packages'][category][name][version] = description
+        if pkgname and not pkgname in self.db:
+            self.db[pkgname] = {}
+        self.db[pkgname][version] = description
 
     def list_categories(self):
         return list(self.categories)
 
     def list_package_names(self, category):
-        if category and not category in self.db['packages']:
+        if not category or (not category in self.categories):
             raise InvalidKeyError('No such category: ' + category)
-        return list(self.db['packages'][category])
+        res = [x.split('/')[1] for x in self.db if x.split('/')[0] == category]
+        return res
 
     def list_package_versions(self, category, name):
-        if category and not category in self.db['packages']:
+        if not category or (not category in self.categories):
             raise InvalidKeyError('No such category: ' + category)
-        if name and not name in self.db['packages'][category]:
-            raise InvalidKeyError('No such package: ' + name)
-        return list(self.db['packages'][category][name])
+        pkgname = category + '/' + name
+        if not pkgname in self.db:
+            raise InvalidKeyError('No such package: ' + pkgname)
+        return list(self.db[pkgname])
 
     def list_all_packages(self):
         result = []
-        for category in self.db['packages']:
-            for name in self.db['packages'][category]:
-                for version in self.db['packages'][category][name]:
-                    result.append(Package(category, name, version))
+        for pkgname, versions in self.db.items():
+            for version in versions:
+                category, name = pkgname.split('/')
+                result.append(Package(category, name, version))
         return result
 
     def get_package_description(self, package):
         #a possible exception should be catched in the caller
-        return self.db['packages'][package.category][package.name][package.version]
+        return self.db[package.category + '/' + package.name][package.version]


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-06-30 23:29 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-06-30 23:29 UTC (permalink / raw
  To: gentoo-commits

commit:     710f8d3e8af33e990acab4733fc3ce58ce09697f
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Jun 30 22:51:53 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Jun 30 22:51:53 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=710f8d3e

g_sorcery/metadata: MetadataGenerator, metadata.xml schema

---
 g_sorcery/metadata.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/g_sorcery/metadata.py b/g_sorcery/metadata.py
index c945f70..7ef949a 100644
--- a/g_sorcery/metadata.py
+++ b/g_sorcery/metadata.py
@@ -64,6 +64,77 @@ class XMLGenerator:
 class MetadataGenerator:
     def __init__(self, db):
         self.db = db
+        schema = [{'name' : 'herd',
+                   'multiple' : (True, ""),
+                   'required' : False,
+                   'subtags' : []},
+                   
+                   {'name' : 'maintainer',
+                   'multiple' : (True, ""),
+                   'required' : False,
+                   'subtags' : [{'name' : 'email',
+                                 'multiple' : (False, ""),
+                                 'required' : True,
+                                 'subtags' : []},
+                                 {'name' : 'name',
+                                 'multiple' : (False, ""),
+                                 'required' : False,
+                                 'subtags' : []},
+                                 {'name' : 'description',
+                                 'multiple' : (False, ""),
+                                 'required' : False,
+                                 'subtags' : []},
+                                 ]
+                    },
+
+                    {'name' : 'longdescription',
+                     'multiple' : (False, ""),
+                     'required' : False,
+                     'subtags' : []},
+
+                     {'name' : 'use',
+                     'multiple' : (False, ""),
+                     'required' : False,
+                     'subtags' : [{'name' : 'flag',
+                                 'multiple' : (True, "name"),
+                                 'required' : True,
+                                 'subtags' : []}]
+                     },
+
+                     {'name' : 'upstream',
+                     'multiple' : (False, ""),
+                     'required' : False,
+                     'subtags' : [{'name' : 'maintainer',
+                                 'multiple' : (True, ""),
+                                 'required' : False,
+                                 'subtags' : [{'name' : 'name',
+                                               'multiple' : (False, ""),
+                                               'required' : True,
+                                               'subtags' : []},
+                                               {'name' : 'email',
+                                               'multiple' : (False, ""),
+                                               'required' : False,
+                                               'subtags' : []}]},
+                                {'name' : 'changelog',
+                                 'multiple' : (False, ""),
+                                 'required' : False,
+                                 'subtags' : []},
+                                 {'name' : 'doc',
+                                 'multiple' : (False, ""),
+                                 'required' : False,
+                                 'subtags' : []},
+                                 {'name' : 'bugs-to',
+                                 'multiple' : (False, ""),
+                                 'required' : False,
+                                 'subtags' : []},
+                                 {'name' : 'remote-id',
+                                 'multiple' : (False, ""),
+                                 'required' : False,
+                                 'subtags' : []},
+                                ]
+                        },
+                   ]
+        self.xmlg = XMLGenerator('pkgmetadata', schema)
         
     def generate(self, package):
         description = self.db.get_package_description(package)


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-01  0:07 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-01  0:07 UTC (permalink / raw
  To: gentoo-commits

commit:     376f09895ba9a19eb1ffa57eeba2bab00b3de363
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Jul  1 00:09:03 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Jul  1 00:09:03 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=376f0989

g_sorcery/metadata: default_schema

---
 g_sorcery/metadata.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/g_sorcery/metadata.py b/g_sorcery/metadata.py
index 89d071e..7053307 100644
--- a/g_sorcery/metadata.py
+++ b/g_sorcery/metadata.py
@@ -59,12 +59,9 @@ class XMLGenerator:
                 self.add_tag(child, child_tag, value)
         else:
             child.text = value
-        
 
-class MetadataGenerator:
-    def __init__(self, db):
-        self.db = db
-        schema = [{'name' : 'herd',
+
+default_schema = [{'name' : 'herd',
                    'multiple' : (True, ""),
                    'required' : False,
                    'subtags' : []},
@@ -134,6 +131,11 @@ class MetadataGenerator:
                                 ]
                         },
                    ]
+            
+
+class MetadataGenerator:
+    def __init__(self, db, schema = default_schema):
+        self.db = db
         self.xmlg = XMLGenerator('pkgmetadata', schema)
         
     def generate(self, package):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-02  8:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-02  8:39 UTC (permalink / raw
  To: gentoo-commits

commit:     287c6639052afbaffd35e7722ec2e2de9a1e7710
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Tue Jul  2 08:24:33 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Tue Jul  2 08:24:33 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=287c6639

g_sorcery/fileutils: wget

---
 g_sorcery/fileutils.py  | 3 +++
 g_sorcery/package_db.py | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 1920495..a8415c0 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -70,3 +70,6 @@ def copy_all(src, dst):
             shutil.copytree(src_name, dst_name)
         else:
             shutil.copy2(src_name, dst_name)
+
+def wget(uri, directory):
+    return os.system('wget -P ' + directory + ' ' + uri)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index fc59878..179d07d 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -14,7 +14,7 @@
 from .exceptions import DBStructureError, IntegrityError, \
      InvalidKeyError, SyncError
 
-from .fileutils import FileJSON, hash_file, copy_all
+from .fileutils import FileJSON, hash_file, copy_all, wget
 
 import portage
 
@@ -81,7 +81,7 @@ class PackageDB:
         self.clean()
         real_db_uri = self.get_real_db_uri()
         download_dir = tempfile.TemporaryDirectory()
-        if os.system('wget -P ' + download_dir.name + ' ' + real_db_uri):
+        if wget(real_db_uri, download_dir.name):
             raise SyncError('sync failed: ' + real_db_uri)
         
         temp_dir = tempfile.TemporaryDirectory()


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-02 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-02 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     30294fadf1471b9118eeed293ad0dbdf48de1bb2
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Tue Jul  2 12:40:43 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Tue Jul  2 12:40:43 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=30294fad

py2, g_sorcery/compatibility: TemporaryDirectory

---
 g_sorcery/compatibility.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/g_sorcery/compatibility.py b/g_sorcery/compatibility.py
index 5491d72..4fbc3f1 100644
--- a/g_sorcery/compatibility.py
+++ b/g_sorcery/compatibility.py
@@ -11,16 +11,19 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
-import sys
+import shutil, sys
 
 py2k = sys.version_info < (3, 0)
 
 if py2k:
+
+    from tempfile import mkdtemp
+    
     class TemporaryDirectory():
         def __init__(self):
-            pass
+            self.name = mkdtemp()
 
         def __del__(self):
-            pass
+            shutil.rmtree(self.name)
 else:
     from tempfile import TemporaryDirectory


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-02 17:30 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-02 17:30 UTC (permalink / raw
  To: gentoo-commits

commit:     de2050c9a076ef62c3101876a8b89757f1c9e93a
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Tue Jul  2 17:31:27 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Tue Jul  2 17:31:27 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=de2050c9

g_sorcery/metadata, g_sorcery/package_db: fixes, thanks to dol-sen

---
 g_sorcery/metadata.py   | 2 +-
 g_sorcery/package_db.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/g_sorcery/metadata.py b/g_sorcery/metadata.py
index 1ce8fdc..3d10c7f 100644
--- a/g_sorcery/metadata.py
+++ b/g_sorcery/metadata.py
@@ -54,7 +54,7 @@ class XMLGenerator(object):
         subtags = tag['subtags']
         if subtags:
             if 'text' in value:
-                child.text = value[text]
+                child.text = value['text']
             for child_tag in subtags:
                 self.add_tag(child, child_tag, value)
         else:

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 763ea30..12577ad 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -20,7 +20,7 @@ from .fileutils import FileJSON, hash_file, copy_all, wget
 
 import portage
 
-import collections, glob, hashlib, os, shutil, tarfile, tempfile
+import collections, glob, hashlib, os, shutil, tarfile
 
 Package = collections.namedtuple("Package", "category name version")
 
@@ -115,7 +115,7 @@ class PackageDB(object):
         
         self.read()
 
-    def get_real_db_uri():
+    def get_real_db_uri(self):
         return self.db_uri
             
     def manifest(self):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-03 22:54 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-03 22:54 UTC (permalink / raw
  To: gentoo-commits

commit:     447877b2db0f20f36cd0bf6aea0fb0f7c0e9b2e8
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul  3 21:59:20 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul  3 21:59:20 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=447877b2

g_sorcery/metadata: hiding pylint swearing

---
 g_sorcery/metadata.py | 133 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 126 insertions(+), 7 deletions(-)

diff --git a/g_sorcery/metadata.py b/g_sorcery/metadata.py
index 3d10c7f..7df3fe7 100644
--- a/g_sorcery/metadata.py
+++ b/g_sorcery/metadata.py
@@ -17,22 +17,87 @@ import xml.etree.ElementTree as ET
 import xml.dom.minidom as minidom
 
 def prettify(tree):
+    """
+    Convert XML tree to a string.
+
+    Args:
+        tree: xml.etree.ElementTree.Element instance
+
+    Returns:
+        A string with XML source.
+    """
     rough_str = ET.tostring(tree, "utf-8").decode("utf-8")
     reparsed = minidom.parseString(rough_str)
     return reparsed.toprettyxml(encoding="utf-8").decode("utf-8")
 
 class XMLGenerator(object):
+    """
+    XML generator. Generates an XML tree according a given
+    schema using a dict as a source of data.
+
+    Schema format.
+    ~~~~~~~~~~~~~~
+    Schema is a list of entries. Each entry describes one XML tag.
+    Entry is a dict. dict keys are:
+        name: Name of a tag
+        multiple: Defines if a given tag can be used more
+                  then one time. It is a tuple. First element
+                  of a tuple is boolean. If it is set a tag can be
+                  repeated. Second element is a string. If it is not
+                  empty, it defines a name for an attribute
+                  that will distinguish different entries of a tag.
+        required: Boolean that defines if a given tag is required.
+        subtags: List a subtags.
+
+    Data dictinonary format.
+    ~~~~~~~~~~~~~~~~~~~~~~~~
+    Keys correspond to tags from a schema with the same name.
+    If a tag is not multiple without subkeys value is just a
+    string with text for the tag.
+    If tag is multiple value is a list with entries
+    corresponding to a single tag.
+    If tag has subtags value is a dictionary with entries
+    corresponding to subkeys and 'text' entry corresponding
+    to text for the tag.
+    If tag should have attributes value is a tuple or list with
+    0 element containing an attribute and 1 element containing
+    a value for the tag as described previously.
+    """
     def __init__(self, external, schema):
+        """
+        Args:
+            external: Name of an outermost tag.
+            schema: XML schema.
+        """
         self.external = external
         self.schema = schema        
 
     def generate(self, values):
+        """
+        Generate an XML tree filled with values from
+        a given dictionary.
+
+        Args:
+            values: Data dictionary.
+
+        Returns:
+            XML tree being an istance of
+            xml.etree.ElementTree.Element
+        """
         root = ET.Element(self.external)
         for tag in self.schema:
             self.add_tag(root, tag, values)
         return root
 
     def add_tag(self, root, tag, values):
+        """
+        Add a tag.
+
+        Args:
+            root: A parent tag.
+            tag: Tag from schema to be added.
+            values: Data dictionary.
+        """
         name = tag['name']
         if not name in values:
             if tag['required']:
@@ -41,12 +106,23 @@ class XMLGenerator(object):
         value = values[name]
         multiple, attr = tag['multiple']
         if multiple:
-            for v in value:
-                self.add_single_tag(root, name, tag, v, attr)
+            for val in value:
+                self.add_single_tag(root, name, tag, val, attr)
         else:
             self.add_single_tag(root, name, tag, value)
             
     def add_single_tag(self, root, name, tag, value, attr=None):
+        """
+        Add a single tag.
+
+        Args:
+            root: A parent tag.
+            name: Name of tag to be added.
+            tag: Tag from schema to be added.
+            value: Entry of a data dictionary
+                   corresponding to the tag.
+            attr: An attribute of the tag.
+        """
         child = ET.SubElement(root, name)
         if attr:
             child.set(attr, value[0])
@@ -61,6 +137,8 @@ class XMLGenerator(object):
             child.text = value
 
 
+# A default schema describing metadata.xml
+# See http://devmanual.gentoo.org/ebuild-writing/misc-files/metadata/
 default_schema = [{'name' : 'herd',
                    'multiple' : (True, ""),
                    'required' : False,
@@ -134,24 +212,65 @@ default_schema = [{'name' : 'herd',
             
 
 class MetadataGenerator(object):
-    def __init__(self, db, schema = default_schema):
-        self.db = db
+    """
+    Metada generator. Generates metadata for a given package.
+    """
+    def __init__(self, package_db, schema = default_schema):
+        """
+        Args:
+            package_db: Package database.
+            schema: Schema of an XML tree.
+        """
+        self.package_db = package_db
         self.xmlg = XMLGenerator('pkgmetadata', schema)
         
     def generate(self, package):
-        description = self.db.get_package_description(package)
+        """
+        Generate metadata for a package.
+
+        Args:
+            package: package_db.Package instance.
+
+        Returns:
+            Metadata source as a list of strings.
+        """
+        description = self.package_db.get_package_description(package)
         metadata = self.process(package, description)
         metadata = self.postprocess(package, description, metadata)
         metadata = prettify(metadata)
         metadata = metadata.split('\n')
         if metadata[-1] == '':
-                metadata = metadata[:-1]
-        metadata.insert(1, '<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">')
+            metadata = metadata[:-1]
+        dtp = '<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">'
+        metadata.insert(1, dtp)
         return metadata
 
     def process(self, package, description):
+        """
+        Generate metadata using values from a description.
+
+        Args:
+            package: package_db.Package instance.
+            description: Package description (see package_db module).
+
+        Returns:
+            Metadata source as a list of strings.
+            DOCTYPE missing.
+        """
         metadata = self.xmlg.generate(description)
         return metadata
         
     def postprocess(self, package, description, metadata):
+        """
+        Postprocess generated metadata. Can be overrided.
+
+        Args:
+            package: package_db.Package instance.
+            description: Package description (see package_db module).
+            metadata: xml.etree.ElementTree.Element instance
+
+        Returns:
+            Metadata source as a list of strings.
+            DOCTYPE missing.
+        """
         return metadata


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-03 22:54 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-03 22:54 UTC (permalink / raw
  To: gentoo-commits

commit:     87d8d8df989f17bd56be4f822cd0ced13c876089
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul  3 21:14:52 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul  3 21:14:52 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=87d8d8df

g_sorcery/backend: hiding pylint swearing

---
 g_sorcery/backend.py | 79 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 67 insertions(+), 12 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index f637ae0..bbdc337 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -16,7 +16,12 @@ import glob, os
 from .package_db import Package
 
 class Backend(object):
-    def __init__(self, PackageDB, EbuildGenrator, MetadataGenerator, directory,
+    """
+    Backend for a repository.
+    """
+    
+    def __init__(self, package_db_class, ebuild_generator_class,
+                 metadata_generator_class, directory,
                  repo_uri="", db_uri="", sync_db=True, eclass_dir=""):
         self.sync_db = sync_db
         self.repo_uri = repo_uri
@@ -26,33 +31,61 @@ class Backend(object):
         self.directory = directory
         self.backend_data_dir = os.path.join(directory, '.backend_data')
         os.makedirs(self.backend_data_dir)
-        self.db = PackageDB(os.path.join(self.backend_data_dir, 'db'),
+        db_dir = os.path.join(self.backend_data_dir, 'db')
+        self.package_db = package_db_class(db_dir,
                             repo_uri = self.repo_uri,
                             db_uri = self.db_uri)
 
-        self.repo_uri = self.db.repo_uri
-        self.db_uri = self.db.db_uri
+        self.repo_uri = self.package_db.repo_uri
+        self.db_uri = self.package_db.db_uri
 
-        self.eg = EbuildGenrator(self.db)
-        self.mg = MetadataGenerator(self.db)
+        self.ebuild_generator = ebuild_generator_class(self.package_db)
+        self.metadata_generator = metadata_generator_class(self.package_db)
 
     def sync(self):
+        """
+        Synchronize package database.
+        If self.sync_db is set synchronizes with generated database,
+        if it is unset synchronizes with a repository.
+        """        
         if self.sync_db and not self.db_uri:
             Exception("No uri for syncing provided.")
         if not self.sync_db and not self.repo_uri:
             Exception("No repo uri provided.")
         if self.sync_db:
-            self.db.sync()
+            self.package_db.sync()
         else:
-            self.db.generate()
+            self.package_db.generate()
 
     def list_ebuilds(self):
-        return self.db.list_all_packages()
+        """
+        List all the packages in a database.
+
+        Returns:
+            List of all packages in a databes
+            with package_db.Package entries.
+        """
+        return self.package_db.list_all_packages()
 
     def generate_ebuild(self, package):
-        return self.eg.generate(package)
+        """
+        Generate ebuild for a specified package.
+
+        Args:
+            package: package_db.Package instance.
+
+        Returns:
+            Ebuild source as a list of strings.
+        """
+        return self.ebuild_generator.generate(package)
 
     def list_eclasses(self):
+        """
+        List all eclasses.
+
+        Returns:
+            List of all eclasses with string entries.
+        """
         result = []
         if self.eclass_dir:
             for f_name in glob.iglob(os.path.join(self.eclass_dir, '*.eclass')):
@@ -60,6 +93,15 @@ class Backend(object):
         return result
 
     def generate_eclass(self, eclass):
+        """
+        Generate a given eclass.
+
+        Args:
+            eclass: String containing eclass name.
+
+        Returns:
+            Eclass source as a list of strings.
+        """
         if not self.eclass_dir:
             Exception('No eclass dir')
         f_name = os.path.join(self.eclass_dir, eclass + '.eclass')
@@ -72,6 +114,19 @@ class Backend(object):
         return eclass
 
     def generate_metadata(self, category, name):
-        version = self.db.get_max_version(category, name)
-        metadata = self.mg.generate(Package(category, name, version))
+        """
+        Generate metadata for a given package.
+
+        Args:
+            category: category name
+            name: package name
+
+        Returns:
+            Generated metadata as a list of strings.
+            It uses the most recent version of a package
+            to look for data for generation.
+        """
+        version = self.package_db.get_max_version(category, name)
+        metadata = self.metadata_generator.generate(
+            Package(category, name, version))
         return metadata


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-03 22:54 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-03 22:54 UTC (permalink / raw
  To: gentoo-commits

commit:     350919502cefa70740030fe66960fa8f3abaac06
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul  3 22:34:38 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul  3 22:34:38 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=35091950

g_sorcery/metadata: fix

---
 g_sorcery/metadata.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/metadata.py b/g_sorcery/metadata.py
index 7df3fe7..36a2e07 100644
--- a/g_sorcery/metadata.py
+++ b/g_sorcery/metadata.py
@@ -47,7 +47,7 @@ class XMLGenerator(object):
                   empty, it defines a name for an attribute
                   that will distinguish different entries of a tag.
         required: Boolean that defines if a given tag is required.
-        subtags: List a subtags.
+        subtags: List of subtags.
 
     Data dictinonary format.
     ~~~~~~~~~~~~~~~~~~~~~~~~


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-03 22:54 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-03 22:54 UTC (permalink / raw
  To: gentoo-commits

commit:     72a3fd0d67571a0494627c3abe85df76def68ad0
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul  3 22:47:51 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul  3 22:47:51 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=72a3fd0d

g_sorcery/ebuild: hiding pylint swearing

---
 g_sorcery/ebuild.py | 79 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 74 insertions(+), 5 deletions(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index 586bb58..5d1e06b 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -14,18 +14,44 @@
 import string
 
 class EbuildGenerator(object):
-    def __init__(self, db):
-        self.db = db
+    """
+    Ebuild generator.
+    """
+    def __init__(self, package_db):
+        """
+        Args:
+            package_db: Package database.
+        """
+        self.package_db = package_db
 
     def generate(self, package):
+        """
+        Generate an ebuild for a package.
+
+        Args:
+            package: package_db.Package instance.
+
+        Returns:
+            Ebuild source as a list of strings.
+        """
         #a possible exception should be catched in the caller
-        description = self.db.get_package_description(package)
+        description = self.package_db.get_package_description(package)
         ebuild = self.get_template(package, description)
         ebuild = self.process(ebuild, description)
         ebuild = self.postprocess(ebuild, description)
         return ebuild
 
     def process(self, ebuild, description):
+        """
+        Fill ebuild tamplate with data.
+
+        Args:
+            ebuild: Ebuild template.
+            description: Dictionary with ebuild description.
+
+        Returns:
+            Ebuild source as a list of strings.
+        """
         result = []
         for line in ebuild:
             tmpl = string.Template(line)
@@ -33,17 +59,50 @@ class EbuildGenerator(object):
         return result
         
     def get_template(self, package, description):
+        """
+        Generate ebuild tamplate. Should be overriden.
+
+        Args:
+            package: package_db.Package instance.
+            description: Dictionary with ebuild description.
+
+        Returns:
+            Ebuild template.
+        """
         ebuild = []
         return ebuild
         
     def postprocess(self, ebuild, description):
+        """
+        Hook to be overriden.
+
+        Args:
+            ebuild: Ebuild source as a list of strings.
+            description: Dictionary with ebuild description.
+
+        Returns:
+            Ebuild source as a list of strings.
+        """
         return ebuild
 
 class EbuildGeneratorFromFile(EbuildGenerator):
-    def __init__(self, db):
-        super(EbuildGeneratorFromFile, self).__init__(db)
+    """
+    Ebuild generators that takes templates from files.
+    """
+    def __init__(self, package_db):
+        super(EbuildGeneratorFromFile, self).__init__(package_db)
 
     def get_template(self, package, description):
+        """
+        Generate ebuild tamplate.
+
+        Args:
+            package: package_db.Package instance.
+            description: Dictionary with ebuild description.
+
+        Returns:
+            Ebuild template.
+        """
         name = self.get_template_file(package, description)
         with open(name, 'r') as f:
             ebuild = f.read().split('\n')
@@ -52,4 +111,14 @@ class EbuildGeneratorFromFile(EbuildGenerator):
         return ebuild
 
     def get_template_file(self, package, description):
+        """
+        Get template filename for a package. Should be overriden.
+        
+        Args:
+            package: package_db.Package instance.
+            description: Dictionary with ebuild description.
+
+        Returns:
+            Template filename.
+        """
         return ""


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-03 22:54 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-03 22:54 UTC (permalink / raw
  To: gentoo-commits

commit:     299f2edd32b6f026189403563f074ce48ce78e98
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul  3 22:54:34 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul  3 22:54:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=299f2edd

g_sorcery/fileutils: hiding pylint swearing

---
 g_sorcery/fileutils.py | 44 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 41 insertions(+), 3 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 37591b3..ed68f65 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -16,11 +16,15 @@ import json, os, shutil
 from .exceptions import FileJSONError
 
 class FileJSON(object):
+    """
+    Class for JSON files.
+    """
     def __init__(self, directory, name, mandatories):
         """
-        Initialize
-
-        mandatories -- list of mandatory keys
+        Args:
+            directory: File directory.
+            name: File name.
+            mandatories: List of requiered keys.
         """
         self.directory = os.path.abspath(directory)
         self.name = name
@@ -28,6 +32,9 @@ class FileJSON(object):
         self.mandatories = mandatories
 
     def read(self):
+        """
+        Read JSON file.
+        """
         if not os.path.exists(self.directory):
             os.makedirs(self.directory)
         content = {}
@@ -45,6 +52,9 @@ class FileJSON(object):
         return content
 
     def write(self, content):
+        """
+        Write JSON file.
+        """
         for key in self.mandatories:
             if not key in content:
                 raise FileJSONError('lack of mandatory key: ' + key)
@@ -55,6 +65,17 @@ class FileJSON(object):
 
 
 def hash_file(name, hasher, blocksize=65536):
+    """
+    Get a file hash.
+
+    Args:
+        name: file name.
+        hasher: Hasher.
+        blocksize: Blocksize.
+
+    Returns:
+        Hash value.
+    """
     with open(name, 'rb') as f:
         buf = f.read(blocksize)
         while len(buf) > 0:
@@ -63,6 +84,13 @@ def hash_file(name, hasher, blocksize=65536):
     return hasher.hexdigest()
 
 def copy_all(src, dst):
+    """
+    Copy entire tree.
+
+    Args:
+       src: Source.
+       dst: Destination.
+    """
     for f_name in os.listdir(src):
         src_name = os.path.join(src, f_name)
         dst_name = os.path.join(dst, f_name)
@@ -72,4 +100,14 @@ def copy_all(src, dst):
             shutil.copy2(src_name, dst_name)
 
 def wget(uri, directory):
+    """
+    Fetch a file.
+
+    Args:
+        uri: URI.
+        directory: Directory where file should be saved.
+
+    Returns:
+        Nonzero in case of a failure.
+    """
     return os.system('wget -P ' + directory + ' ' + uri)


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-03 23:32 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-03 23:32 UTC (permalink / raw
  To: gentoo-commits

commit:     5b73fac8cab9ea8516292f5d7e07b8c56b9a4358
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul  3 23:34:14 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul  3 23:34:14 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=5b73fac8

g_sorcery/ebuild: EbuildGeneratorFromFile: default filename

---
 g_sorcery/ebuild.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index 5d1e06b..9529220 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -89,8 +89,9 @@ class EbuildGeneratorFromFile(EbuildGenerator):
     """
     Ebuild generators that takes templates from files.
     """
-    def __init__(self, package_db):
+    def __init__(self, package_db, filename=""):
         super(EbuildGeneratorFromFile, self).__init__(package_db)
+        self.filename = filename
 
     def get_template(self, package, description):
         """
@@ -121,4 +122,4 @@ class EbuildGeneratorFromFile(EbuildGenerator):
         Returns:
             Template filename.
         """
-        return ""
+        return self.filename


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-03 23:49 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-03 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     024082326314d918e7c5d5245323a949bf16d3dd
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul  3 23:38:45 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul  3 23:38:45 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=02408232

g_sorcery/fileutils: get_pkgpath

---
 g_sorcery/fileutils.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index ed68f65..5cafc36 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -111,3 +111,15 @@ def wget(uri, directory):
         Nonzero in case of a failure.
     """
     return os.system('wget -P ' + directory + ' ' + uri)
+
+def get_pkgpath():
+    """
+    Get package path.
+
+    Returns:
+        Package path.
+    """
+     root = __file__
+     if os.path.islink(root):
+         root = os.path.realpath(root)
+     return os.path.dirname(os.path.abspath(root))


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-03 23:49 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-03 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     3ec16e18c9d58f78fbdc0b138fe3e13c1f856864
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul  3 23:39:36 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul  3 23:39:36 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=3ec16e18

g_sorcery/fileutils: fix indent

---
 g_sorcery/fileutils.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 5cafc36..659df41 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -119,7 +119,7 @@ def get_pkgpath():
     Returns:
         Package path.
     """
-     root = __file__
-     if os.path.islink(root):
-         root = os.path.realpath(root)
-     return os.path.dirname(os.path.abspath(root))
+    root = __file__
+    if os.path.islink(root):
+        root = os.path.realpath(root)
+    return os.path.dirname(os.path.abspath(root))


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-04 20:24 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-04 20:24 UTC (permalink / raw
  To: gentoo-commits

commit:     67918dfbb2b96bd82721fd18252d9ba4256499e0
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Jul  4 20:25:35 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Jul  4 20:25:35 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=67918dfb

g_sorcery/ebuild: list substitution added to ebuild processing

---
 g_sorcery/ebuild.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index 83fcb13..2737577 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -98,7 +98,10 @@ class EbuildGenerator(object):
         result = []
         for line in ebuild:
             tmpl = string.Template(line)
-            result.append(tmpl.substitute(description))
+            line = tmpl.substitute(description)
+            line = substitute_list(line, description)
+            result.append(line)
+            
         return result
         
     def get_template(self, package, description):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-13 15:12 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-13 15:12 UTC (permalink / raw
  To: gentoo-commits

commit:     a04df7efe4a2466beb8193db5c95cebebe4af77d
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jul 13 15:11:54 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jul 13 15:11:54 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=a04df7ef

g_sorcery/collections -> g_sorcery/g_collections

---
 g_sorcery/collections.py | 47 -----------------------------------------------
 1 file changed, 47 deletions(-)

diff --git a/g_sorcery/collections.py b/g_sorcery/collections.py
deleted file mode 100644
index abc1c14..0000000
--- a/g_sorcery/collections.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
-    collections.py
-    ~~~~~~~~~~~~~~
-    
-    Customized classes of standard python data types
-    for use withing g-sorcery for custom formatted string output
-    substitution in our ebuild templates.
-    
-    :copyright: (c) 2013 by Brian Dolbec
-    :copyright: (c) 2013 by Jauhien Piatlicki
-    :license: GPL-2, see LICENSE for more details.
-"""
-
-import collections
-
-class elist(list):
-    '''Custom list type which adds a customized __str__()
-    and takes an optional separator argument
-
-    elist() -> new empty elist
-    elist(iterable) -> new elist initialized from iterable's items
-    elist(separator='\\n\\t') -> new empty elist with
-        newline & tab indented str(x) output
-    elist(iterable, ' ') -> new elist initialized from iterable's items
-        with space separated str(x) output
-    '''
-
-    __slots__ = ('_sep_')
-
-    def __init__(self, iterable=None, separator=' '):
-        '''
-        iterable: initialize from iterable's items
-        separator: string used to join list members with for __str__()
-        '''
-        list.__init__(self, iterable or [])
-        self._sep_ = separator
-
-    def __str__(self):
-        '''Custom output function
-        'x.__str__() <==> str(separator.join(x))'
-        '''
-        return self._sep_.join(self)
-
-Package = collections.namedtuple("Package", "category name version")


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-13 15:12 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-13 15:12 UTC (permalink / raw
  To: gentoo-commits

commit:     88457b31c20b00478f41f559ff0f6afbada557cf
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jul 13 15:12:15 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jul 13 15:12:15 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=88457b31

g_sorcery/ebuild: typo

---
 g_sorcery/ebuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index dd552aa..d196d8b 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -60,7 +60,7 @@ class EbuildGenerator(object):
             except ValueError as e:
                 error = str(e)
             if error:
-                error = "sunstitution failed in line '" + line + "': " + error
+                error = "substitution failed in line '" + line + "': " + error
                 raise DependencyError(error)
             result.append(line)
             


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-13 22:22 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-13 22:22 UTC (permalink / raw
  To: gentoo-commits

commit:     5c4d205605853d0114ab038c84d32af507969f59
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jul 13 22:22:10 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jul 13 22:22:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=5c4d2056

g_sorcery/backend: pkgmanager flags, py2k compatibility

---
 g_sorcery/backend.py   |  3 +--
 g_sorcery/g_sorcery.py | 10 ++++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index c5f8409..1013411 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -294,8 +294,7 @@ class Backend(object):
                 return -1
             package_manager_class = package_managers[package_manager]
         package_manager = package_manager_class()
-        package_manager.install(args.pkgname)
-        
+        package_manager.install(args.pkgname, *args.pkgmanager_flags)
         
     def __call__(self, args, config, global_config):
         args = self.parser.parse_args(args)

diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py
index 756532e..bb3530e 100644
--- a/g_sorcery/g_sorcery.py
+++ b/g_sorcery/g_sorcery.py
@@ -11,13 +11,19 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
-import configparser
+
 import importlib
 import os
 import sys
 
-from .fileutils import FileJSON
+from .compatibility import py2k
 
+if py2k:
+    import ConfigParser as configparser
+else:
+    import configparser
+
+from .fileutils import FileJSON
 from .exceptions import FileJSONError
 
 def main():


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-13 23:35 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-13 23:35 UTC (permalink / raw
  To: gentoo-commits

commit:     dd2b85c882dad1cf37baf3528b172c39022b2e69
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sat Jul 13 23:35:49 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sat Jul 13 23:35:49 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=dd2b85c8

g_sorcery/logger: logger with better output added

---
 g_sorcery/backend.py   | 35 ++++++++++++++++++++++-------------
 g_sorcery/g_sorcery.py | 12 +++++++-----
 g_sorcery/logger.py    | 28 ++++++++++++++++++++++++++++
 g_sorcery/mangler.py   |  4 ++++
 4 files changed, 61 insertions(+), 18 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index d1f7ed4..0803379 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -25,6 +25,7 @@ else:
 
 from .g_collections import Package
 from .exceptions import DependencyError, DigestError
+from .logger import Logger
 from .mangler import package_managers
 
 class Backend(object):
@@ -80,11 +81,13 @@ class Backend(object):
         p_install.add_argument('pkgmanager_flags', nargs=argparse.REMAINDER)
         p_install.set_defaults(func=self.install)
 
+        self.logger = Logger()
+
     def get_overlay(self, args, config, global_config):
         overlay = args.overlay
         if not overlay:
             if not 'default_overlay' in config:
-               print("No overlay given, exiting.")
+               self.logger.error("no overlay given, exiting.")
                return None
             else:
                 overlay = config['default_overlay']
@@ -99,25 +102,25 @@ class Backend(object):
         if self.sync_db:
             pkg_db = self.package_db_class(db_path, db_uri=url)
             if not pkg_db.db_uri:
-                sys.stderr.write('No url given\n')
+                self.logger.error('no url given\n')
                 return -1
         else:
             pkg_db = self.package_db_class(db_path, repo_uri=url)
             if not pkg_db.repo_uri:
-                sys.stderr.write('No url given\n')
+                self.logger.error('no url given\n')
                 return -1
 
         if self.sync_db:
             try:
                 pkg_db.sync(db_uri=url)
             except Exception as e:
-                sys.stderr.write('Sync failed: ' + str(e) + '\n')
+                self.logger.error('sync failed: ' + str(e) + '\n')
                 return -1
         else:
             try:
                 pkg_db.generate(repo_uri=url)
             except Exception as e:
-                sys.stderr.write('Sync failed: ' + str(e) + '\n')
+                self.logger.error('sync failed: ' + str(e) + '\n')
                 return -1
         return 0
 
@@ -141,7 +144,7 @@ class Backend(object):
                     print('    Available versions: ' + ' '.join(versions))
                     print('\n')
         except Exception as e:
-            sys.stderr.write('List failed: ' + str(e) + '\n')
+            self.logger.error('list failed: ' + str(e) + '\n')
             return -1
         return 0
 
@@ -165,7 +168,7 @@ class Backend(object):
             category = parts[0]
             name = parts[1]
         else:
-            sys.stderr.write('Bad package name: ' + pkgname + '\n')
+            self.logger.error('bad package name: ' + pkgname + '\n')
             return -1
 
         if not category:
@@ -176,14 +179,14 @@ class Backend(object):
                     categories.append(cat)
 
             if not len(categories):
-                sys.stderr.write('No package with name ' + pkgname + ' found\n')
+                self.logger.error('no package with name ' + pkgname + ' found\n')
                 return -1
                     
             if len(categories) > 1:
-                sys.stderr.write('Ambiguous packagename: ' + pkgname + '\n')
-                sys.stderr.write('Please select one of the following packages:\n')
+                self.logger.error('ambiguous packagename: ' + pkgname + '\n')
+                self.logger.error('please select one of the following packages:\n')
                 for cat in categories:
-                    sys.stderr.write('    ' + cat + '/' + pkgname + '\n')
+                    self.logger.error('    ' + cat + '/' + pkgname + '\n')
                 return -1
                 
             category = categories[0]
@@ -193,7 +196,7 @@ class Backend(object):
             for version in versions:
                 dependencies |= self.solve_dependencies(pkg_db, Package(category, name, version))[0]
         except Exception as e:
-            sys.stderr.write('Dependency solving failed: ' + str(e) + '\n')
+            self.logger.error('dependency solving failed: ' + str(e) + '\n')
             return -1
         
         eclasses = []
@@ -207,6 +210,7 @@ class Backend(object):
         return 0
 
     def generate_ebuilds(self, package_db, overlay, packages, digest=False):
+        self.logger.info("ebuild generation")
         if digest:
             ebuild_g = self.ebuild_g_with_digest_class(package_db)
         else:
@@ -215,6 +219,7 @@ class Backend(object):
             category = package.category
             name = package.name
             version = package.version
+            self.logger.info("    generating " + category + '/' + name + '-' + version)
             path = os.path.join(overlay, category, name)
             if not os.path.exists(path):
                 os.makedirs(path)
@@ -225,6 +230,7 @@ class Backend(object):
 
 
     def generate_metadatas(self, package_db, overlay, packages):
+        self.logger.info("metadata generation")
         metadata_g = self.metadata_g_class(package_db)
         for package in packages:
             path = os.path.join(overlay, package.category, package.name)
@@ -236,11 +242,13 @@ class Backend(object):
                     f.write(line + '\n')
 
     def generate_eclasses(self, overlay, eclasses):
+        self.logger.info("eclasses generation")
         eclass_g = self.eclass_g_class()
         path = os.path.join(overlay, 'eclass')
         if not os.path.exists(path):
             os.makedirs(path)
         for eclass in eclasses:
+            self.logger.info("    generating " + eclass + " eclass")
             source = eclass_g.generate(eclass)
         with open(os.path.join(path, eclass + '.eclass'), 'w') as f:
             for line in source:
@@ -282,6 +290,7 @@ class Backend(object):
 
 
     def digest(self, overlay):
+        self.logger.info("digesting overlay")
         prev = os.getcwd()
         os.chdir(overlay)
         if os.system("repoman manifest"):
@@ -300,7 +309,7 @@ class Backend(object):
             package_manager = None
         if  package_manager:
             if not package_manager in package_managers:
-                sys.stderr.write('Not supportes package manager: ' + package_manager + '\n')
+                self.logger.error('not supported package manager: ' + package_manager + '\n')
                 return -1
             package_manager_class = package_managers[package_manager]
         package_manager = package_manager_class()

diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py
index 2289476..690f4cf 100644
--- a/g_sorcery/g_sorcery.py
+++ b/g_sorcery/g_sorcery.py
@@ -25,11 +25,13 @@ else:
 
 from .fileutils import FileJSON
 from .exceptions import FileJSONError
+from .logger import Logger
 
 def main():
+    logger = Logger()
     if len(sys.argv) < 2:
-        print("No backend specified")
-        return 0
+        logger.error("no backend specified")
+        return -1
     name = sys.argv[1]
     cfg = name + '.json'
     cfg_path = None
@@ -39,13 +41,13 @@ def main():
             cfg_path = path
             break
     if not cfg_path:
-        sys.stderr.write('g-sorcery error: no config file for ' + name + ' backend\n')
+        logger.error('no config file for ' + name + ' backend\n')
         return -1
     cfg_f = FileJSON(cfg_path, cfg, ['package'])
     try:
         config = cfg_f.read()
     except FileJSONError as e:
-        sys.stderr.write('g-sorcery error in config file for ' + name + ': ' + str(e) + '\n')
+        logger.error('error loading config file for ' + name + ': ' + str(e) + '\n')
         return -1
     backend = get_backend(config['package'])
 
@@ -58,7 +60,7 @@ def main():
             config_file = None
 
     if not config_file:
-        sys.stderr.write('g-sorcery error: no global config file\n')
+        logger.error('no global config file\n')
         return -1
     
     global_config = configparser.ConfigParser()

diff --git a/g_sorcery/logger.py b/g_sorcery/logger.py
new file mode 100644
index 0000000..8a95b85
--- /dev/null
+++ b/g_sorcery/logger.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+    logger.py
+    ~~~~~~~~~
+    
+    logging classes
+    
+    :copyright: (c) 2013 by Jauhien Piatlicki
+    :license: GPL-2, see LICENSE for more details.
+"""
+
+import portage
+
+
+class Logger(object):
+    def __init__(self):
+        self.out = portage.output.EOutput()
+
+    def error(self, message):
+        self.out.eerror(message)
+
+    def info(self, message):
+        self.out.einfo(message)
+
+    def warn(self, message):
+        self.out.ewarn(message)

diff --git a/g_sorcery/mangler.py b/g_sorcery/mangler.py
index 5826de5..fbdcdd3 100644
--- a/g_sorcery/mangler.py
+++ b/g_sorcery/mangler.py
@@ -13,6 +13,7 @@
 
 import os
 
+from .logger import Logger
 
 class PackageManager(object):
     """
@@ -20,11 +21,14 @@ class PackageManager(object):
     """
 
     executable = ""
+    logger = Logger()
     
     def __init__(self):
         pass
 
     def run_command(self, *args):
+        command = self.executable + " " + " ".join(args)
+        self.logger.info("running a package mangler: " + command)
         return os.system(self.executable + " " + " ".join(args))
 
     def install(self, pkgname, *args):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-14 23:47 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-14 23:47 UTC (permalink / raw
  To: gentoo-commits

commit:     57cb1e3d4722565cc41a04d16af0cee8005b95ed
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Jul 14 23:47:23 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Jul 14 23:47:23 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=57cb1e3d

g_sorcery/backend: clean overlay, repo_name

---
 g_sorcery/backend.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 6e2a985..e17419d 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -328,6 +328,11 @@ class Backend(object):
         overlay = self._get_overlay(args, config, global_config)
         pkg_db = self._get_package_db(args, config, global_config)
         pkg_db.read()
+
+        os.system('rm -rf ' + overlay + '/*')
+        os.makedirs(os.path.join(overlay, 'profiles'))
+        os.system("echo " + os.path.basename(overlay) + '>' + \
+                  os.path.join(overlay, 'profiles', 'repo_name'))
         
         if args.digest:
             ebuild_g = self.ebuild_g_with_digest_class(pkg_db)
@@ -363,7 +368,7 @@ class Backend(object):
             with open(os.path.join(path, eclass + '.eclass'), 'w') as f:
                 for line in source:
                     f.write(line + '\n')
-
+                    
         self.digest(overlay)
 
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-15  0:18 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-15  0:18 UTC (permalink / raw
  To: gentoo-commits

commit:     30b2612e563e66a821bd8b9a39810d441604d0eb
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Jul 15 00:18:24 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Jul 15 00:18:24 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=30b2612e

g_sorcery/backend: fix, thanks to dol-sen

---
 g_sorcery/backend.py | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index e17419d..c4d3383 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -251,8 +251,7 @@ class Backend(object):
                 os.makedirs(path)
             source = ebuild_g.generate(package)
             with open(os.path.join(path, name + '-' + version + '.ebuild'), 'w') as f:
-                for line in source:
-                    f.write(line + '\n')
+                f.write('\n'.join(source))
 
 
     def generate_metadatas(self, package_db, overlay, packages):
@@ -264,8 +263,7 @@ class Backend(object):
                 os.makedirs(path)
             source = metadata_g.generate(package)
             with open(os.path.join(path, 'metadata.xml'), 'w') as f:
-                for line in source:
-                    f.write(line + '\n')
+                f.write('\n'.join(source))
 
     def generate_eclasses(self, overlay, eclasses):
         self.logger.info("eclasses generation")
@@ -277,8 +275,7 @@ class Backend(object):
             self.logger.info("    generating " + eclass + " eclass")
             source = eclass_g.generate(eclass)
             with open(os.path.join(path, eclass + '.eclass'), 'w') as f:
-                for line in source:
-                    f.write(line + '\n')
+                f.write('\n'.join(source))
 
 
     def solve_dependencies(self, package_db, package, solved_deps=None, unsolved_deps=None):
@@ -350,13 +347,11 @@ class Backend(object):
                 os.makedirs(path)
             source = ebuild_g.generate(package, ebuild_data)
             with open(os.path.join(path, name + '-' + version + '.ebuild'), 'w') as f:
-                for line in source:
-                    f.write(line + '\n')
+                f.write('\n'.join(source))
 
             source = metadata_g.generate(package)
             with open(os.path.join(path, 'metadata.xml'), 'w') as f:
-                for line in source:
-                    f.write(line + '\n')
+                f.write('\n'.join(source))
 
         eclass_g = self.eclass_g_class()
         path = os.path.join(overlay, 'eclass')
@@ -366,8 +361,7 @@ class Backend(object):
         for eclass in eclass_g.list():
             source = eclass_g.generate(eclass)
             with open(os.path.join(path, eclass + '.eclass'), 'w') as f:
-                for line in source:
-                    f.write(line + '\n')
+                f.write('\n'.join(source))
                     
         self.digest(overlay)
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-15 16:33 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-15 16:33 UTC (permalink / raw
  To: gentoo-commits

commit:     2744da31877c81d4a373db4554b79f2cb6a579c5
Author:     Jauhien Piatlicki <jpiatlicki <AT> zertisa <DOT> com>
AuthorDate: Mon Jul 15 16:32:54 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Jul 15 16:32:54 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=2744da31

g_sorcery/fileutils: fast_manifest

---
 g_sorcery/fileutils.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 478570d..067ea42 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -11,7 +11,11 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
-import json, os, shutil
+import glob
+import json
+import hashlib
+import os
+import shutil
 
 from .exceptions import FileJSONError
 from .g_collections import Package, elist
@@ -153,3 +157,44 @@ def get_pkgpath(root = None):
     if os.path.islink(root):
         root = os.path.realpath(root)
     return os.path.dirname(os.path.abspath(root))
+
+class ManifestEntry:
+    def __init__(self, directory, name, ftype):
+        self.directory = directory
+        self.name = name
+        self.ftype = ftype
+        self.digest()
+
+    def digest(self):
+        h_sha256 = hashlib.new('SHA256')
+        h_sha512 = hashlib.new('SHA512')
+        h_whirlpool = hashlib.new('whirlpool')
+        with open(os.path.join(self.directory, self.name), 'rb') as f:
+            src = f.read()
+        h_sha256.update(src)
+        h_sha512.update(src)
+        h_whirlpool.update(src)
+        self.size = str(len(src))
+        self.sha256 = h_sha256.hexdigest()
+        self.sha512 = h_sha512.hexdigest()
+        self.whirlpool = h_whirlpool.hexdigest()
+
+
+def fast_manifest(directory):
+    manifest = []
+    metadata = os.path.join(directory, "metadata.xml")
+
+    for aux in glob.glob(os.path.join(directory, "files/*")):
+        manifest.append(ManifestEntry(os.path.dirname(aux), os.path.basename(aux), "AUX"))
+    for ebuild in glob.glob(os.path.join(directory, "*.ebuild")):
+        manifest.append(ManifestEntry(directory, os.path.basename(ebuild), "EBUILD"))
+    if (os.path.isfile(metadata)):
+        manifest.append(ManifestEntry(directory, "metadata.xml", "MISC"))
+
+    manifest = [" ".join([m.ftype, m.name, m.size,
+                          "SHA256", m.sha256, "SHA512", m.sha512,
+                          "WHIRLPOOL", m.whirlpool])
+                for m in manifest]
+
+    with open(os.path.join(directory, "Manifest"), 'w') as f:
+        f.write('\n'.join(manifest))


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-15 17:20 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-15 17:20 UTC (permalink / raw
  To: gentoo-commits

commit:     6c2d91d14a9cc24aafb66e565e4e5581c793b03a
Author:     Jauhien Piatlicki <jpiatlicki <AT> zertisa <DOT> com>
AuthorDate: Mon Jul 15 17:19:49 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Jul 15 17:19:49 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=6c2d91d1

g_sorcery/backend: fast overlay digesting added

---
 g_sorcery/backend.py    | 14 ++++++++++++--
 g_sorcery/fileutils.py  |  2 +-
 g_sorcery/package_db.py |  3 +++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index c4d3383..85a6218 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -24,6 +24,7 @@ else:
     import configparser
 
 from .g_collections import Package
+from .fileutils import fast_manifest
 from .exceptions import DependencyError, DigestError
 from .logger import Logger
 from .mangler import package_managers
@@ -319,6 +320,12 @@ class Backend(object):
         if os.system("repoman manifest"):
             raise DigestError('repoman manifest failed')
         os.chdir(prev)
+
+    def fast_digest(self, overlay, pkgnames):
+        self.logger.info("fast digesting overlay")
+        for pkgname in pkgnames:
+            directory = os.path.join(overlay, pkgname)
+            fast_manifest(directory)
         
     def generate_tree(self, args, config, global_config):
         self.logger.info("tree generation")
@@ -362,9 +369,12 @@ class Backend(object):
             source = eclass_g.generate(eclass)
             with open(os.path.join(path, eclass + '.eclass'), 'w') as f:
                 f.write('\n'.join(source))
-                    
-        self.digest(overlay)
 
+        if args.digest:
+            self.digest(overlay)
+        else:
+            pkgnames = pkg_db.list_catpkg_names()
+            self.fast_digest(overlay, pkgnames)
 
     def install(self, args, config, global_config):
         self.generate(args, config, global_config)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 067ea42..d0d154a 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -197,4 +197,4 @@ def fast_manifest(directory):
                 for m in manifest]
 
     with open(os.path.join(directory, "Manifest"), 'w') as f:
-        f.write('\n'.join(manifest))
+        f.write('\n'.join(manifest) + '\n')

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index c42aa30..b6db2ba 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -489,6 +489,9 @@ class PackageDB(object):
         res = [x.split('/')[1] for x in self.database if x.split('/')[0] == category]
         return res
 
+    def list_catpkg_names(self):
+        return list(self.database)
+
     def list_package_versions(self, category, name):
         """
         List package versions.


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-16 23:09 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-16 23:09 UTC (permalink / raw
  To: gentoo-commits

commit:     83644c95ac2cf6e020663bf51a85b9411e25020c
Author:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Jul 15 16:32:54 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Jul 15 16:32:54 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=83644c95

g_sorcery/fileutils: fast_manifest

---
 g_sorcery/fileutils.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 478570d..067ea42 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -11,7 +11,11 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
-import json, os, shutil
+import glob
+import json
+import hashlib
+import os
+import shutil
 
 from .exceptions import FileJSONError
 from .g_collections import Package, elist
@@ -153,3 +157,44 @@ def get_pkgpath(root = None):
     if os.path.islink(root):
         root = os.path.realpath(root)
     return os.path.dirname(os.path.abspath(root))
+
+class ManifestEntry:
+    def __init__(self, directory, name, ftype):
+        self.directory = directory
+        self.name = name
+        self.ftype = ftype
+        self.digest()
+
+    def digest(self):
+        h_sha256 = hashlib.new('SHA256')
+        h_sha512 = hashlib.new('SHA512')
+        h_whirlpool = hashlib.new('whirlpool')
+        with open(os.path.join(self.directory, self.name), 'rb') as f:
+            src = f.read()
+        h_sha256.update(src)
+        h_sha512.update(src)
+        h_whirlpool.update(src)
+        self.size = str(len(src))
+        self.sha256 = h_sha256.hexdigest()
+        self.sha512 = h_sha512.hexdigest()
+        self.whirlpool = h_whirlpool.hexdigest()
+
+
+def fast_manifest(directory):
+    manifest = []
+    metadata = os.path.join(directory, "metadata.xml")
+
+    for aux in glob.glob(os.path.join(directory, "files/*")):
+        manifest.append(ManifestEntry(os.path.dirname(aux), os.path.basename(aux), "AUX"))
+    for ebuild in glob.glob(os.path.join(directory, "*.ebuild")):
+        manifest.append(ManifestEntry(directory, os.path.basename(ebuild), "EBUILD"))
+    if (os.path.isfile(metadata)):
+        manifest.append(ManifestEntry(directory, "metadata.xml", "MISC"))
+
+    manifest = [" ".join([m.ftype, m.name, m.size,
+                          "SHA256", m.sha256, "SHA512", m.sha512,
+                          "WHIRLPOOL", m.whirlpool])
+                for m in manifest]
+
+    with open(os.path.join(directory, "Manifest"), 'w') as f:
+        f.write('\n'.join(manifest))


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-16 23:09 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-16 23:09 UTC (permalink / raw
  To: gentoo-commits

commit:     a2f8e24a10bb4872c8ec0450cd20e35ddd444b28
Author:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Jul 15 17:19:49 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Jul 15 17:19:49 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=a2f8e24a

g_sorcery/backend: fast overlay digesting added

---
 g_sorcery/backend.py    | 14 ++++++++++++--
 g_sorcery/fileutils.py  |  2 +-
 g_sorcery/package_db.py |  3 +++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index c4d3383..85a6218 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -24,6 +24,7 @@ else:
     import configparser
 
 from .g_collections import Package
+from .fileutils import fast_manifest
 from .exceptions import DependencyError, DigestError
 from .logger import Logger
 from .mangler import package_managers
@@ -319,6 +320,12 @@ class Backend(object):
         if os.system("repoman manifest"):
             raise DigestError('repoman manifest failed')
         os.chdir(prev)
+
+    def fast_digest(self, overlay, pkgnames):
+        self.logger.info("fast digesting overlay")
+        for pkgname in pkgnames:
+            directory = os.path.join(overlay, pkgname)
+            fast_manifest(directory)
         
     def generate_tree(self, args, config, global_config):
         self.logger.info("tree generation")
@@ -362,9 +369,12 @@ class Backend(object):
             source = eclass_g.generate(eclass)
             with open(os.path.join(path, eclass + '.eclass'), 'w') as f:
                 f.write('\n'.join(source))
-                    
-        self.digest(overlay)
 
+        if args.digest:
+            self.digest(overlay)
+        else:
+            pkgnames = pkg_db.list_catpkg_names()
+            self.fast_digest(overlay, pkgnames)
 
     def install(self, args, config, global_config):
         self.generate(args, config, global_config)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 067ea42..d0d154a 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -197,4 +197,4 @@ def fast_manifest(directory):
                 for m in manifest]
 
     with open(os.path.join(directory, "Manifest"), 'w') as f:
-        f.write('\n'.join(manifest))
+        f.write('\n'.join(manifest) + '\n')

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index c42aa30..b6db2ba 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -489,6 +489,9 @@ class PackageDB(object):
         res = [x.split('/')[1] for x in self.database if x.split('/')[0] == category]
         return res
 
+    def list_catpkg_names(self):
+        return list(self.database)
+
     def list_package_versions(self, category, name):
         """
         List package versions.


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-17  8:06 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-17  8:06 UTC (permalink / raw
  To: gentoo-commits

commit:     8b184daf4fa77ba7b0dfdb32cf0ddce58ce665ec
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul 17 08:06:08 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul 17 08:06:08 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=8b184daf

g_sorcery/ebuild: fix typo

---
 g_sorcery/ebuild.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index 6fbc7cb..19b9a1f 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -49,7 +49,7 @@ class EbuildGenerator(object):
 
     def process(self, ebuild, ebuild_data):
         """
-        Fill ebuild tamplate with data.
+        Fill ebuild template with data.
 
         Args:
             ebuild: Ebuild template.
@@ -74,7 +74,7 @@ class EbuildGenerator(object):
         
     def get_template(self, package, ebuild_data):
         """
-        Generate ebuild tamplate. Should be overriden.
+        Generate ebuild template. Should be overriden.
 
         Args:
             package: package_db.Package instance.
@@ -109,7 +109,7 @@ class EbuildGeneratorFromFile(EbuildGenerator):
 
     def get_template(self, package, ebuild_data):
         """
-        Generate ebuild tamplate.
+        Generate ebuild template.
 
         Args:
             package: package_db.Package instance.
@@ -153,7 +153,7 @@ class DefaultEbuildGenerator(EbuildGenerator):
         self.template.append("")
 
         if hasattr(layout, "vars_before_inherit"):
-            self._append_vars_to_tamplate(layout.vars_before_inherit)
+            self._append_vars_to_template(layout.vars_before_inherit)
             self.template.append("")
 
         if hasattr(layout, "inherit"):
@@ -161,14 +161,14 @@ class DefaultEbuildGenerator(EbuildGenerator):
             self.template.append("")
 
         if hasattr(layout, "vars_after_inherit"):
-            self._append_vars_to_tamplate(layout.vars_after_inherit)
+            self._append_vars_to_template(layout.vars_after_inherit)
             self.template.append("")
 
         self.template.append('DESCRIPTION="%(description)s"')
         self.template.append("")
 
         if hasattr(layout, "vars_after_description"):
-            self._append_vars_to_tamplate(layout.vars_after_description)
+            self._append_vars_to_template(layout.vars_after_description)
             self.template.append("")
 
         self.template.append('SLOT="0"')
@@ -176,11 +176,11 @@ class DefaultEbuildGenerator(EbuildGenerator):
         self.template.append("")
 
         if hasattr(layout, "vars_after_keywords"):
-            self._append_vars_to_tamplate(layout.vars_after_keywords)
+            self._append_vars_to_template(layout.vars_after_keywords)
             self.template.append("")
         
 
-    def _append_vars_to_tamplate(self, variables):
+    def _append_vars_to_template(self, variables):
         VAR_NAME = 0
         VAR_VALUE = 1
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-17 17:05 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-17 17:05 UTC (permalink / raw
  To: gentoo-commits

commit:     1a08be09e50ba9bdce2e7838db2d120f22279e80
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul 17 17:04:20 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul 17 17:04:20 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=1a08be09

g_sorcery/fileutils: xz files support

---
 g_sorcery/fileutils.py  | 15 ++++++++-------
 g_sorcery/package_db.py |  5 +----
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 115f330..cdec458 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -212,8 +212,7 @@ def _call_loader(f_name, loader, open_file = True, open_mode = 'r'):
     return {os.path.basename(f_name): data}
 
 
-def load_remote_file(uri, loader, open_file = True, open_mode='r',
-                     process_unpacked_as_directory = False):
+def load_remote_file(uri, loader, open_file = True, open_mode='r'):
     download_dir = TemporaryDirectory()
     loaded_data = {}
     if wget(uri, download_dir.name):
@@ -223,14 +222,16 @@ def load_remote_file(uri, loader, open_file = True, open_mode='r',
             unpack_dir = TemporaryDirectory()
             with tarfile.open(f_name) as f:
                 f.extractall(unpack_dir.name)
-            if process_unpacked_as_directory:
-                loaded_data.update(_call_loader(unpack_dir.name, loader, open_file=False))
-            else:
-                for uf_name in glob.glob(os.path.join(unpack_dir, "*")):
-                    loaded_data.update(_call_loader(uf_name, loader,
+            for uf_name in glob.glob(os.path.join(unpack_dir, "*")):
+                loaded_data.update(_call_loader(uf_name, loader,
                                     open_file=open_file, open_mode=open_mode))
             del unpack_dir
         else:
+            name, extention = os.path.splitext(f_name)
+            if (extention == ".xz"):
+                if (os.system("xz -d " + f_name)):
+                    raise DownloadingError("xz failed: " + f_name + " from " + uri)
+                f_name = name
             loaded_data.update(_call_loader(f_name, loader,
                                 open_file=open_file, open_mode=open_mode))
     del download_dir

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 8b256e0..2d8ee42 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -179,7 +179,7 @@ class PackageDB(object):
         data = self.download_data()
         self.parse_data(data)
 
-    def load_data(self):
+    def load_data(self, data_f):
         pass
 
     def parse_data(data):
@@ -197,7 +197,6 @@ class PackageDB(object):
                 decuri["loader"] = self.load_data
                 decuri["open_file"] = True
                 decuri["open_mode"] = "r"
-                decuri["process_unpacked_as_directory"] = False
             else:
                 decuri = uri
                 if not "loader" in decuri:
@@ -206,8 +205,6 @@ class PackageDB(object):
                     decuri["open_file"] = True
                 if not "open_mode" in decuri:
                     decuri["open_mode"] = "r"
-                if not "process_unpacked_as_directory" in decuri:
-                    decuri["process_unpacked_as_directory"] = False
             decoded.append(decuri)
         return decoded
         


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-18 10:53 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-18 10:53 UTC (permalink / raw
  To: gentoo-commits

commit:     793b4ef97fa8f86abbae9d70bf7d3b65c0f94e2d
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Jul 18 10:40:21 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Jul 18 10:40:21 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=793b4ef9

g_sorcery/compatibility: basestring fix

---
 g_sorcery/compatibility.py | 14 ++++++++++++++
 g_sorcery/ebuild.py        |  1 +
 g_sorcery/package_db.py    |  2 +-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/compatibility.py b/g_sorcery/compatibility.py
index be2988e..b09865c 100644
--- a/g_sorcery/compatibility.py
+++ b/g_sorcery/compatibility.py
@@ -27,3 +27,17 @@ if py2k:
             shutil.rmtree(self.name)
 else:
     from tempfile import TemporaryDirectory
+
+#basestring removed in py3k
+#fix for it from https://github.com/oxplot/fysom/issues/1
+
+if py2k:
+    str = str
+    unicode = unicode
+    bytes = str
+    basestring = basestring
+else:
+    str = str
+    unicode = str
+    bytes = bytes
+    basestring = (str,bytes)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index 19b9a1f..2a200a1 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -11,6 +11,7 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
+from .compatibility import basestring
 from .exceptions import DependencyError
 
 class EbuildGenerator(object):

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 1f12015..313162f 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -19,7 +19,7 @@ import tarfile
 
 import portage
 
-from .compatibility import py2k, TemporaryDirectory
+from .compatibility import basestring, py2k, TemporaryDirectory
 
 from .exceptions import DBStructureError, IntegrityError, \
      InvalidKeyError, SyncError


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-18 12:18 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-18 12:18 UTC (permalink / raw
  To: gentoo-commits

commit:     57688167eacd34f03b4ae04b820c7c032ef9aefd
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Jul 18 12:13:49 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Jul 18 12:13:49 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=57688167

g_sorcery/g_collections: Dependency class added (uses portage.dep.Atom)

---
 g_sorcery/g_collections.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/g_sorcery/g_collections.py b/g_sorcery/g_collections.py
index 3ecc373..e9655a9 100644
--- a/g_sorcery/g_collections.py
+++ b/g_sorcery/g_collections.py
@@ -16,6 +16,8 @@
 
 import collections
 
+import portage
+
 class elist(list):
     '''Custom list type which adds a customized __str__()
     and takes an optional separator argument
@@ -45,3 +47,25 @@ class elist(list):
         return self._sep_.join(self)
 
 Package = collections.namedtuple("Package", "category name version")
+
+
+class Dependency(object):
+
+    __slots__ = ('atom', 'category', 'package', 'version', 'operator')
+
+    def __init__(self, category, package, version="", operator=""):
+        atom_str = operator + category + "/" + package
+        if version:            
+            atom_str += "-" + str(version)
+        object.__setattr__(self, "atom", portage.dep.Atom(atom_str))
+        object.__setattr__(self, "category", category)
+        object.__setattr__(self, "package", package)
+        object.__setattr__(self, "version", version)
+        object.__setattr__(self, "operator", operator)
+
+    def __setattr__(self, name, value):
+        raise AttributeError("Dependency instances are immutable",
+                             self.__class__, name, value)
+
+    def __str__(self):
+        return str(self.atom)


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-18 12:18 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-18 12:18 UTC (permalink / raw
  To: gentoo-commits

commit:     2fd6b53b1fb16064e9faf350910ec3610cd4f202
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Jul 18 12:18:12 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Jul 18 12:18:12 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=2fd6b53b

g_sorcery/g_collections: elist, handling non string entries implemented

---
 g_sorcery/g_collections.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/g_collections.py b/g_sorcery/g_collections.py
index e9655a9..6af88ee 100644
--- a/g_sorcery/g_collections.py
+++ b/g_sorcery/g_collections.py
@@ -44,7 +44,7 @@ class elist(list):
         '''Custom output function
         'x.__str__() <==> str(separator.join(x))'
         '''
-        return self._sep_.join(self)
+        return self._sep_.join(map(str, self))
 
 Package = collections.namedtuple("Package", "category name version")
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-18 17:26 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-18 17:26 UTC (permalink / raw
  To: gentoo-commits

commit:     f612e4795f94f3869e3017655a1eb46264a2c56a
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Jul 18 17:26:22 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Jul 18 17:26:22 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=f612e479

g_sorcery/g_collections: todos

---
 g_sorcery/g_collections.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/g_sorcery/g_collections.py b/g_sorcery/g_collections.py
index 138e239..d03409a 100644
--- a/g_sorcery/g_collections.py
+++ b/g_sorcery/g_collections.py
@@ -77,6 +77,8 @@ class serializable_elist(object):
         return serializable_elist(value["data"], separator = value["separator"])
 
 
+#todo: replace Package with something better
+
 class Package(object):
 
     __slots__ = ('category', 'name', 'version')
@@ -94,6 +96,8 @@ class Package(object):
         return Package(*value)
 
 
+#todo equality operator for Dependency, as it can be used in backend dependency solving algorithm
+
 class Dependency(object):
 
     __slots__ = ('atom', 'category', 'package', 'version', 'operator')


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-19 11:10 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-19 11:10 UTC (permalink / raw
  To: gentoo-commits

commit:     d0ba57c32aead6e5e92bbeab63192d5aed643ee6
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Fri Jul 19 09:01:54 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Fri Jul 19 09:01:54 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=d0ba57c3

g_sorcery/ebuild: fix typo

---
 g_sorcery/ebuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index 2a200a1..0c720a6 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -143,7 +143,7 @@ class EbuildGeneratorFromFile(EbuildGenerator):
 class DefaultEbuildGenerator(EbuildGenerator):
     def __init__(self, package_db, layout):
         super(DefaultEbuildGenerator, self).__init__(package_db)
-        self.template = ["# automatically generated by g-elpa",
+        self.template = ["# automatically generated by g-sorcery",
                          "# please do not edit this file",
                          ""]
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-19 14:44 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-19 14:44 UTC (permalink / raw
  To: gentoo-commits

commit:     9b01f27448621d0b90f41664664bc95f7363a3a9
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Fri Jul 19 14:44:01 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Fri Jul 19 14:44:01 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=9b01f274

g_sorcery/fileutils: support for .lzma

---
 g_sorcery/fileutils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 6ead317..92e1fb4 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -202,7 +202,7 @@ def load_remote_file(uri, parser, open_file = True, open_mode='r'):
             del unpack_dir
         else:
             name, extention = os.path.splitext(f_name)
-            if (extention == ".xz"):
+            if extention in [".xz", ".lzma"]:
                 if (os.system("xz -d " + f_name)):
                     raise DownloadingError("xz failed: " + f_name + " from " + uri)
                 f_name = name


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-23 23:13 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-23 23:13 UTC (permalink / raw
  To: gentoo-commits

commit:     6daac1e1e53aed446035a00de3e46a63d1a89706
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Tue Jul 23 22:08:05 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Tue Jul 23 22:08:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=6daac1e1

g_sorcery/package_db: add process_uri hook, as we not always want to download file from a given URI

---
 g_sorcery/package_db.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 7ff4398..77724d5 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -575,9 +575,12 @@ class DBGenerator(object):
         uries = self.decode_download_uries(uries)
         data = {}
         for uri in uries:
-            data.update(load_remote_file(**uri))
+            self.process_uri(uri, data)
         return data
 
+    def process_uri(self, uri, data):
+        data.update(load_remote_file(**uri))
+
     def get_download_uries(self, common_config, config):
         pass
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-23 23:13 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-23 23:13 UTC (permalink / raw
  To: gentoo-commits

commit:     af3d861322bd64772e86a4ffad16bee676e7bc6b
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Tue Jul 23 22:26:16 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Tue Jul 23 22:26:16 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=af3d8613

g_sorcery/package_db: reasonable default for DBGenerator.get_download_uries and fix DBGenerator.process_data

---
 g_sorcery/package_db.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 77724d5..35bad48 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -582,7 +582,7 @@ class DBGenerator(object):
         data.update(load_remote_file(**uri))
 
     def get_download_uries(self, common_config, config):
-        pass
+        return [config["repo_uri"]]
 
     def decode_download_uries(self, uries):
         decoded = []
@@ -607,7 +607,7 @@ class DBGenerator(object):
     def parse_data(self):
         pass #todo: raise no implemeted or add some reasonable default
 
-    def process_data(self):
+    def process_data(self, pkg_db, data, common_config, config):
         pass
 
     def convert(self, configs, dict_name, value):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-07-31 23:29 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-07-31 23:29 UTC (permalink / raw
  To: gentoo-commits

commit:     e21df5236b0ffa8c8cf14e41c5a3da241d883ba4
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jul 31 23:29:23 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jul 31 23:29:23 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=e21df523

g_sorcery/backend: Docstrings

---
 g_sorcery/backend.py | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 130 insertions(+)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 97c36ce..e38eba7 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -87,6 +87,17 @@ class Backend(object):
         self.logger = Logger()
 
     def _get_overlay(self, args, config, global_config):
+        """
+        Get an overlay directory.
+
+        Args:
+            args: Command line arguments.
+            config: Backend config.
+            global_config: g-sorcery config.
+
+        Returns:
+            Overlay directory.
+        """
         overlay = args.overlay
         if not overlay:
             if not 'default_overlay' in config:
@@ -98,6 +109,17 @@ class Backend(object):
         return overlay
 
     def _get_package_db(self, args, config, global_config):
+        """
+        Get package database object.
+
+        Args:
+            args: Command line arguments.
+            config: Backend config.
+            global_config: g-sorcery config.
+
+        Returns:
+            Package database object.
+        """
         overlay = self._get_overlay(args, config, global_config)
         backend_path = os.path.join(overlay, self.sorcery_dir, config["package"])
         repository = args.repository
@@ -105,6 +127,17 @@ class Backend(object):
         return pkg_db
 
     def sync(self, args, config, global_config):
+        """
+        Synchronize or generate local database.
+
+        Args:
+            args: Command line arguments.
+            config: Backend config.
+            global_config: g-sorcery config.
+
+        Returns:
+            Exit status.
+        """
         overlay = self._get_overlay(args, config, global_config)
         backend_path = os.path.join(overlay, self.sorcery_dir, config["package"])
         repository = args.repository
@@ -139,6 +172,17 @@ class Backend(object):
         return 0
 
     def list(self, args, config, global_config):
+        """
+        List all available packages.
+
+        Args:
+            args: Command line arguments.
+            config: Backend config.
+            global_config: g-sorcery config.
+
+        Returns:
+            Exit status.
+        """
         pkg_db = self._get_package_db(args, config, global_config)
         pkg_db.read()
         try:
@@ -160,6 +204,17 @@ class Backend(object):
         return 0
 
     def generate(self, args, config, global_config):
+        """
+        Generate ebuilds for a given package and all its dependecies.
+
+        Args:
+            args: Command line arguments.
+            config: Backend config.
+            global_config: g-sorcery config.
+
+        Returns:
+            Exit status.
+        """
         overlay = self._get_overlay(args, config, global_config)
         pkg_db = self._get_package_db(args, config, global_config)
         pkg_db.read()
@@ -218,6 +273,16 @@ class Backend(object):
         return 0
 
     def generate_ebuilds(self, package_db, overlay, packages, digest=False):
+        """
+        Generate ebuilds for given packages.
+
+        Args:
+            package_db: Package database
+            overlay: Overlay directory.
+            packages: List of packages.
+            digest: whether sources should be digested in Manifest.
+        """
+
         self.logger.info("ebuild generation")
         if digest:
             ebuild_g = self.ebuild_g_with_digest_class(package_db)
@@ -237,6 +302,14 @@ class Backend(object):
 
 
     def generate_metadatas(self, package_db, overlay, packages):
+        """
+        Generate metada files for given packages.
+
+        Args:
+            package_db: Package database
+            overlay: Overlay directory.
+            packages: List of packages.
+        """
         self.logger.info("metadata generation")
         metadata_g = self.metadata_g_class(package_db)
         for package in packages:
@@ -248,6 +321,13 @@ class Backend(object):
                 f.write('\n'.join(source))
 
     def generate_eclasses(self, overlay, eclasses):
+        """
+        Generate given eclasses.
+
+        Args:
+            overlay: Overlay directory.
+            eclasses: List of eclasses.
+        """
         self.logger.info("eclasses generation")
         eclass_g = self.eclass_g_class()
         path = os.path.join(overlay, 'eclass')
@@ -261,6 +341,21 @@ class Backend(object):
 
 
     def solve_dependencies(self, package_db, package, solved_deps=None, unsolved_deps=None):
+        """
+        Solve dependencies.
+
+        Args:
+            package_db: Package database.
+            package: A package we want to solve dependencies for.
+            solved_deps: List of solved dependencies.
+            unsolved_deps: List of dependencies to be solved.
+
+        Returns:
+            A pair (solved_deps, unsolved_deps).
+
+        Note:
+            Each dependency is an object of class g_collections.Dependency.
+        """
         if not solved_deps:
             solved_deps = set()
         if not unsolved_deps:
@@ -297,6 +392,12 @@ class Backend(object):
 
 
     def digest(self, overlay):
+        """
+        Digest an overlay using repoman.
+
+        Args:
+            overlay: Overlay directory.
+        """
         self.logger.info("digesting overlay")
         prev = os.getcwd()
         os.chdir(overlay)
@@ -305,12 +406,30 @@ class Backend(object):
         os.chdir(prev)
 
     def fast_digest(self, overlay, pkgnames):
+        """
+        Digest an overlay using custom method faster than repoman.
+
+        Args:
+            overlay: Overlay directory.
+            pkgnames: List of full package names (category/package).
+        """
         self.logger.info("fast digesting overlay")
         for pkgname in pkgnames:
             directory = os.path.join(overlay, pkgname)
             fast_manifest(directory)
         
     def generate_tree(self, args, config, global_config):
+        """
+        Generate entire overlay.
+
+        Args:
+            args: Command line arguments.
+            config: Backend config.
+            global_config: g-sorcery config.
+
+        Returns:
+            Exit status.
+        """
         self.logger.info("tree generation")
         overlay = self._get_overlay(args, config, global_config)
         pkg_db = self._get_package_db(args, config, global_config)
@@ -360,6 +479,17 @@ class Backend(object):
             self.fast_digest(overlay, pkgnames)
 
     def install(self, args, config, global_config):
+        """
+        Install a package.
+
+        Args:
+            args: Command line arguments.
+            config: Backend config.
+            global_config: g-sorcery config.
+
+        Returns:
+            Exit status.
+        """
         self.generate(args, config, global_config)
         try:
             package_manager = global_config.get("main", "package_manager")


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     1ec0b070a11e10b8111538a8b8bdb865497bc82f
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 11:32:06 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 11:32:06 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=1ec0b070

g_sorcery/ebuild: Docstrings added

---
 g_sorcery/ebuild.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index 0c720a6..a1bd6b8 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -46,6 +46,15 @@ class EbuildGenerator(object):
         return ebuild
 
     def process_ebuild_data(self, ebuild_data):
+        """
+        A hook allowing changing ebuild_data before ebuild generation.
+
+        Args:
+            ebuild_data: Dictinary with ebuild data.
+
+        Returns:
+            Dictinary with ebuild data.
+        """
         return ebuild_data
 
     def process(self, ebuild, ebuild_data):
@@ -89,7 +98,7 @@ class EbuildGenerator(object):
         
     def postprocess(self, ebuild, ebuild_data):
         """
-        Hook to be overriden.
+        A hook for changing of a generated ebuild.
 
         Args:
             ebuild: Ebuild source as a list of strings.
@@ -141,6 +150,27 @@ class EbuildGeneratorFromFile(EbuildGenerator):
 
 
 class DefaultEbuildGenerator(EbuildGenerator):
+    """
+    Default ebuild generator.
+
+    Takes a layout dictinary that describes ebuild structure and generates
+    an ebuild temlate basing on it.
+
+    Layout has entries for vars and inherited eclasses. Each entry is a list.
+    Entries are processed in the following order:
+    
+    vars_before_inherit
+    inherit
+    vars_after_inherit
+    vars_after_description
+    vars_after_keywords
+
+    inherit entry is just a list of eclass names.
+    vars* entries are lists of variables in tw0 possible formats:
+    1. A string with variable name
+    2. A tuple (varname, value)
+    Variable names are automatically transformed to the upper-case.
+    """
     def __init__(self, package_db, layout):
         super(DefaultEbuildGenerator, self).__init__(package_db)
         self.template = ["# automatically generated by g-sorcery",
@@ -182,6 +212,12 @@ class DefaultEbuildGenerator(EbuildGenerator):
         
 
     def _append_vars_to_template(self, variables):
+        """
+        Add a list of variables to the end of template.
+
+        Args:
+            variables: List of variables.
+        """
         VAR_NAME = 0
         VAR_VALUE = 1
 
@@ -193,4 +229,14 @@ class DefaultEbuildGenerator(EbuildGenerator):
 
 
     def get_template(self, package, ebuild_data):
+        """
+        Generate ebuild template.
+
+        Args:
+            package: package_db.Package instance.
+            ebuild_data: Dictionary with ebuild data.
+
+        Returns:
+            Ebuild template.
+        """
         return self.template


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     12987b9b5b0e24af55a7fe27816db605a3bd578e
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 11:42:15 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 11:42:15 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=12987b9b

g_sorcery/fileutils: Docstrings added

---
 g_sorcery/fileutils.py | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 7a096b1..ab42ff2 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -139,6 +139,9 @@ def get_pkgpath(root = None):
     return os.path.dirname(os.path.abspath(root))
 
 class ManifestEntry:
+    """
+    A manifest entry for a file.
+    """
     def __init__(self, directory, name, ftype):
         self.directory = directory
         self.name = name
@@ -146,6 +149,9 @@ class ManifestEntry:
         self.digest()
 
     def digest(self):
+        """
+        Digest a file associated with a manifest entry.
+        """
         h_sha256 = hashlib.new('SHA256')
         h_sha512 = hashlib.new('SHA512')
         h_whirlpool = hashlib.new('whirlpool')
@@ -161,6 +167,14 @@ class ManifestEntry:
 
 
 def fast_manifest(directory):
+    """
+    Digest package directory.
+    This function is intended to be used in place of repoman manifest,
+    as it is to slow.
+
+    Args:
+        directory: Directory.
+    """
     manifest = []
     metadata = os.path.join(directory, "metadata.xml")
 
@@ -181,6 +195,19 @@ def fast_manifest(directory):
 
 
 def _call_parser(f_name, parser, open_file = True, open_mode = 'r'):
+    """
+    Call parser on a given file.
+
+    Args:
+        f_name: File name.
+        parser: Parser function.
+        open_file: Whether parser accepts a file descriptor.
+        open_mode: Open mode for a file.
+
+    Returns:
+        A dictionary with one entry. Key if a file name, content is
+    content returned by parser.
+    """
     data = None
     if open_file:
         with open(f_name, open_mode) as f:
@@ -191,6 +218,20 @@ def _call_parser(f_name, parser, open_file = True, open_mode = 'r'):
 
 
 def load_remote_file(uri, parser, open_file = True, open_mode='r', output=""):
+    """
+    Load files from an URI.
+
+    Args:
+        uri: URI.
+        parser: Parser that will be applied to downloaded files.
+        open_file: Whether parser accepts a file descriptor.
+        open_mode: Open mode for a file.
+        output: What output name should downloaded file have
+    (it will be a key identifying data loaded from this file)
+
+    Returns:
+        Dictionary with a loaded data. Key is filename, content is data returned by parser.
+    """
     download_dir = TemporaryDirectory()
     loaded_data = {}
     if wget(uri, download_dir.name, output):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     e1cb08b41ba81524fcf88df0076c4c0dcf918d29
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 11:45:34 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 11:45:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=e1cb08b4

g_sorcery/g_collections: Docstrings added

---
 g_sorcery/g_collections.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/g_collections.py b/g_sorcery/g_collections.py
index d03409a..f0804a3 100644
--- a/g_sorcery/g_collections.py
+++ b/g_sorcery/g_collections.py
@@ -48,6 +48,9 @@ class elist(list):
 
 
 class serializable_elist(object):
+    """
+    A JSON serializable version of elist.
+    """
 
     __slots__ = ('data')
     
@@ -80,7 +83,9 @@ class serializable_elist(object):
 #todo: replace Package with something better
 
 class Package(object):
-
+    """
+    Class to store full package name: category/package-version
+    """
     __slots__ = ('category', 'name', 'version')
 
     def __init__(self, category, package, version):
@@ -99,6 +104,9 @@ class Package(object):
 #todo equality operator for Dependency, as it can be used in backend dependency solving algorithm
 
 class Dependency(object):
+    """
+    Class to store a dependency. Uses portage Atom.
+    """
 
     __slots__ = ('atom', 'category', 'package', 'version', 'operator')
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     467964022ce881c4e22a3ba76e8ab7941c1afab3
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 11:46:48 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 11:46:48 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=46796402

g_sorcery/g_sorcery: Docstrings added

---
 g_sorcery/g_sorcery.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py
index 6beb565..da29980 100644
--- a/g_sorcery/g_sorcery.py
+++ b/g_sorcery/g_sorcery.py
@@ -70,6 +70,9 @@ def main():
 
 
 def get_backend(package):
+    """
+    Load backend by package name.
+    """
     logger = Logger()
     try:
         module = importlib.import_module(package + '.backend')


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     3768929c2b516df97e7d3d45ed41a44487f81790
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 12:33:52 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 12:33:52 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=3768929c

g_sorcery/g_sorcery: Docstrings added

---
 g_sorcery/package_db.py | 156 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 148 insertions(+), 8 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 35bad48..3f2993a 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -38,8 +38,6 @@ class PackageDB(object):
     ~~~~~~~~~~~~~~~~~
     db dir
         manifest.json: database manifest
-        uri.json: URIes
-        info.json: information about database
         categories.json: information about categories
         category1
             packages.json: list of packages
@@ -113,8 +111,6 @@ class PackageDB(object):
         """
         Args:
             directory: database directory.
-            repo_uri: Repository URI.
-            db_uri: URI for synchronization with remote database.
         """
         self.CATEGORIES_NAME = 'categories.json'
         self.PACKAGES_NAME = 'packages.json'
@@ -462,6 +458,12 @@ class PackageDB(object):
         return res
 
     def list_catpkg_names(self):
+        """
+        List category/package entries.
+
+        Returns:
+            List with category/package entries.
+        """
         return list(self.database)
 
     def list_package_versions(self, category, name):
@@ -498,13 +500,13 @@ class PackageDB(object):
 
     def get_package_description(self, package):
         """
-        Get package description.
+        Get package ebuild data.
 
         Args:
             package: package_db.Package instance.
 
         Returns:
-            Dictionary with package description.
+            Dictionary with package ebuild data.
         """
         #a possible exception should be catched in the caller
         return self.database[package.category + '/' + package.name][package.version]
@@ -544,6 +546,29 @@ class DBGenerator(object):
         self.package_db_class = package_db_class
 
     def __call__(self, directory, repository, common_config=None, config=None, generate=True):
+        """
+        Get a package database.
+
+        A directory layout looks like:
+        backend directory
+            config.json
+            repo1 dir
+                config.json
+                db - directory with database
+            repo2 dir
+                config.json
+                db - directory with database
+
+        Args:
+            directory: Directory for package databases (backend directory).
+            repository: Repository name.
+            common_config: Backend config.
+            config: Repository config.
+            generate: Whether package tree should be generated.
+
+        Returns:
+            Package database.
+        """
         db_path = os.path.join(directory, repository, "db")
         pkg_db = self.package_db_class(db_path)
 
@@ -567,10 +592,28 @@ class DBGenerator(object):
         return pkg_db
 
     def generate_tree(self, pkg_db, common_config, config):
+        """
+        Generate package entries.
+
+        Args:
+            pkg_db: Package database.
+            common_config: Backend config.
+            config: Repository config.
+        """
         data = self.download_data(common_config, config)
         self.process_data(pkg_db, data, common_config, config)
 
     def download_data(self, common_config, config):
+        """
+        Obtain data for database generation.
+
+        Args:
+            common_config: Backend config.
+            config: Repository config.
+
+        Returns:
+            Downloaded data.
+        """
         uries = self.get_download_uries(common_config, config)
         uries = self.decode_download_uries(uries)
         data = {}
@@ -579,12 +622,47 @@ class DBGenerator(object):
         return data
 
     def process_uri(self, uri, data):
+        """
+        Download and parse data from a given URI.
+
+        Args:
+            uri: URI.
+            data: Data dictionary.
+        """
         data.update(load_remote_file(**uri))
 
     def get_download_uries(self, common_config, config):
+        """
+        Get uries to download from.
+
+        Args:
+            common_config: Backend config.
+            config: Repository config.
+
+        Returns:
+            List with URI entries.
+            Each entry has one of the following formats:
+            1. String with URI.
+            2. A dictionary with entries:
+                - uri: URI.
+                - parser: Parser to be applied to downloaded data.
+                - open_file: Whether parser accepts file objects.
+                - open_mode: Open mode for a downloaded file.
+                The only mandatory entry is uri.
+        """
         return [config["repo_uri"]]
 
     def decode_download_uries(self, uries):
+        """
+        Convert URI list with incomplete and string entries
+        into list with complete dictionary entries.
+
+        Args:
+            uries: List of URIes.
+
+        Returns:
+            List of URIes with dictionary entries.
+        """
         decoded = []
         for uri in uries:
             decuri = {}
@@ -604,13 +682,45 @@ class DBGenerator(object):
             decoded.append(decuri)
         return decoded
 
-    def parse_data(self):
-        pass #todo: raise no implemeted or add some reasonable default
+    def parse_data(self, data_file):
+        """
+        Parse downloaded data.
+
+        Args:
+            data_file: File name of open file object.
+
+        Returns:
+            Parsed data.
+        """
+        raise NotImplementedError
 
     def process_data(self, pkg_db, data, common_config, config):
+        """
+        Process downloaded data and fill database.
+
+        Args:
+            pkg_db: Package database.
+            data: Dictionary with data, keys are file names.
+            common_config; Backend config.
+            config: Repository config.
+        """
         pass
 
     def convert(self, configs, dict_name, value):
+        """
+        Convert a value using configs.
+        This function is aimed to be used for conversion
+        of values such as license or package names.
+
+        Args:
+            configs: List of configs.
+            dict_name: Name of a dictionary in config
+        that should be used for conversion.
+            value: Value to convert.
+
+        Returns:
+            Converted value.
+        """
         result = value
         for config in configs:
             if config:
@@ -621,6 +731,18 @@ class DBGenerator(object):
         return result
 
     def convert_dependency(self, configs, dependency, external=True):
+        """
+        Convert dependency.
+
+        Args:
+            configs: List of configs.
+            dependency: Dependency to be converted.
+            external: Whether external deps should be keeped.
+
+        Returns:
+            Right dependency name or None if dependency is external and
+        external == False.
+        """
         external_dep = ""
         for config in configs:
             if config:
@@ -637,12 +759,30 @@ class DBGenerator(object):
             return self.convert_internal_dependency(configs, dependency)
 
     def convert_internal_dependency(self, configs, dependency):
+        """
+        Hook to convert internal dependencies.
+        """
         return dependency
 
     def convert_external_dependency(self, configs, dependency):
+        """
+        Hook to convert external dependencies.
+        """
         return dependency
         
     def in_config(self, configs, list_name, value):
+        """
+        Check whether value is in config.
+
+        Args:
+            configs: List of configs.
+            list_name: Name of a list in config
+        that should be used for checking.
+            value: Value to look for.
+
+        Returns:
+            Boolean.
+        """
         result = False
         for config in configs:
             if config:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     99c0f1fecb508b7d65f32d144e75a5d7ba71a7d9
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 11:47:41 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 11:47:41 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=99c0f1fe

g_sorcery/logger: Docstrings added

---
 g_sorcery/logger.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/g_sorcery/logger.py b/g_sorcery/logger.py
index 8a95b85..5d6a839 100644
--- a/g_sorcery/logger.py
+++ b/g_sorcery/logger.py
@@ -15,6 +15,9 @@ import portage
 
 
 class Logger(object):
+    """
+    A simple logger object. Uses portage out facilities.
+    """
     def __init__(self):
         self.out = portage.output.EOutput()
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     15506cf3cd091135c98a868ec68375f0e682d64d
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 11:48:34 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 11:48:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=15506cf3

g_sorcery/mangler: Docstrings added

---
 g_sorcery/mangler.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/mangler.py b/g_sorcery/mangler.py
index fbdcdd3..6b31f27 100644
--- a/g_sorcery/mangler.py
+++ b/g_sorcery/mangler.py
@@ -40,11 +40,14 @@ class PackageManager(object):
 
 
 class Portage(PackageManager):
+    """
+    Portage package manager abstraction.
+    """
     def __init__(self):
         self.executable = "/usr/bin/emerge"
 
     def install(self, pkgname, *args):
         return self.run_command("-va", pkgname, *args)
 
-
+#list of supported package managers.
 package_managers = {'portage' : Portage}


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:39 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:39 UTC (permalink / raw
  To: gentoo-commits

commit:     4adf87ffbc61204a90f309517351c872dc37aa44
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 12:39:12 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 12:39:12 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=4adf87ff

g_sorcery/serialization: Docstrings added

---
 g_sorcery/serialization.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/g_sorcery/serialization.py b/g_sorcery/serialization.py
index 28e29e5..e051596 100644
--- a/g_sorcery/serialization.py
+++ b/g_sorcery/serialization.py
@@ -16,7 +16,14 @@ import importlib
 
 
 class JSONSerializer(json.JSONEncoder):
+    """
+    Custom JSON encoder.
 
+    Each serializable class should have a method serialize
+    that returns JSON serializable value. If class addfitionally
+    has a classmethod deserialize that it can be deserialized
+    and additional metainformation is added to the resulting JSON.
+    """
     def default(self, obj):
         if hasattr(obj, "serialize"):
             if hasattr(obj, "deserialize"):
@@ -32,6 +39,13 @@ class JSONSerializer(json.JSONEncoder):
 
 
 def deserializeHook(json_object):
+    """
+    Custom JSON decoder.
+
+    Each class that can be deserialized should have classmethod deserialize
+    that takes value (previously returned by serialize method) and transforms
+    it into class instance.
+    """
     if "python_class" in json_object:
         module = importlib.import_module(json_object["python_module"])
         cls = getattr(module, json_object["python_class"])


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 12:55 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 12:55 UTC (permalink / raw
  To: gentoo-commits

commit:     792c17dd38a38430ca75aa95f81e9f27fdcd989b
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 12:55:39 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 12:55:39 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=792c17dd

g_sorcery/fileutils: different fixes

---
 g_sorcery/fileutils.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index ab42ff2..c7a5257 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -50,7 +50,8 @@ class FileJSON(object):
             for key in self.mandatories:
                 content[key] = ""
             with open(self.path, 'w') as f:
-                json.dump(content, f, indent=2, sort_keys=True, cls=JSONSerializer)
+                json.dump(content, f, indent=2,
+                    sort_keys=True, cls=JSONSerializer)
         else:
             with open(self.path, 'r') as f:
                 content = json.load(f, object_hook=deserializeHook)
@@ -120,7 +121,8 @@ def wget(uri, directory, output=""):
         Nonzero in case of a failure.
     """
     if output:
-        ret = os.system('wget ' + uri + ' -O ' + os.path.join(directory, output))
+        ret = os.system('wget ' + uri +
+                    ' -O ' + os.path.join(directory, output))
     else:
         ret = os.system('wget -P ' + directory + ' ' + uri)
     return ret
@@ -142,6 +144,10 @@ class ManifestEntry:
     """
     A manifest entry for a file.
     """
+
+    __slots__ = ('directory', 'name', 'ftype', 'digest',
+                 'size', 'sha256', 'sha512', 'whirlpool')
+    
     def __init__(self, directory, name, ftype):
         self.directory = directory
         self.name = name
@@ -179,9 +185,11 @@ def fast_manifest(directory):
     metadata = os.path.join(directory, "metadata.xml")
 
     for aux in glob.glob(os.path.join(directory, "files/*")):
-        manifest.append(ManifestEntry(os.path.dirname(aux), os.path.basename(aux), "AUX"))
+        manifest.append(ManifestEntry(os.path.dirname(aux),
+                            os.path.basename(aux), "AUX"))
     for ebuild in glob.glob(os.path.join(directory, "*.ebuild")):
-        manifest.append(ManifestEntry(directory, os.path.basename(ebuild), "EBUILD"))
+        manifest.append(ManifestEntry(directory,
+                            os.path.basename(ebuild), "EBUILD"))
     if (os.path.isfile(metadata)):
         manifest.append(ManifestEntry(directory, "metadata.xml", "MISC"))
 
@@ -249,7 +257,8 @@ def load_remote_file(uri, parser, open_file = True, open_mode='r', output=""):
             name, extention = os.path.splitext(f_name)
             if extention in [".xz", ".lzma"]:
                 if (os.system("xz -d " + f_name)):
-                    raise DownloadingError("xz failed: " + f_name + " from " + uri)
+                    raise DownloadingError("xz failed: "
+                                + f_name + " from " + uri)
                 f_name = name
             loaded_data.update(_call_parser(f_name, parser,
                                 open_file=open_file, open_mode=open_mode))


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 15:58 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     a505f2696f626cee979d69cd7f58811b29218773
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 15:09:18 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 15:09:18 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=a505f269

g_sorcery/compatibility: typo

---
 g_sorcery/compatibility.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/compatibility.py b/g_sorcery/compatibility.py
index b09865c..59c239e 100644
--- a/g_sorcery/compatibility.py
+++ b/g_sorcery/compatibility.py
@@ -40,4 +40,4 @@ else:
     str = str
     unicode = str
     bytes = bytes
-    basestring = (str,bytes)
+    basestring = (str, bytes)


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 15:58 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     c837ca65bd137c69a8ab32d3267b0308089180fe
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 14:28:05 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 14:28:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=c837ca65

g_sorcery/backend: different fixes

---
 g_sorcery/backend.py | 75 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 47 insertions(+), 28 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index e38eba7..9e2ef66 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -12,9 +12,7 @@
 """
 
 import argparse
-import glob
 import os
-import sys
 
 from .compatibility import py2k
 
@@ -50,7 +48,8 @@ class Backend(object):
     
     def __init__(self, package_db_generator_class, 
                  ebuild_g_with_digest_class, ebuild_g_without_digest_class,
-                 eclass_g_class, metadata_g_class, package_db_class=PackageDB, sync_db=False):
+                 eclass_g_class, metadata_g_class,
+                 package_db_class=PackageDB, sync_db=False):
         self.sorcery_dir = '.g-sorcery'
         self.sync_db = sync_db
         self.package_db_generator = package_db_generator_class(package_db_class)
@@ -59,7 +58,8 @@ class Backend(object):
         self.eclass_g_class = eclass_g_class
         self.metadata_g_class = metadata_g_class
 
-        self.parser = argparse.ArgumentParser(description='Automatic ebuild generator.')
+        self.parser = \
+            argparse.ArgumentParser(description='Automatic ebuild generator.')
         self.parser.add_argument('-o', '--overlay')
         self.parser.add_argument('-r', '--repository')
 
@@ -101,8 +101,8 @@ class Backend(object):
         overlay = args.overlay
         if not overlay:
             if not 'default_overlay' in config:
-               self.logger.error("no overlay given, exiting.")
-               return None
+                self.logger.error("no overlay given, exiting.")
+                return None
             else:
                 overlay = config['default_overlay']
         overlay = args.overlay
@@ -121,9 +121,11 @@ class Backend(object):
             Package database object.
         """
         overlay = self._get_overlay(args, config, global_config)
-        backend_path = os.path.join(overlay, self.sorcery_dir, config["package"])
+        backend_path = os.path.join(overlay,
+                            self.sorcery_dir, config["package"])
         repository = args.repository
-        pkg_db = self.package_db_generator(backend_path, repository, generate=False)
+        pkg_db = self.package_db_generator(backend_path,
+                                    repository, generate=False)
         return pkg_db
 
     def sync(self, args, config, global_config):
@@ -139,7 +141,8 @@ class Backend(object):
             Exit status.
         """
         overlay = self._get_overlay(args, config, global_config)
-        backend_path = os.path.join(overlay, self.sorcery_dir, config["package"])
+        backend_path = os.path.join(overlay,
+                            self.sorcery_dir, config["package"])
         repository = args.repository
         repository = args.repository
         repository_config = {}
@@ -152,7 +155,7 @@ class Backend(object):
         if repository:
             if not "repositories" in config:
                 self.logger.error("repository " + repository + 
-                                  " specified, but there is no repositories entry in config")
+                    " specified, but there is no repositories entry in config")
                 return -1
             repositories = config["repositories"]
             if not repository in repositories:
@@ -168,7 +171,8 @@ class Backend(object):
                             common_config, repository_config, generate=False)
             pkg_db.sync(repository_config["db_uri"])
         else:
-            pkg_db = self.package_db_generator(backend_path, repository, common_config, repository_config)
+            pkg_db = self.package_db_generator(backend_path,
+                            repository, common_config, repository_config)
         return 0
 
     def list(self, args, config, global_config):
@@ -194,7 +198,8 @@ class Backend(object):
                 for pkg in packages:
                     max_ver = pkg_db.get_max_version(category, pkg)
                     versions = pkg_db.list_package_versions(category, pkg)
-                    desc = pkg_db.get_package_description(Package(category, pkg, max_ver))
+                    desc = pkg_db.get_package_description(Package(category,
+                                                            pkg, max_ver))
                     print('  ' + pkg + ': ' + desc['description'])
                     print('    Available versions: ' + ' '.join(versions))
                     print('\n')
@@ -242,12 +247,14 @@ class Backend(object):
                     categories.append(cat)
 
             if not len(categories):
-                self.logger.error('no package with name ' + pkgname + ' found\n')
+                self.logger.error('no package with name ' \
+                                  + pkgname + ' found\n')
                 return -1
                     
             if len(categories) > 1:
                 self.logger.error('ambiguous packagename: ' + pkgname + '\n')
-                self.logger.error('please select one of the following packages:\n')
+                self.logger.error('please select one of' \
+                                  + 'the following packages:\n')
                 for cat in categories:
                     self.logger.error('    ' + cat + '/' + pkgname + '\n')
                 return -1
@@ -257,7 +264,8 @@ class Backend(object):
         dependencies = set()
         try:
             for version in versions:
-                dependencies |= self.solve_dependencies(pkg_db, Package(category, name, version))[0]
+                dependencies |= self.solve_dependencies(pkg_db,
+                                    Package(category, name, version))[0]
         except Exception as e:
             self.logger.error('dependency solving failed: ' + str(e) + '\n')
             return -1
@@ -292,12 +300,14 @@ class Backend(object):
             category = package.category
             name = package.name
             version = package.version
-            self.logger.info("    generating " + category + '/' + name + '-' + version)
+            self.logger.info("    generating " +
+                        category + '/' + name + '-' + version)
             path = os.path.join(overlay, category, name)
             if not os.path.exists(path):
                 os.makedirs(path)
             source = ebuild_g.generate(package)
-            with open(os.path.join(path, name + '-' + version + '.ebuild'), 'w') as f:
+            with open(os.path.join(path,
+                        name + '-' + version + '.ebuild'), 'w') as f:
                 f.write('\n'.join(source))
 
 
@@ -340,7 +350,8 @@ class Backend(object):
                 f.write('\n'.join(source))
 
 
-    def solve_dependencies(self, package_db, package, solved_deps=None, unsolved_deps=None):
+    def solve_dependencies(self, package_db, package,
+                           solved_deps=None, unsolved_deps=None):
         """
         Solve dependencies.
 
@@ -370,7 +381,7 @@ class Backend(object):
         found = True
         try:
             desc = package_db.get_package_description(package)
-        except KeyError as e:
+        except KeyError:
             found = False
         if not found:
             error = "package " + package.category + '/' + \
@@ -379,11 +390,12 @@ class Backend(object):
         
         dependencies = desc["dependencies"]
         for pkg in dependencies:
-            versions = package_db.list_package_versions(pkg.category, pkg.package)
+            versions = package_db.list_package_versions(pkg.category,
+                                                        pkg.package)
             for version in versions:            
                 solved_deps, unsolved_deps = self.solve_dependencies(package_db,
-                                                                 Package(pkg.category, pkg.package, version),
-                                                                 solved_deps, unsolved_deps)
+                                    Package(pkg.category, pkg.package, version),
+                                    solved_deps, unsolved_deps)
         
         solved_deps.add(package)
         unsolved_deps.remove(package)
@@ -450,12 +462,15 @@ class Backend(object):
             category = package.category
             name = package.name
             version = package.version
-            self.logger.info("    generating " + category + '/' + name + '-' + version)
+            self.logger.info("    generating " +
+                             category + '/' + name + '-' + version)
             path = os.path.join(overlay, category, name)
             if not os.path.exists(path):
                 os.makedirs(path)
             source = ebuild_g.generate(package, ebuild_data)
-            with open(os.path.join(path, name + '-' + version + '.ebuild'), 'w') as f:
+            with open(os.path.join(path,
+                        name + '-' + version + '.ebuild'),
+                      'w') as f:
                 f.write('\n'.join(source))
 
             source = metadata_g.generate(package)
@@ -498,7 +513,8 @@ class Backend(object):
             package_manager = None
         if  package_manager:
             if not package_manager in package_managers:
-                self.logger.error('not supported package manager: ' + package_manager + '\n')
+                self.logger.error('not supported package manager: ' \
+                                + package_manager + '\n')
                 return -1
             package_manager_class = package_managers[package_manager]
         package_manager = package_manager_class()
@@ -506,7 +522,8 @@ class Backend(object):
         
     def __call__(self, args, config, global_config):
         args = self.parser.parse_args(args)
-        info_f = FileJSON(os.path.join(args.overlay, self.sorcery_dir), "info.json", ["repositories"])
+        info_f = FileJSON(os.path.join(args.overlay, self.sorcery_dir),
+                          "info.json", ["repositories"])
         self.info = info_f.read()
         repos = self.info["repositories"]
         if args.repository:
@@ -528,11 +545,13 @@ class Backend(object):
                 if len(brepos) == 1:
                     args.repository = brepos[0]
                 else:
-                    self.logger.error("No repository specified, possible values:")
+                    self.logger.error("No repository specified," \
+                                      + " possible values:")
                     for repo in brepos:
                         print("    " + repo)
                     return -1
             else:
-                self.logger.error("No repository for backend " + back + " in overlay " + args.overlay)
+                self.logger.error("No repository for backend " \
+                                  + back + " in overlay " + args.overlay)
                 return -1
         return args.func(args, config, global_config)


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 15:58 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     9e86fe61a11a0e9d1105d173ce545a7ff7362f58
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 15:23:24 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 15:23:24 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=9e86fe61

g_sorcery/g_collections: remove unused import

---
 g_sorcery/g_collections.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/g_sorcery/g_collections.py b/g_sorcery/g_collections.py
index f0804a3..18258c8 100644
--- a/g_sorcery/g_collections.py
+++ b/g_sorcery/g_collections.py
@@ -14,8 +14,6 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
-import collections
-
 import portage
 
 class elist(list):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 15:58 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     c322c8a555e4297f5c841feabfe0326031889471
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 15:33:10 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 15:33:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=c322c8a5

g_sorcery/package_db: different fixes

---
 g_sorcery/package_db.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 3f2993a..e97ee15 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -251,6 +251,7 @@ class PackageDB(object):
 
         number_of_packages = len(list(self.database))
         written_number = 0
+        length = 20
         
         for pkgname, versions in self.database.items():
             category, name = pkgname.split('/')
@@ -273,14 +274,14 @@ class PackageDB(object):
             pkgs.append(name)
             f.write(pkgs)
 
-            chars = ['-','\\','|','/']
+            chars = ['-', '\\', '|', '/']
             show = chars[written_number % 4]
             percent = (written_number * 100)//number_of_packages
-            length = 20
-            progress = (percent * 20)//100
-            blank = 20 - progress
+            progress = (percent * length)//100
+            blank = length - progress
 
-            sys.stdout.write("\r %s [%s%s] %s%%" % (show, "#" * progress, " " * blank, percent))
+            sys.stdout.write("\r %s [%s%s] %s%%" % \
+                             (show, "#" * progress, " " * blank, percent))
             sys.stdout.flush()
             written_number += 1
 
@@ -292,7 +293,7 @@ class PackageDB(object):
         self.additional_write()
 
         if self.database:
-            sys.stdout.write("\r %s [%s] %s%%" % ("-", "#" * 20, 100))
+            sys.stdout.write("\r %s [%s] %s%%" % ("-", "#" * length, 100))
             sys.stdout.flush()
             print("")
 
@@ -454,7 +455,8 @@ class PackageDB(object):
         """
         if not category or (not category in self.categories):
             raise InvalidKeyError('No such category: ' + category)
-        res = [x.split('/')[1] for x in self.database if x.split('/')[0] == category]
+        res = [x.split('/')[1] for x in self.database
+               if x.split('/')[0] == category]
         return res
 
     def list_catpkg_names(self):
@@ -509,7 +511,8 @@ class PackageDB(object):
             Dictionary with package ebuild data.
         """
         #a possible exception should be catched in the caller
-        return self.database[package.category + '/' + package.name][package.version]
+        return self.database[package.category \
+                             + '/' + package.name][package.version]
 
     def get_max_version(self, category, name):
         """
@@ -545,7 +548,8 @@ class DBGenerator(object):
     def __init__(self, package_db_class=PackageDB):
         self.package_db_class = package_db_class
 
-    def __call__(self, directory, repository, common_config=None, config=None, generate=True):
+    def __call__(self, directory, repository,
+                 common_config=None, config=None, generate=True):
         """
         Get a package database.
 
@@ -572,7 +576,8 @@ class DBGenerator(object):
         db_path = os.path.join(directory, repository, "db")
         pkg_db = self.package_db_class(db_path)
 
-        config_f = FileJSON(os.path.join(directory, repository), "config.json", [])
+        config_f = FileJSON(os.path.join(directory, repository),
+                            "config.json", [])
         if config:
             config_f.write(config)
         else:
@@ -587,7 +592,8 @@ class DBGenerator(object):
         if generate:
             pkg_db.clean()
             self.generate_tree(pkg_db, common_config, config)
-            pkg_db.write() #todo: make db write on every add_package and only necessary info
+            #todo: make db write on every add_package and only necessary info
+            pkg_db.write()
             pkg_db.manifest()
         return pkg_db
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 15:58 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     e1f3116f6835b9efdc39df40c912061b5ac6065f
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 15:15:27 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 15:15:27 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=e1f3116f

g_sorcery/ebuild: Line too long fix

---
 g_sorcery/ebuild.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index a1bd6b8..36847f9 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -225,7 +225,8 @@ class DefaultEbuildGenerator(EbuildGenerator):
             if isinstance(var, basestring):
                 self.template.append(var.upper() + '="%(' + var + ')s"')
             else:
-                self.template.append(var[VAR_NAME].upper() + '="' + var[VAR_VALUE] + '"')
+                self.template.append(var[VAR_NAME].upper() \
+                                     + '="' + var[VAR_VALUE] + '"')
 
 
     def get_template(self, package, ebuild_data):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-01 15:58 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-01 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     94ddce25bf3b9c02ec5ec591576bdcae9d335a2b
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug  1 15:24:38 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug  1 15:24:38 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=94ddce25

g_sorcery/g_sorcery: fix line too long

---
 g_sorcery/g_sorcery.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py
index da29980..b177cfa 100644
--- a/g_sorcery/g_sorcery.py
+++ b/g_sorcery/g_sorcery.py
@@ -47,7 +47,8 @@ def main():
     try:
         config = cfg_f.read()
     except FileJSONError as e:
-        logger.error('error loading config file for ' + name + ': ' + str(e) + '\n')
+        logger.error('error loading config file for ' \
+                     + name + ': ' + str(e) + '\n')
         return -1
     backend = get_backend(config['package'])
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-02 10:18 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-02 10:18 UTC (permalink / raw
  To: gentoo-commits

commit:     170896fb1549ecf048929bc7e8d7e1bba7aabaaa
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Fri Aug  2 10:18:01 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Fri Aug  2 10:18:01 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=170896fb

g_sorcery/backend: fix overlay name

---
 g_sorcery/backend.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 4b356b3..6cc0d13 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -458,7 +458,7 @@ class Backend(object):
         else:
             masters = elist(config["repositories"][args.repository]["masters"])
         with open(os.path.join(overlay, 'metadata', 'layout.conf'), 'w') as f:
-            f.write("repo-name = %s\n" % overlay)
+            f.write("repo-name = %s\n" % os.path.basename(overlay))
             f.write("masters = %s\n" % masters)
         
         if args.digest:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-08-12  0:36 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-08-12  0:36 UTC (permalink / raw
  To: gentoo-commits

commit:     3128ec6e5ec9e3bd472d63621af521153f922d4a
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Aug 11 20:34:08 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Aug 11 20:34:08 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=3128ec6e

g_sorcery/logger: ProgressBar

---
 g_sorcery/logger.py     | 40 ++++++++++++++++++++++++++++++++++++++++
 g_sorcery/package_db.py | 25 ++++++-------------------
 2 files changed, 46 insertions(+), 19 deletions(-)

diff --git a/g_sorcery/logger.py b/g_sorcery/logger.py
index 5d6a839..5848715 100644
--- a/g_sorcery/logger.py
+++ b/g_sorcery/logger.py
@@ -11,6 +11,8 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
+import sys
+
 import portage
 
 
@@ -29,3 +31,41 @@ class Logger(object):
 
     def warn(self, message):
         self.out.ewarn(message)
+
+
+class ProgressBar(object):
+    """
+    A progress bar for CLI
+    """
+
+    __slots__ = ('length', 'total', 'processed', 'chars')
+    
+    def __init__(self, length, total, processed = 0):
+        self.length = length
+        self.total = total
+        self.chars = ['-', '\\', '|', '/']
+        self.processed = processed
+
+    def begin(self):
+        self.processed = 0
+        self.display()
+
+    def display(self, processed = None):
+        if processed:
+            self.processed = processed
+
+        show = self.chars[self.processed % 4]
+        percent = (self.processed * 100)//self.total
+        progress = (percent * self.length)//100
+        blank = self.length - progress
+        sys.stdout.write("\r %s [%s%s] %s%%" % \
+                             (show, "#" * progress, " " * blank, percent))
+        sys.stdout.flush()
+
+    def increment(self, count = 1):
+        self.processed += count
+        self.display()
+
+    def end(self):
+        self.processed = self.total
+        self.display()

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index f8ba1a2..12873eb 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -26,7 +26,7 @@ from .exceptions import DBStructureError, IntegrityError, \
      InvalidKeyError, SyncError
 from .fileutils import FileJSON, hash_file, load_remote_file, copy_all, wget
 from .g_collections import Package
-from .logger import Logger
+from .logger import Logger, ProgressBar
 
 
 class PackageDB(object):
@@ -249,9 +249,9 @@ class PackageDB(object):
             logger = Logger()
             logger.info("writing database")
 
-        number_of_packages = len(list(self.database))
-        written_number = 0
-        length = 20
+        progress_bar = ProgressBar(20, len(list(self.database)))
+        if self.database:
+                progress_bar.begin()
         
         for pkgname, versions in self.database.items():
             category, name = pkgname.split('/')
@@ -273,19 +273,7 @@ class PackageDB(object):
                 pkgs = []
             pkgs.append(name)
             f.write(pkgs)
-
-            chars = ['-', '\\', '|', '/']
-            show = chars[written_number % 4]
-            percent = (written_number * 100)//number_of_packages
-            progress = (percent * length)//100
-            blank = length - progress
-
-            sys.stdout.write("\r %s [%s%s] %s%%" % \
-                             (show, "#" * progress, " " * blank, percent))
-            sys.stdout.flush()
-            written_number += 1
-
-            
+            progress_bar.increment()
 
         for category in self.categories:
             self.additional_write_category(category)
@@ -293,8 +281,7 @@ class PackageDB(object):
         self.additional_write()
 
         if self.database:
-            sys.stdout.write("\r %s [%s] %s%%" % ("-", "#" * length, 100))
-            sys.stdout.flush()
+            progress_bar.end()
             print("")
 
     def additional_write_version(self, category, package, version):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-01 22:12 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-01 22:12 UTC (permalink / raw
  To: gentoo-commits

commit:     c0881774603c9dfe89af6d68d9765ea1dd1023b5
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Sep  1 22:13:37 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Sep  1 22:13:37 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=c0881774

g_sorcery/package_db: more verbosity

---
 g_sorcery/fileutils.py  |  8 +-------
 g_sorcery/package_db.py | 31 ++++++++++++++-----------------
 2 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index c7a5257..2e836cf 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -101,13 +101,7 @@ def copy_all(src, dst):
        src: Source.
        dst: Destination.
     """
-    for f_name in os.listdir(src):
-        src_name = os.path.join(src, f_name)
-        dst_name = os.path.join(dst, f_name)
-        if os.path.isdir(src_name):
-            shutil.copytree(src_name, dst_name)
-        else:
-            shutil.copy2(src_name, dst_name)
+    os.system("cp -rv " + src + "/* " + dst)
 
 def wget(uri, directory, output=""):
     """

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index fac6c9f..404e55a 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -16,7 +16,6 @@ import hashlib
 import os
 import shutil
 import sys
-import tarfile
 
 import portage
 
@@ -112,6 +111,7 @@ class PackageDB(object):
         Args:
             directory: database directory.
         """
+        self.logger = Logger()
         self.CATEGORIES_NAME = 'categories.json'
         self.PACKAGES_NAME = 'packages.json'
         self.VERSIONS_NAME = 'versions.json'
@@ -142,32 +142,24 @@ class PackageDB(object):
         
         temp_dir = TemporaryDirectory()
         for f_name in glob.iglob(os.path.join(download_dir.name, '*.tar.gz')):
-            with tarfile.open(f_name) as f:
-                f.extractall(temp_dir.name)
+            self.logger.info("unpacking " + f_name)
+            os.system("tar -xvzf " + f_name + " -C " + temp_dir.name)
 
-        tempdb_dir = TemporaryDirectory()
-        tempdb = PackageDB(tempdb_dir.name)
-
-        for d_name in os.listdir(temp_dir.name):
-            current_dir = os.path.join(temp_dir.name, d_name)
-            if not os.path.isdir(current_dir):
-                continue
-            copy_all(current_dir, tempdb_dir.name)
+        tempdb_dir = os.listdir(temp_dir.name)[0]
+        tempdb = PackageDB(tempdb_dir)
 
         if not tempdb.check_manifest():
             raise IntegrityError('Manifest check failed.')
 
+        self.logger.info("copy files to an actual database")
         self.clean()
-        copy_all(tempdb_dir.name, self.directory)
+        copy_all(tempdb_dir, self.directory)
         
         if not self.check_manifest():
             raise IntegrityError('Manifest check failed, db inconsistent.')
                 
         del download_dir
         del temp_dir
-        del tempdb_dir
-        
-        self.read()
 
     def get_real_db_uri(self, db_uri):
         """
@@ -209,6 +201,7 @@ class PackageDB(object):
             Tuple with first element containing result of manifest check
             as boolean and second element containing list of files with errors.
         """
+        self.logger.info("checking manifest")
         m_f = FileJSON(self.directory, 'manifest.json', [])
         manifest = m_f.read()
         
@@ -220,12 +213,17 @@ class PackageDB(object):
             if not name in manifest:
                 raise DBStructureError('Bad manifest: no ' + name + ' entry')
 
+        progress_bar = ProgressBar(20, len(manifest))
+        progress_bar.begin()
         for name, value in manifest.items():
+            progress_bar.increment()
             if hash_file(os.path.join(self.directory, name), hashlib.md5()) != \
                 value:
                 result = False
                 errors.append(name)
 
+        progress_bar.end()
+        print("")
         return (result, errors)
 
     def clean(self):
@@ -249,8 +247,7 @@ class PackageDB(object):
         categories_f.write(self.categories)
 
         if self.database:
-            logger = Logger()
-            logger.info("writing database")
+            self.logger.info("writing database")
 
         progress_bar = ProgressBar(20, len(list(self.database)))
         if self.database:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-04 13:37 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-04 13:37 UTC (permalink / raw
  To: gentoo-commits

commit:     1d01ed35ce23c80357a00acea911939749d54de7
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Sep  4 13:37:28 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Sep  4 13:37:28 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=1d01ed35

g_sorcery/package_db: fix a stupid bug in sync function

---
 g_sorcery/package_db.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 404e55a..bd21857 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -145,7 +145,7 @@ class PackageDB(object):
             self.logger.info("unpacking " + f_name)
             os.system("tar -xvzf " + f_name + " -C " + temp_dir.name)
 
-        tempdb_dir = os.listdir(temp_dir.name)[0]
+        tempdb_dir = os.path.join(temp_dir.name, os.listdir(temp_dir.name)[0])
         tempdb = PackageDB(tempdb_dir)
 
         if not tempdb.check_manifest():
@@ -207,7 +207,7 @@ class PackageDB(object):
         
         result = True
         errors = []
-        
+
         names = [self.CATEGORIES_NAME]
         for name in names:
             if not name in manifest:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-04 18:03 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-04 18:03 UTC (permalink / raw
  To: gentoo-commits

commit:     d91b5eafae9a41730c9ad978f46871a32e3e1e15
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Sep  4 14:42:09 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Sep  4 14:42:09 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=d91b5eaf

g_sorcery/logger: progress bar to stderr

---
 g_sorcery/logger.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/g_sorcery/logger.py b/g_sorcery/logger.py
index 5848715..6617602 100644
--- a/g_sorcery/logger.py
+++ b/g_sorcery/logger.py
@@ -58,9 +58,9 @@ class ProgressBar(object):
         percent = (self.processed * 100)//self.total
         progress = (percent * self.length)//100
         blank = self.length - progress
-        sys.stdout.write("\r %s [%s%s] %s%%" % \
+        sys.stderr.write("\r %s [%s%s] %s%%" % \
                              (show, "#" * progress, " " * blank, percent))
-        sys.stdout.flush()
+        sys.stderr.flush()
 
     def increment(self, count = 1):
         self.processed += count


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-04 18:03 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-04 18:03 UTC (permalink / raw
  To: gentoo-commits

commit:     d2c815bf3f1557e83d550376da84ae6468c5eb8d
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Sep  4 18:02:36 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Sep  4 18:02:36 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=d2c815bf

g_sorcery/package_db: check manifest parallely

---
 g_sorcery/package_db.py | 42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index bd21857..e9402da 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -13,6 +13,7 @@
 
 import glob
 import hashlib
+import multiprocessing
 import os
 import shutil
 import sys
@@ -193,6 +194,13 @@ class PackageDB(object):
         m_f = FileJSON(self.directory, 'manifest.json', [])
         m_f.write(manifest)
 
+    def _check_manifest_process(self, i, entries, errors):
+        for name, value in entries:
+            if hash_file(os.path.join(self.directory, name), hashlib.md5()) != \
+                value:
+                errors.append(name)
+
+
     def check_manifest(self):
         """
         Check database manifest.
@@ -204,26 +212,36 @@ class PackageDB(object):
         self.logger.info("checking manifest")
         m_f = FileJSON(self.directory, 'manifest.json', [])
         manifest = m_f.read()
-        
+
+        manager = multiprocessing.Manager()
+
         result = True
-        errors = []
+        errors = manager.list()
 
         names = [self.CATEGORIES_NAME]
         for name in names:
             if not name in manifest:
                 raise DBStructureError('Bad manifest: no ' + name + ' entry')
 
-        progress_bar = ProgressBar(20, len(manifest))
-        progress_bar.begin()
-        for name, value in manifest.items():
-            progress_bar.increment()
-            if hash_file(os.path.join(self.directory, name), hashlib.md5()) != \
-                value:
-                result = False
-                errors.append(name)
+        proc_num = multiprocessing.cpu_count() + 1
+
+        portion = len(manifest) // proc_num
+        procs = []
+        entries = manifest.items()
+        
+        for i in range(proc_num - 1):
+            procs.append(multiprocessing.Process(target=self._check_manifest_process, args=(i, entries[i * portion:(i+1) * portion - 1], errors)))
+        procs.append(multiprocessing.Process(target=self._check_manifest_process, args=(proc_num - 1, entries[(proc_num - 1) * portion:], errors)))
+
+        for proc in procs:
+            proc.start()
+
+        for proc in procs:
+            proc.join()
+
+        if errors:
+            result = False
 
-        progress_bar.end()
-        print("")
         return (result, errors)
 
     def clean(self):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-04 18:14 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-04 18:14 UTC (permalink / raw
  To: gentoo-commits

commit:     39841f804b3835555bc6d9f29a2d0e9810dba8c4
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Sep  4 18:09:21 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Sep  4 18:09:21 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=39841f80

g_sorcery/package_db; fix for py-3

---
 g_sorcery/package_db.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index e9402da..5fa8d4f 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -227,7 +227,7 @@ class PackageDB(object):
 
         portion = len(manifest) // proc_num
         procs = []
-        entries = manifest.items()
+        entries = list(manifest.items())
         
         for i in range(proc_num - 1):
             procs.append(multiprocessing.Process(target=self._check_manifest_process, args=(i, entries[i * portion:(i+1) * portion - 1], errors)))


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-04 23:52 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-04 23:52 UTC (permalink / raw
  To: gentoo-commits

commit:     eda1c6a3cd450c3d193ccc2725d7a36ee02851e6
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Sep  4 23:54:22 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Sep  4 23:54:22 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=eda1c6a3

g_sorcery/package_db: use a single file for a category

---
 g_sorcery/package_db.py | 38 ++++++++++++--------------------------
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 5fa8d4f..b52c12d 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -270,32 +270,27 @@ class PackageDB(object):
         progress_bar = ProgressBar(20, len(list(self.database)))
         if self.database:
                 progress_bar.begin()
+
+        categories_content = {}
+        for category in self.categories:
+            categories_content[category] = {}
         
         for pkgname, versions in self.database.items():
             category, name = pkgname.split('/')
             if not category or (not category in self.categories):
                 raise DBStructureError('Non existent: ' + category)
+            categories_content[category][name] = {}
             for version, content in versions.items():
-                f = FileJSON(os.path.join(self.directory, category, name),
-                    version + '.json', [])
-                f.write(content)
+                categories_content[category][name][version] = content
                 self.additional_write_version(category, name, version)
-            f = FileJSON(os.path.join(self.directory, category, name),
-                self.VERSIONS_NAME, [])
-            f.write(list(versions))
             self.additional_write_package(category, name)
-            f = FileJSON(os.path.join(self.directory, category),
-                self.PACKAGES_NAME, [])
-            pkgs = f.read()
-            if not pkgs:
-                pkgs = []
-            pkgs.append(name)
-            f.write(pkgs)
             progress_bar.increment()
 
         for category in self.categories:
+            f = FileJSON(os.path.join(self.directory, category), self.PACKAGES_NAME, [])
+            f.write(categories_content[category])
             self.additional_write_category(category)
-            
+
         self.additional_write()
 
         if self.database:
@@ -345,24 +340,15 @@ class PackageDB(object):
             if not packages:
                 raise DBStructureError('Empty category: ' + category)
             
-            for name in packages:
-                package_path = os.path.join(category_path, name)
-                if not os.path.isdir(category_path):
-                    error_msg = 'Empty package: ' + category + '/' + name
-                    raise DBStructureError(error_msg)
+            for name, versions in packages.items():
                 
-                f = FileJSON(package_path, self.VERSIONS_NAME, [])
-                versions = f.read()
                 if not versions:
                     error_msg = 'Empty package: ' + category + '/' + name
                     raise DBStructureError(error_msg)
-
+                
                 pkgname = category + '/' + name
-                self.database[pkgname] = {}
+                self.database[pkgname] = versions
                 for version in versions:
-                    f = FileJSON(package_path, version + '.json', [])
-                    ebuild_data = f.read()
-                    self.database[pkgname][version] = ebuild_data
                     self.additional_read_version(category, name, version)
                 self.additional_read_package(category, name)
             self.additional_read_category(category)


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-05 21:29 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-05 21:29 UTC (permalink / raw
  To: gentoo-commits

commit:     a53fabbfe293bbbc2380a7bcd3331fee1fde918e
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Sep  5 21:30:31 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Sep  5 21:30:31 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=a53fabbf

g_sorcery/backend: fix problems with unicode for python-2

---
 g_sorcery/backend.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 963eb06..686cda0 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -478,12 +478,12 @@ class Backend(object):
             source = ebuild_g.generate(package, ebuild_data)
             with open(os.path.join(path,
                         name + '-' + version + '.ebuild'),
-                      'w') as f:
-                f.write('\n'.join(source))
+                      'wb') as f:
+                f.write('\n'.join(source).encode('utf-8'))
 
             source = metadata_g.generate(package)
-            with open(os.path.join(path, 'metadata.xml'), 'w') as f:
-                f.write('\n'.join(source))
+            with open(os.path.join(path, 'metadata.xml'), 'wb') as f:
+                f.write('\n'.join(source).encode('utf-8'))
 
         eclass_g = self.eclass_g_class()
         path = os.path.join(overlay, 'eclass')


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-15 17:46 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-15 17:46 UTC (permalink / raw
  To: gentoo-commits

commit:     c78429b58c5c7fb038a03f3ba8db237dcdfd9070
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Sep 15 17:45:50 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Sep 15 17:45:50 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=c78429b5

g_sorcery/backend: add checking for installed overlays and fix overlay names in masters

---
 g_sorcery/backend.py | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 76c8cd2..fb5e698 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -14,6 +14,8 @@
 import argparse
 import os
 
+import portage
+
 from .compatibility import py2k
 
 if py2k:
@@ -106,6 +108,7 @@ class Backend(object):
             else:
                 overlay = config['default_overlay']
         overlay = args.overlay
+        overlay = os.path.abspath(overlay)
         return overlay
 
     def _get_package_db(self, args, config, global_config):
@@ -473,9 +476,31 @@ class Backend(object):
             masters = elist(["gentoo"])
         else:
             masters = elist(config["repositories"][args.repository]["masters"])
+
+        overlays = FileJSON("/var/lib/g-sorcery", "overlays.json", [])
+        overlays_old_info = overlays.read()
+        overlays_info = {}
+        masters_overlays = elist()
+        portage_overlays = [repo.location for repo in portage.settings.repositories]
+
+        for repo, info in overlays_old_info.items():
+            if info["path"] in portage_overlays:
+                overlays_info[repo] = info
+
+        overlays.write(overlays_info)
+
+        for repo in masters:
+            if repo != "gentoo":
+                if not repo in overlays_info:
+                    self.logger.error("Master repository " + repo + " not available on your system")
+                    self.logger.error("Please, add it with layman -a " + repo)
+                    return -1
+                masters_overlays.append(overlays_info[repo]["repo-name"])
+
+        overlays_info[args.repository] = {"repo-name": os.path.basename(overlay), "path": overlay}
         with open(os.path.join(overlay, 'metadata', 'layout.conf'), 'w') as f:
             f.write("repo-name = %s\n" % os.path.basename(overlay))
-            f.write("masters = %s\n" % masters)
+            f.write("masters = %s\n" % masters_overlays)
         
         if args.digest:
             ebuild_g = self.ebuild_g_with_digest_class(pkg_db)
@@ -531,6 +556,7 @@ class Backend(object):
         else:
             pkgnames = catpkg_names
             self.fast_digest(overlay, pkgnames)
+        overlays.write(overlays_info)
 
     def install(self, args, config, global_config):
         """


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-15 17:46 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-15 17:46 UTC (permalink / raw
  To: gentoo-commits

commit:     345f07d064f1c8fe38bd4a1c793b877afd95d6c4
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Sep 15 15:36:44 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Sep 15 15:36:44 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=345f07d0

add a list of ebuilds to be generated automatically

---
 g_sorcery/backend.py | 129 ++++++++++++++++++++++++++++++++-------------------
 1 file changed, 80 insertions(+), 49 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 686cda0..76c8cd2 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -23,7 +23,7 @@ else:
 
 from .g_collections import Package, elist
 from .fileutils import fast_manifest, FileJSON
-from .exceptions import DependencyError, DigestError
+from .exceptions import DependencyError, DigestError, InvalidKeyError
 from .logger import Logger
 from .mangler import package_managers
 from .package_db import PackageDB
@@ -225,46 +225,8 @@ class Backend(object):
 
         pkgname = args.pkgname
 
-        parts = pkgname.split('/')
-
-        category = None
-        
-        if len(parts) == 1:
-            name = parts[0]
-        elif len(parts) == 2:
-            category = parts[0]
-            name = parts[1]
-        else:
-            self.logger.error('bad package name: ' + pkgname + '\n')
-            return -1
-
-        if not category:
-            all_categories = pkg_db.list_categories()
-            categories = []
-            for cat in all_categories:
-                if pkg_db.in_category(cat, name):
-                    categories.append(cat)
-
-            if not len(categories):
-                self.logger.error('no package with name ' \
-                                  + pkgname + ' found\n')
-                return -1
-                    
-            if len(categories) > 1:
-                self.logger.error('ambiguous packagename: ' + pkgname + '\n')
-                self.logger.error('please select one of' \
-                                  + 'the following packages:\n')
-                for cat in categories:
-                    self.logger.error('    ' + cat + '/' + pkgname + '\n')
-                return -1
-                
-            category = categories[0]
-        versions = pkg_db.list_package_versions(category, name)
-        dependencies = set()
         try:
-            for version in versions:
-                dependencies |= self.solve_dependencies(pkg_db,
-                                    Package(category, name, version))[0]
+            dependencies = self.get_dependencies(pkg_db, pkgname)
         except Exception as e:
             self.logger.error('dependency solving failed: ' + str(e) + '\n')
             return -1
@@ -349,6 +311,48 @@ class Backend(object):
                 f.write('\n'.join(source))
 
 
+    def get_dependencies(self, package_db, pkgname):
+        parts = pkgname.split('/')
+        category = None
+        if len(parts) == 1:
+            name = parts[0]
+        elif len(parts) == 2:
+            category = parts[0]
+            name = parts[1]
+        else:
+            error = 'bad package name: ' + pkgname
+            self.logger.error(error + '\n')
+            raise DependencyError(error)
+
+        if not category:
+            all_categories = package_db.list_categories()
+            categories = []
+            for cat in all_categories:
+                if package_db.in_category(cat, name):
+                    categories.append(cat)
+
+            if not len(categories):
+                error = 'no package with name ' \
+                                  + pkgname + ' found'
+                self.logger.error(error + '\n')
+                raise DependencyError(error)
+
+            if len(categories) > 1:
+                self.logger.error('ambiguous packagename: ' + pkgname + '\n')
+                self.logger.error('please select one of' \
+                                  + 'the following packages:\n')
+                for cat in categories:
+                    self.logger.error('    ' + cat + '/' + pkgname + '\n')
+                raise DependencyError("ambiguous packagename")
+
+            category = categories[0]
+        versions = package_db.list_package_versions(category, name)
+        dependencies = set()
+        for version in versions:
+            dependencies |= self.solve_dependencies(package_db,
+                                    Package(category, name, version))[0]
+        return dependencies
+
     def solve_dependencies(self, package_db, package,
                            solved_deps=None, unsolved_deps=None):
         """
@@ -385,16 +389,24 @@ class Backend(object):
         if not found:
             error = "package " + package.category + '/' + \
                 package.name + '-' + package.version + " not found"
-            raise DependencyError(error)
-        
+            self.logger.error(error)
+            # at the moment ignore unsolved dependencies, as those deps can be in other repo
+            # or can be external: portage will catch it
+            unsolved_deps.remove(package)
+            return (solved_deps, unsolved_deps)
+
         dependencies = desc["dependencies"]
         for pkg in dependencies:
-            versions = package_db.list_package_versions(pkg.category,
+            try:
+                versions = package_db.list_package_versions(pkg.category,
                                                         pkg.package)
-            for version in versions:            
-                solved_deps, unsolved_deps = self.solve_dependencies(package_db,
+                for version in versions:            
+                    solved_deps, unsolved_deps = self.solve_dependencies(package_db,
                                     Package(pkg.category, pkg.package, version),
                                     solved_deps, unsolved_deps)
+            except InvalidKeyError:
+                # ignore non existing packages
+                continue
         
         solved_deps.add(package)
         unsolved_deps.remove(package)
@@ -441,6 +453,11 @@ class Backend(object):
         Returns:
             Exit status.
         """
+        try:
+            packages = global_config.get(config["backend"], args.repository + "_packages").split(" ")
+        except Exception:
+            packages = []
+
         self.logger.info("tree generation")
         overlay = self._get_overlay(args, config, global_config)
         pkg_db = self._get_package_db(args, config, global_config)
@@ -465,8 +482,22 @@ class Backend(object):
         else:
             ebuild_g = self.ebuild_g_without_digest_class(pkg_db)
         metadata_g = self.metadata_g_class(pkg_db)
-        
-        for package, ebuild_data in pkg_db:
+
+        packages_iter = pkg_db
+        catpkg_names = pkg_db.list_catpkg_names()
+        if packages:
+            dependencies = set()
+            catpkg_names = set()
+            packages_dict = {}
+            for pkg in packages:
+                dependencies |= self.get_dependencies(pkg_db, pkg)
+
+            for pkg in dependencies:
+                catpkg_names |= set([pkg.category + '/' + pkg.name])
+                packages_dict[pkg] = pkg_db.get_package_description(pkg)
+            packages_iter = packages_dict.items()
+
+        for package, ebuild_data in packages_iter:
             category = package.category
             name = package.name
             version = package.version
@@ -498,7 +529,7 @@ class Backend(object):
         if args.digest:
             self.digest(overlay)
         else:
-            pkgnames = pkg_db.list_catpkg_names()
+            pkgnames = catpkg_names
             self.fast_digest(overlay, pkgnames)
 
     def install(self, args, config, global_config):
@@ -516,7 +547,7 @@ class Backend(object):
         self.generate(args, config, global_config)
         try:
             package_manager = global_config.get("main", "package_manager")
-        except configparser.NoOptionError:    
+        except configparser.NoOptionError:
             package_manager_class = package_managers["portage"]
             package_manager = None
         if  package_manager:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-15 18:08 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-15 18:08 UTC (permalink / raw
  To: gentoo-commits

commit:     06d3c9a7d81c6bde33575183827fe06c3446a3c7
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Sep 15 18:08:02 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Sep 15 18:08:02 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=06d3c9a7

g_sorcery/backend: add gentoo entry to masters

---
 g_sorcery/backend.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index fb5e698..49b80fd 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -497,6 +497,8 @@ class Backend(object):
                     return -1
                 masters_overlays.append(overlays_info[repo]["repo-name"])
 
+        masters_overlays.append("gentoo")
+
         overlays_info[args.repository] = {"repo-name": os.path.basename(overlay), "path": overlay}
         with open(os.path.join(overlay, 'metadata', 'layout.conf'), 'w') as f:
             f.write("repo-name = %s\n" % os.path.basename(overlay))


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-15 22:38 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-15 22:38 UTC (permalink / raw
  To: gentoo-commits

commit:     4517e12bc899f50a7ce705967793f489fdca63b9
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Sep 15 21:18:50 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Sep 15 21:18:50 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=4517e12b

g_sorcery/fileutils: fix

---
 g_sorcery/fileutils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 2e836cf..24ad8e1 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -139,7 +139,7 @@ class ManifestEntry:
     A manifest entry for a file.
     """
 
-    __slots__ = ('directory', 'name', 'ftype', 'digest',
+    __slots__ = ('directory', 'name', 'ftype',
                  'size', 'sha256', 'sha512', 'whirlpool')
     
     def __init__(self, directory, name, ftype):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-16 14:33 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-16 14:33 UTC (permalink / raw
  To: gentoo-commits

commit:     b7395883e14280193c4d18037c3a0355dc2cda3d
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Sep 16 12:41:00 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Sep 16 12:41:00 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=b7395883

g_sorcery/package_db: fix sync and do not use multiprocessing in check_manifest

---
 g_sorcery/package_db.py | 35 +++++++----------------------------
 1 file changed, 7 insertions(+), 28 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index b52c12d..6c8a0d9 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -13,7 +13,6 @@
 
 import glob
 import hashlib
-import multiprocessing
 import os
 import shutil
 import sys
@@ -149,14 +148,14 @@ class PackageDB(object):
         tempdb_dir = os.path.join(temp_dir.name, os.listdir(temp_dir.name)[0])
         tempdb = PackageDB(tempdb_dir)
 
-        if not tempdb.check_manifest():
+        if not tempdb.check_manifest()[0]:
             raise IntegrityError('Manifest check failed.')
 
         self.logger.info("copy files to an actual database")
         self.clean()
         copy_all(tempdb_dir, self.directory)
         
-        if not self.check_manifest():
+        if not self.check_manifest()[0]:
             raise IntegrityError('Manifest check failed, db inconsistent.')
                 
         del download_dir
@@ -194,13 +193,6 @@ class PackageDB(object):
         m_f = FileJSON(self.directory, 'manifest.json', [])
         m_f.write(manifest)
 
-    def _check_manifest_process(self, i, entries, errors):
-        for name, value in entries:
-            if hash_file(os.path.join(self.directory, name), hashlib.md5()) != \
-                value:
-                errors.append(name)
-
-
     def check_manifest(self):
         """
         Check database manifest.
@@ -213,31 +205,18 @@ class PackageDB(object):
         m_f = FileJSON(self.directory, 'manifest.json', [])
         manifest = m_f.read()
 
-        manager = multiprocessing.Manager()
-
         result = True
-        errors = manager.list()
+        errors = []
 
         names = [self.CATEGORIES_NAME]
         for name in names:
             if not name in manifest:
                 raise DBStructureError('Bad manifest: no ' + name + ' entry')
 
-        proc_num = multiprocessing.cpu_count() + 1
-
-        portion = len(manifest) // proc_num
-        procs = []
-        entries = list(manifest.items())
-        
-        for i in range(proc_num - 1):
-            procs.append(multiprocessing.Process(target=self._check_manifest_process, args=(i, entries[i * portion:(i+1) * portion - 1], errors)))
-        procs.append(multiprocessing.Process(target=self._check_manifest_process, args=(proc_num - 1, entries[(proc_num - 1) * portion:], errors)))
-
-        for proc in procs:
-            proc.start()
-
-        for proc in procs:
-            proc.join()
+        for name, value in manifest.items():
+            if hash_file(os.path.join(self.directory, name), hashlib.md5()) != \
+                value:
+                errors.append(name)
 
         if errors:
             result = False


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-16 14:33 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-16 14:33 UTC (permalink / raw
  To: gentoo-commits

commit:     e58e7b2cc35944138b123ea220edd5d7ceeba716
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Sep 16 14:20:26 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Sep 16 14:20:26 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=e58e7b2c

g_sorcery/g_collections: add equality and hash to Package

---
 g_sorcery/g_collections.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/g_sorcery/g_collections.py b/g_sorcery/g_collections.py
index 64efaf6..104673d 100644
--- a/g_sorcery/g_collections.py
+++ b/g_sorcery/g_collections.py
@@ -94,6 +94,14 @@ class Package(object):
     def __str__(self):
         return self.category + '/' + self.name + '-' + self.version
 
+    def __eq__(self, other):
+        return self.category == other.category and \
+            self.name == other.name and \
+            self.version == other.version
+
+    def __hash__(self):
+        return hash(self.category + self.name + self.version)
+
     def serialize(self):
         return [self.category, self.name, self.version]
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-16 15:05 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-16 15:05 UTC (permalink / raw
  To: gentoo-commits

commit:     87b54474bb528e1da59c318b65e9806a0bb38926
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Sep 16 15:04:58 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Sep 16 15:04:58 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=87b54474

g_sorcery/package_db: fix

---
 g_sorcery/package_db.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 6c8a0d9..4320ab5 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -562,9 +562,7 @@ class DBGenerator(object):
         if generate:
             pkg_db.clean()
             self.generate_tree(pkg_db, common_config, config)
-            #todo: make db write on every add_package and only necessary info
-            pkg_db.write()
-            pkg_db.manifest()
+            pkg_db.write_and_manifest()
         return pkg_db
 
     def generate_tree(self, pkg_db, common_config, config):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-18 22:09 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-18 22:09 UTC (permalink / raw
  To: gentoo-commits

commit:     8fb27b1ef7c43d9a912e2d19c813045f422c6c02
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Sep 18 20:08:51 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Sep 18 20:08:51 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=8fb27b1e

g_sorcery/package_db: fix external dependency convertion

---
 g_sorcery/package_db.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 4320ab5..79b7ca1 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -727,7 +727,7 @@ class DBGenerator(object):
                         external_dep = ext_deps[dependency]
         if external_dep:
             if external:
-                return self.convert_external_dependency(configs, dependency)
+                return self.convert_external_dependency(configs, external_dep)
             else:
                 return None
         else:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-19 23:21 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-19 23:21 UTC (permalink / raw
  To: gentoo-commits

commit:     5e232f1980c3e24bf80f624b97a13205086053e9
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Sep 19 22:31:12 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Sep 19 22:31:12 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=5e232f19

g_sorcery: comments in sources

---
 g_sorcery/backend.py       | 11 +++++++++++
 g_sorcery/fileutils.py     |  7 ++++++-
 g_sorcery/g_collections.py |  3 ++-
 g_sorcery/logger.py        | 24 ++++++++++++++++++++++++
 g_sorcery/package_db.py    | 13 ++++---------
 5 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 49b80fd..5b10574 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -588,6 +588,17 @@ class Backend(object):
         package_manager.install(args.pkgname, *args.pkgmanager_flags)
         
     def __call__(self, args, config, global_config):
+        """
+        Execute a command
+
+        Args:
+            args: Command line arguments.
+            config: Backend config.
+            global_config: g-sorcery config.
+
+        Returns:
+            Exit status.
+        """
         args = self.parser.parse_args(args)
         info_f = FileJSON(os.path.join(args.overlay, self.sorcery_dir),
                           "info.json", ["repositories"])

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 24ad8e1..f444f4a 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -24,7 +24,8 @@ from .serialization import JSONSerializer, deserializeHook
 
 class FileJSON(object):
     """
-    Class for JSON files.
+    Class for JSON files. Supports custom JSON serialization
+    provided by g_sorcery.serialization.
     """
     def __init__(self, directory, name, mandatories=[]):
         """
@@ -110,6 +111,7 @@ def wget(uri, directory, output=""):
     Args:
         uri: URI.
         directory: Directory where file should be saved.
+        output: Name of output file.
 
     Returns:
         Nonzero in case of a failure.
@@ -125,6 +127,9 @@ def get_pkgpath(root = None):
     """
     Get package path.
 
+    Args:
+        root: module file path
+
     Returns:
         Package path.
     """

diff --git a/g_sorcery/g_collections.py b/g_sorcery/g_collections.py
index 104673d..b28db6a 100644
--- a/g_sorcery/g_collections.py
+++ b/g_sorcery/g_collections.py
@@ -7,7 +7,8 @@
     
     Customized classes of standard python data types
     for use withing g-sorcery for custom formatted string output
-    substitution in our ebuild templates.
+    substitution in our ebuild templates and classes for storing
+    information about packages and dependencies.
     
     :copyright: (c) 2013 by Brian Dolbec
     :copyright: (c) 2013 by Jauhien Piatlicki

diff --git a/g_sorcery/logger.py b/g_sorcery/logger.py
index 6617602..9fec3b6 100644
--- a/g_sorcery/logger.py
+++ b/g_sorcery/logger.py
@@ -41,16 +41,31 @@ class ProgressBar(object):
     __slots__ = ('length', 'total', 'processed', 'chars')
     
     def __init__(self, length, total, processed = 0):
+        """
+        Args:
+            length: Length of the progress bar.
+            total: The overall number of items to process.
+            processe: Number of processed items.
+        """
         self.length = length
         self.total = total
         self.chars = ['-', '\\', '|', '/']
         self.processed = processed
 
     def begin(self):
+        """
+        Start displaying the progress bar with 0% progress.
+        """
         self.processed = 0
         self.display()
 
     def display(self, processed = None):
+        """
+        Show the progress bar with current progress.
+
+        Args:
+            processed: Number of processed items.
+        """
         if processed:
             self.processed = processed
 
@@ -63,9 +78,18 @@ class ProgressBar(object):
         sys.stderr.flush()
 
     def increment(self, count = 1):
+        """
+        Increment number of processed items.
+
+        Args:
+            count: Step of incrementation.
+        """
         self.processed += count
         self.display()
 
     def end(self):
+        """
+        Show 100%.
+        """
         self.processed = self.total
         self.display()

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 79b7ca1..13a6141 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -39,14 +39,7 @@ class PackageDB(object):
         manifest.json: database manifest
         categories.json: information about categories
         category1
-            packages.json: list of packages
-            package1
-                versions.json: list of versions
-                version1.json: description of a package
-                version2.json: description of a package
-                ...
-            package2
-            ...
+            packages.json: information about available packages
         category2
         ...
     
@@ -114,7 +107,6 @@ class PackageDB(object):
         self.logger = Logger()
         self.CATEGORIES_NAME = 'categories.json'
         self.PACKAGES_NAME = 'packages.json'
-        self.VERSIONS_NAME = 'versions.json'
         self.directory = os.path.abspath(directory)
         self.reset_db()
 
@@ -233,6 +225,9 @@ class PackageDB(object):
         self.write_and_manifest()
 
     def write_and_manifest(self):
+        """
+        Write and digest database.
+        """
         self.write()
         self.manifest()
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2013-09-20 15:09 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2013-09-20 15:09 UTC (permalink / raw
  To: gentoo-commits

commit:     91b5e1839487e3e26fb7d084ace158d27ce2f36d
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Fri Sep 20 15:08:44 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Fri Sep 20 15:08:44 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=91b5e183

g_sorcery: fixes

---
 g_sorcery/backend.py       | 20 +++++++++++++-------
 g_sorcery/compatibility.py |  2 ++
 g_sorcery/fileutils.py     |  9 ++++++---
 g_sorcery/g_sorcery.py     |  8 +-------
 g_sorcery/mangler.py       |  1 +
 g_sorcery/metadata.py      |  4 +++-
 g_sorcery/package_db.py    |  2 +-
 7 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 5b10574..e606348 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -16,13 +16,7 @@ import os
 
 import portage
 
-from .compatibility import py2k
-
-if py2k:
-    import ConfigParser as configparser
-else:
-    import configparser
-
+from .compatibility import configparser
 from .g_collections import Package, elist
 from .fileutils import fast_manifest, FileJSON
 from .exceptions import DependencyError, DigestError, InvalidKeyError
@@ -315,6 +309,18 @@ class Backend(object):
 
 
     def get_dependencies(self, package_db, pkgname):
+        """
+        Get dependencies for a given package.
+
+        Args:
+            package_db: Database.
+            pkgname: package name (string).
+
+        Returns:
+            A set containing dependencies (instances of Package).
+        Package version is ignored currently and a returned set contains all
+        the versions of packages pkgname depends on.
+        """
         parts = pkgname.split('/')
         category = None
         if len(parts) == 1:

diff --git a/g_sorcery/compatibility.py b/g_sorcery/compatibility.py
index 59c239e..edc61c3 100644
--- a/g_sorcery/compatibility.py
+++ b/g_sorcery/compatibility.py
@@ -18,6 +18,7 @@ py2k = sys.version_info < (3, 0)
 if py2k:
 
     from tempfile import mkdtemp
+    import ConfigParser as configparser
     
     class TemporaryDirectory(object):
         def __init__(self):
@@ -27,6 +28,7 @@ if py2k:
             shutil.rmtree(self.name)
 else:
     from tempfile import TemporaryDirectory
+    import configparser
 
 #basestring removed in py3k
 #fix for it from https://github.com/oxplot/fysom/issues/1

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index f444f4a..443206c 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -27,7 +27,7 @@ class FileJSON(object):
     Class for JSON files. Supports custom JSON serialization
     provided by g_sorcery.serialization.
     """
-    def __init__(self, directory, name, mandatories=[]):
+    def __init__(self, directory, name, mandatories=None):
         """
         Args:
             directory: File directory.
@@ -38,7 +38,10 @@ class FileJSON(object):
         self.directory = os.path.abspath(directory)
         self.name = name
         self.path = os.path.join(directory, name)
-        self.mandatories = mandatories
+        if not mandatories:
+            self.mandatories = []
+        else:
+            self.mandatories = mandatories
 
     def read(self):
         """
@@ -139,7 +142,7 @@ def get_pkgpath(root = None):
         root = os.path.realpath(root)
     return os.path.dirname(os.path.abspath(root))
 
-class ManifestEntry:
+class ManifestEntry(object):
     """
     A manifest entry for a file.
     """

diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py
index b177cfa..76ecf82 100644
--- a/g_sorcery/g_sorcery.py
+++ b/g_sorcery/g_sorcery.py
@@ -16,13 +16,7 @@ import importlib
 import os
 import sys
 
-from .compatibility import py2k
-
-if py2k:
-    import ConfigParser as configparser
-else:
-    import configparser
-
+from .compatibility import configparser
 from .fileutils import FileJSON
 from .exceptions import FileJSONError
 from .logger import Logger

diff --git a/g_sorcery/mangler.py b/g_sorcery/mangler.py
index 6b31f27..c85e029 100644
--- a/g_sorcery/mangler.py
+++ b/g_sorcery/mangler.py
@@ -44,6 +44,7 @@ class Portage(PackageManager):
     Portage package manager abstraction.
     """
     def __init__(self):
+        super(Portage, self).__init__()
         self.executable = "/usr/bin/emerge"
 
     def install(self, pkgname, *args):

diff --git a/g_sorcery/metadata.py b/g_sorcery/metadata.py
index 36a2e07..fb7cb37 100644
--- a/g_sorcery/metadata.py
+++ b/g_sorcery/metadata.py
@@ -215,12 +215,14 @@ class MetadataGenerator(object):
     """
     Metada generator. Generates metadata for a given package.
     """
-    def __init__(self, package_db, schema = default_schema):
+    def __init__(self, package_db, schema = None):
         """
         Args:
             package_db: Package database.
             schema: Schema of an XML tree.
         """
+        if not schema:
+            schema = default_schema
         self.package_db = package_db
         self.xmlg = XMLGenerator('pkgmetadata', schema)
         

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 13a6141..f19f9d4 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -243,7 +243,7 @@ class PackageDB(object):
 
         progress_bar = ProgressBar(20, len(list(self.database)))
         if self.database:
-                progress_bar.begin()
+            progress_bar.begin()
 
         categories_content = {}
         for category in self.categories:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
  2014-11-24 14:25 [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
@ 2014-11-24 14:25 ` Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2014-11-24 14:25 UTC (permalink / raw
  To: gentoo-commits

commit:     3acb0ce6d38d02915f142f2ec69c9c24fb1ec99c
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 24 14:22:28 2014 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Mon Nov 24 14:22:28 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=3acb0ce6

[g_sorcery/g_sorcery.py] check backend initialization

---
 g_sorcery/g_sorcery.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py
index 76ecf82..b41adfb 100644
--- a/g_sorcery/g_sorcery.py
+++ b/g_sorcery/g_sorcery.py
@@ -4,9 +4,9 @@
 """
     g_sorcery.py
     ~~~~~~~~~~~~
-    
+
     the main module
-    
+
     :copyright: (c) 2013 by Jauhien Piatlicki
     :license: GPL-2, see LICENSE for more details.
 """
@@ -46,6 +46,10 @@ def main():
         return -1
     backend = get_backend(config['package'])
 
+    if not backend:
+        logger.error("backend initialization failed, exiting")
+        return -1
+
     config_file = None
     for path in '.', '~', '/etc/g-sorcery':
         config_file = os.path.join(path, "g-sorcery.cfg")
@@ -57,7 +61,7 @@ def main():
     if not config_file:
         logger.error('no global config file\n')
         return -1
-    
+
     global_config = configparser.ConfigParser()
     global_config.read(config_file)
 
@@ -74,7 +78,7 @@ def get_backend(package):
     except ImportError as error:
         logger.error("error importing backend: " + str(error))
         return None
-    
+
     return module
 
 


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2015-04-22  7:35 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2015-04-22  7:35 UTC (permalink / raw
  To: gentoo-commits

commit:     eef3ee7168fbf38bb5ef56a47fee0c0873cd4540
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 17 07:27:02 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Fri Apr 17 07:27:02 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=eef3ee71

[g_sorcery] fix DB cleaning

do not write empty DB on cleaning,
so syncing with old (v. 0) DBs works

 g_sorcery/db_layout.py  | 1 +
 g_sorcery/package_db.py | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/db_layout.py b/g_sorcery/db_layout.py
index fe6f281..ea4298a 100644
--- a/g_sorcery/db_layout.py
+++ b/g_sorcery/db_layout.py
@@ -230,6 +230,7 @@ class DBLayout(object):
         """
         if os.path.exists(self.directory):
             shutil.rmtree(self.directory)
+        os.makedirs(self.directory)
 
     def read(self):
         """

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 5eeeb63..ec2d45f 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -216,7 +216,6 @@ class PackageDB(object):
         """
         self.db_layout.clean()
         self.reset_db()
-        self.write()
 
 
     def write(self):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
  2015-04-20 21:36 [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
@ 2015-04-22  7:35 ` Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2015-04-22  7:35 UTC (permalink / raw
  To: gentoo-commits

commit:     bbe16a229b42e96f847246d82e8f1bcff4d60a82
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 17 20:59:50 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Fri Apr 17 20:59:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=bbe16a22

[g_sorcery/db_layout,g_sorcery/package_db] better version/format checking, fix exceptions

 g_sorcery/db_layout.py  |  4 +++-
 g_sorcery/package_db.py | 19 +++++++++++++------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/g_sorcery/db_layout.py b/g_sorcery/db_layout.py
index da779bd..8eb81da 100644
--- a/g_sorcery/db_layout.py
+++ b/g_sorcery/db_layout.py
@@ -26,6 +26,8 @@ PACKAGES_FILE_NAME = 'packages'
 JSON_FILE_SUFFIX = 'json'
 BSON_FILE_SUFFIX = 'bson'
 
+SUPPORTED_DB_LAYOUTS=[0, 1]
+
 class CategoryJSON(FileJSON):
     """
     Category file in JSON format.
@@ -182,7 +184,7 @@ def get_layout(metadata):
             raise DBLayoutError("unsupported packages file format: " + category_format)
         return (category_cls, [file_name(CATEGORIES_FILE_NAME), file_name(METADATA_FILE_NAME)])
     else:
-        raise DBLayoutError("unsupported DB layout version: " + layout_version)
+        raise DBLayoutError("unsupported DB layout version: " + str(layout_version))
 
 
 class DBLayout(object):

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 5374ae5..4c67fdc 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -18,12 +18,13 @@ import portage
 
 from .compatibility import basestring, py2k, TemporaryDirectory
 
-from .db_layout import DBLayout, JSON_FILE_SUFFIX
-from .exceptions import DBError, DBStructureError, InvalidKeyError, SyncError
+from .db_layout import DBLayout, JSON_FILE_SUFFIX, SUPPORTED_DB_LAYOUTS, SUPPORTED_FILE_FORMATS
+from .exceptions import DBError, DBLayoutError, DBStructureError, InvalidKeyError, SyncError
 from .fileutils import FileJSON, load_remote_file, copy_all, wget
 from .g_collections import Package
 from .logger import Logger
 
+SUPPORTED_DB_STRUCTURES=[0, 1]
 
 class PackageDB(object):
     """
@@ -142,11 +143,17 @@ class PackageDB(object):
 
         if preferred_layout_version == 0 \
            and preferred_db_version != 0:
-            raise DBStructureError("Wrong DB version: " + preferred_db_version + \
+            raise DBStructureError("Wrong DB version: " + str(preferred_db_version) + \
                                    ", with DB layout version 0 it can be only 0")
 
-        if not preferred_db_version in [0, 1]:
-            raise DBStructureError("Unsupported DB version: " + preferred_db_version)
+        if not preferred_db_version in SUPPORTED_DB_STRUCTURES:
+            raise DBStructureError("Unsupported DB version: " + str(preferred_db_version))
+
+        if not preferred_layout_version in SUPPORTED_DB_LAYOUTS:
+            raise DBLayoutError("unsupported DB layout version: " + str(preferred_layout_version))
+
+        if not preferred_category_format in SUPPORTED_FILE_FORMATS:
+            raise DBLayoutError("unsupported packages file format: " + preferred_category_format)
 
         self.logger = Logger()
         self.directory = os.path.abspath(directory)
@@ -261,7 +268,7 @@ class PackageDB(object):
         elif db_version == 1:
             pass
         else:
-            raise DBStructureError("Unsupported DB version: " + db_version)
+            raise DBStructureError("Unsupported DB version: " + str(db_version))
 
 
     def add_category(self, category, description=None):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
  2015-08-18 10:41 [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
@ 2015-08-18 10:42 ` Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2015-08-18 10:42 UTC (permalink / raw
  To: gentoo-commits

commit:     e71fd837faf51fc0e9a123477bfc7558c24b37c0
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 16 22:43:08 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Sun Aug 16 22:43:08 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=e71fd837

[g_sorcery/fileutils] set wget timeout to 2 seconds

 g_sorcery/fileutils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index d783c8a..235eaec 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -149,9 +149,9 @@ def wget(uri, directory, output=""):
     """
     if output:
         ret = os.system('wget ' + uri +
-                    ' -O ' + os.path.join(directory, output))
+                        ' -O ' + os.path.join(directory, output) + ' -T 2')
     else:
-        ret = os.system('wget -P ' + directory + ' ' + uri)
+        ret = os.system('wget -P ' + directory + ' ' + uri + ' -T 2')
     return ret
 
 def get_pkgpath(root = None):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2015-08-18 18:59 Jauhien Piatlicki
  0 siblings, 0 replies; 86+ messages in thread
From: Jauhien Piatlicki @ 2015-08-18 18:59 UTC (permalink / raw
  To: gentoo-commits

commit:     7716920fcfcf1595f6b575e1fe41c733c5ec7ab2
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 18 18:07:55 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Tue Aug 18 18:50:20 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=7716920f

[g_sorcery/fileutils] make wget timeout optional

 g_sorcery/fileutils.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 235eaec..3440ec7 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -135,7 +135,7 @@ def copy_all(src, dst):
     """
     os.system("cp -rv " + src + "/* " + dst)
 
-def wget(uri, directory, output=""):
+def wget(uri, directory, output="", timeout = None):
     """
     Fetch a file.
 
@@ -143,15 +143,21 @@ def wget(uri, directory, output=""):
         uri: URI.
         directory: Directory where file should be saved.
         output: Name of output file.
+        timeout: Timeout for wget.
 
     Returns:
         Nonzero in case of a failure.
     """
+    if timeout is None:
+        timeout_str = ' '
+    else:
+        timeout_str = ' -T ' + str(timeout)
+
     if output:
         ret = os.system('wget ' + uri +
-                        ' -O ' + os.path.join(directory, output) + ' -T 2')
+                        ' -O ' + os.path.join(directory, output) + timeout_str)
     else:
-        ret = os.system('wget -P ' + directory + ' ' + uri + ' -T 2')
+        ret = os.system('wget -P ' + directory + ' ' + uri + timeout_str)
     return ret
 
 def get_pkgpath(root = None):
@@ -255,7 +261,7 @@ def _call_parser(f_name, parser, open_file = True, open_mode = 'r'):
     return {os.path.basename(f_name): data}
 
 
-def load_remote_file(uri, parser, open_file = True, open_mode='r', output=""):
+def load_remote_file(uri, parser, open_file = True, open_mode = 'r', output = "", timeout = None):
     """
     Load files from an URI.
 
@@ -264,7 +270,8 @@ def load_remote_file(uri, parser, open_file = True, open_mode='r', output=""):
         parser: Parser that will be applied to downloaded files.
         open_file: Whether parser accepts a file descriptor.
         open_mode: Open mode for a file.
-        output: What output name should downloaded file have
+        output: What output name should downloaded file have.
+        timeout: URI access timeout.
     (it will be a key identifying data loaded from this file)
 
     Returns:
@@ -272,7 +279,7 @@ def load_remote_file(uri, parser, open_file = True, open_mode='r', output=""):
     """
     download_dir = TemporaryDirectory()
     loaded_data = {}
-    if wget(uri, download_dir.name, output):
+    if wget(uri, download_dir.name, output, timeout=timeout):
         raise DownloadingError("wget failed: " + uri)
     for f_name in glob.glob(os.path.join(download_dir.name, "*")):
         if tarfile.is_tarfile(f_name):


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2023-02-24 18:02 Ulrich Müller
  0 siblings, 0 replies; 86+ messages in thread
From: Ulrich Müller @ 2023-02-24 18:02 UTC (permalink / raw
  To: gentoo-commits

commit:     e19ac3de05e997cbb78c7ea502738188b76ac6cb
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 24 18:01:02 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Feb 24 18:01:02 2023 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=e19ac3de

g_sorcery/fileutils.py: Add blake2b hash, drop sha256 and whirlpool

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 g_sorcery/fileutils.py | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 3440ec7..bb79aa9 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -182,7 +182,7 @@ class ManifestEntry(object):
     """
 
     __slots__ = ('directory', 'name', 'ftype',
-                 'size', 'sha256', 'sha512', 'whirlpool')
+                 'size', 'sha512', 'blake2b')
 
     def __init__(self, directory, name, ftype):
         self.directory = directory
@@ -194,18 +194,15 @@ class ManifestEntry(object):
         """
         Digest a file associated with a manifest entry.
         """
-        h_sha256 = hashlib.new('SHA256')
         h_sha512 = hashlib.new('SHA512')
-        h_whirlpool = hashlib.new('whirlpool')
+        h_blake2b = hashlib.new('blake2b')
         with open(os.path.join(self.directory, self.name), 'rb') as f:
             src = f.read()
-        h_sha256.update(src)
         h_sha512.update(src)
-        h_whirlpool.update(src)
+        h_blake2b.update(src)
         self.size = str(len(src))
-        self.sha256 = h_sha256.hexdigest()
         self.sha512 = h_sha512.hexdigest()
-        self.whirlpool = h_whirlpool.hexdigest()
+        self.blake2b = h_blake2b.hexdigest()
 
 
 def fast_manifest(directory):
@@ -230,8 +227,7 @@ def fast_manifest(directory):
         manifest.append(ManifestEntry(directory, "metadata.xml", "MISC"))
 
     manifest = [" ".join([m.ftype, m.name, m.size,
-                          "SHA256", m.sha256, "SHA512", m.sha512,
-                          "WHIRLPOOL", m.whirlpool])
+                          "SHA512", m.sha512, "BLAKE2B", m.blake2b])
                 for m in manifest]
 
     with open(os.path.join(directory, "Manifest"), 'w') as f:


^ permalink raw reply related	[flat|nested] 86+ messages in thread

end of thread, other threads:[~2023-02-24 18:02 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-01 12:39 [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/ Jauhien Piatlicki
  -- strict thread matches above, loose matches on Subject: below --
2023-02-24 18:02 Ulrich Müller
2015-08-18 18:59 Jauhien Piatlicki
2015-08-18 10:41 [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
2015-08-18 10:42 ` [gentoo-commits] proj/g-sorcery:master " Jauhien Piatlicki
2015-04-22  7:35 Jauhien Piatlicki
2015-04-20 21:36 [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
2015-04-22  7:35 ` [gentoo-commits] proj/g-sorcery:master " Jauhien Piatlicki
2014-11-24 14:25 [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
2014-11-24 14:25 ` [gentoo-commits] proj/g-sorcery:master " Jauhien Piatlicki
2013-09-20 15:09 Jauhien Piatlicki
2013-09-19 23:21 Jauhien Piatlicki
2013-09-18 22:09 Jauhien Piatlicki
2013-09-16 15:05 Jauhien Piatlicki
2013-09-16 14:33 Jauhien Piatlicki
2013-09-16 14:33 Jauhien Piatlicki
2013-09-15 22:38 Jauhien Piatlicki
2013-09-15 18:08 Jauhien Piatlicki
2013-09-15 17:46 Jauhien Piatlicki
2013-09-15 17:46 Jauhien Piatlicki
2013-09-05 21:29 Jauhien Piatlicki
2013-09-04 23:52 Jauhien Piatlicki
2013-09-04 18:14 Jauhien Piatlicki
2013-09-04 18:03 Jauhien Piatlicki
2013-09-04 18:03 Jauhien Piatlicki
2013-09-04 13:37 Jauhien Piatlicki
2013-09-01 22:12 Jauhien Piatlicki
2013-08-12  0:36 Jauhien Piatlicki
2013-08-02 10:18 Jauhien Piatlicki
2013-08-01 15:58 Jauhien Piatlicki
2013-08-01 15:58 Jauhien Piatlicki
2013-08-01 15:58 Jauhien Piatlicki
2013-08-01 15:58 Jauhien Piatlicki
2013-08-01 15:58 Jauhien Piatlicki
2013-08-01 15:58 Jauhien Piatlicki
2013-08-01 12:55 Jauhien Piatlicki
2013-08-01 12:39 Jauhien Piatlicki
2013-08-01 12:39 Jauhien Piatlicki
2013-08-01 12:39 Jauhien Piatlicki
2013-08-01 12:39 Jauhien Piatlicki
2013-08-01 12:39 Jauhien Piatlicki
2013-08-01 12:39 Jauhien Piatlicki
2013-08-01 12:39 Jauhien Piatlicki
2013-07-31 23:29 Jauhien Piatlicki
2013-07-23 23:13 Jauhien Piatlicki
2013-07-23 23:13 Jauhien Piatlicki
2013-07-19 14:44 Jauhien Piatlicki
2013-07-19 11:10 Jauhien Piatlicki
2013-07-18 17:26 Jauhien Piatlicki
2013-07-18 12:18 Jauhien Piatlicki
2013-07-18 12:18 Jauhien Piatlicki
2013-07-18 10:53 Jauhien Piatlicki
2013-07-17 17:05 Jauhien Piatlicki
2013-07-17  8:06 Jauhien Piatlicki
2013-07-16 23:09 Jauhien Piatlicki
2013-07-16 23:09 Jauhien Piatlicki
2013-07-15 17:20 Jauhien Piatlicki
2013-07-15 16:33 Jauhien Piatlicki
2013-07-15  0:18 Jauhien Piatlicki
2013-07-14 23:47 Jauhien Piatlicki
2013-07-13 23:35 Jauhien Piatlicki
2013-07-13 22:22 Jauhien Piatlicki
2013-07-13 15:12 Jauhien Piatlicki
2013-07-13 15:12 Jauhien Piatlicki
2013-07-04 20:24 Jauhien Piatlicki
2013-07-03 23:49 Jauhien Piatlicki
2013-07-03 23:49 Jauhien Piatlicki
2013-07-03 23:32 Jauhien Piatlicki
2013-07-03 22:54 Jauhien Piatlicki
2013-07-03 22:54 Jauhien Piatlicki
2013-07-03 22:54 Jauhien Piatlicki
2013-07-03 22:54 Jauhien Piatlicki
2013-07-03 22:54 Jauhien Piatlicki
2013-07-02 17:30 Jauhien Piatlicki
2013-07-02 12:39 Jauhien Piatlicki
2013-07-02  8:39 Jauhien Piatlicki
2013-07-01  0:07 Jauhien Piatlicki
2013-06-30 23:29 Jauhien Piatlicki
2013-06-29 14:16 Jauhien Piatlicki
2013-06-29 12:13 Jauhien Piatlicki
2013-06-29 12:13 Jauhien Piatlicki
2013-06-24 21:09 Jauhien Piatlicki
2013-06-24 21:09 Jauhien Piatlicki
2013-06-23  0:44 Jauhien Piatlicki
2013-06-23  0:44 Jauhien Piatlicki
2013-06-23  0:44 Jauhien Piatlicki
2013-06-20 23:44 Jauhien Piatlicki
2013-06-20 23:21 Jauhien Piatlicki
2013-06-20 22:53 Jauhien Piatlicki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox