diff options
-rw-r--r-- | g_sorcery/backend.py | 20 | ||||
-rw-r--r-- | g_sorcery/compatibility.py | 2 | ||||
-rw-r--r-- | g_sorcery/fileutils.py | 9 | ||||
-rw-r--r-- | g_sorcery/g_sorcery.py | 8 | ||||
-rw-r--r-- | g_sorcery/mangler.py | 1 | ||||
-rw-r--r-- | g_sorcery/metadata.py | 4 | ||||
-rw-r--r-- | 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: |