diff options
Diffstat (limited to 'g_sorcery/package_db.py')
-rw-r--r-- | g_sorcery/package_db.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py index ec2d45f..5374ae5 100644 --- a/g_sorcery/package_db.py +++ b/g_sorcery/package_db.py @@ -105,6 +105,7 @@ class PackageDB(object): self.pkg_name, self.pkg_data = next(self.pkgs_iter) self.vers_iter = iter(self.pkg_data.items()) + ebuild_data = dict(ebuild_data) ebuild_data.update(self.cat_data['common_data']) return (Package(self.cat_name, self.pkg_name, ver), ebuild_data) @@ -129,6 +130,7 @@ class PackageDB(object): self.pkg_name, self.pkg_data = next(self.pkgs_iter) self.vers_iter = iter(self.pkg_data.items()) + ebuild_data = dict(ebuild_data) ebuild_data.update(self.cat_data['common_data']) return (Package(self.cat_name, self.pkg_name, ver), ebuild_data) @@ -275,6 +277,42 @@ class PackageDB(object): self.categories[category] = description + def set_common_data(self, category, common_data): + """ + Set common data for a category. + + Args: + category: Category name. + common_data: Category common data. + """ + if not category in self.categories: + raise InvalidKeyError('Non-existent category: ' + category) + + if not category in self.database: + self.database[category] = {'common_data': common_data, 'packages': {}} + else: + self.database[category]['common_data'] = common_data + + + def get_common_data(self, category): + """ + Get common data for a category. + + Args: + category: Category name. + + Returns: + Dictionary with category common data. + """ + if not category in self.categories: + raise InvalidKeyError('Non-existent category: ' + category) + + if not category in self.database: + return {} + else: + return self.database[category]['common_data'] + + def add_package(self, package, ebuild_data=None): """ Add a package. |