aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-09-20 16:09:22 +0200
committerJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-09-20 16:09:22 +0200
commitc4e668b5cf76d31bb1a63bc361b7711b570431e5 (patch)
tree48c2722b1856713b13fc9fe629406d551a5c0d83
parentdocs: fixes (diff)
downloadg-sorcery-c4e668b5cf76d31bb1a63bc361b7711b570431e5.tar.gz
g-sorcery-c4e668b5cf76d31bb1a63bc361b7711b570431e5.tar.bz2
g-sorcery-c4e668b5cf76d31bb1a63bc361b7711b570431e5.zip
gs_db_tool and gs_pypi: add docstrings
-rw-r--r--gs_db_tool/gs_db_tool.py21
-rw-r--r--gs_pypi/backend.py3
-rw-r--r--gs_pypi/ebuild.py6
-rw-r--r--gs_pypi/pypi_db.py16
4 files changed, 45 insertions, 1 deletions
diff --git a/gs_db_tool/gs_db_tool.py b/gs_db_tool/gs_db_tool.py
index 1b58cee..5d456a3 100644
--- a/gs_db_tool/gs_db_tool.py
+++ b/gs_db_tool/gs_db_tool.py
@@ -54,6 +54,9 @@ def main():
def transform_db(function):
+ """
+ Decorator for functions that change database.
+ """
def transformator(pkg_db, args):
pkg_db.read()
function(pkg_db, args)
@@ -62,6 +65,9 @@ def transform_db(function):
def read_db(function):
+ """
+ Decorator for functions that read from database.
+ """
def reader(pkg_db, args):
pkg_db.read()
function(pkg_db, args)
@@ -70,12 +76,18 @@ def read_db(function):
@read_db
def for_all(pkg_db, args):
+ """
+ Execute a given python code for all DB entries.
+ """
for package, ebuild_data in pkg_db:
exec(args.function)
@transform_db
def add_var(pkg_db, args):
+ """
+ Add new variable to every entry.
+ """
if args.function:
for package, ebuild_data in pkg_db:
exec(args.function)
@@ -98,6 +110,9 @@ def add_var(pkg_db, args):
@read_db
def show_all(pkg_db, args):
+ """
+ Display all DB entries.
+ """
for package, ebuild_data in pkg_db:
print(package)
print('-' * len(str(package)))
@@ -107,11 +122,17 @@ def show_all(pkg_db, args):
def sync(pkg_db, args):
+ """
+ Synchronize database.
+ """
pkg_db.sync(args.uri)
@transform_db
def rename_var(pkg_db, args):
+ """
+ Rename variable in all entries.
+ """
for package, ebuild_data in pkg_db:
if args.old_name in ebuild_data:
value = ebuild_data.pop(args.old_name)
diff --git a/gs_pypi/backend.py b/gs_pypi/backend.py
index a8e2297..b9e9988 100644
--- a/gs_pypi/backend.py
+++ b/gs_pypi/backend.py
@@ -23,6 +23,9 @@ from .ebuild import PypiEbuildWithoutDigestGenerator, PypiEbuildWithDigestGenera
class PypiEclassGenerator(EclassGenerator):
+ """
+ Implementation of eclass generator. Only specifies a data directory.
+ """
def __init__(self):
super(PypiEclassGenerator, self).__init__(os.path.join(get_pkgpath(__file__), 'data'))
diff --git a/gs_pypi/ebuild.py b/gs_pypi/ebuild.py
index b25c1a4..7fdf145 100644
--- a/gs_pypi/ebuild.py
+++ b/gs_pypi/ebuild.py
@@ -21,6 +21,9 @@ Layout = collections.namedtuple("Layout",
class PypiEbuildWithoutDigestGenerator(DefaultEbuildGenerator):
+ """
+ Implementation of ebuild generator without sources digesting.
+ """
def __init__(self, package_db):
vars_before_inherit = \
@@ -41,6 +44,9 @@ class PypiEbuildWithoutDigestGenerator(DefaultEbuildGenerator):
super(PypiEbuildWithoutDigestGenerator, self).__init__(package_db, layout)
class PypiEbuildWithDigestGenerator(DefaultEbuildGenerator):
+ """
+ Implementation of ebuild generator with sources digesting.
+ """
def __init__(self, package_db):
vars_before_inherit = \
diff --git a/gs_pypi/pypi_db.py b/gs_pypi/pypi_db.py
index 120a153..847cbf3 100644
--- a/gs_pypi/pypi_db.py
+++ b/gs_pypi/pypi_db.py
@@ -22,12 +22,20 @@ from g_sorcery.g_collections import Package, serializable_elist
from g_sorcery.package_db import DBGenerator
class PypiDBGenerator(DBGenerator):
-
+ """
+ Implementation of database generator for PYPI backend.
+ """
def get_download_uries(self, common_config, config):
+ """
+ Get URI of packages index.
+ """
self.repo_uri = config["repo_uri"]
return [{"uri": self.repo_uri + "pypi?%3Aaction=index", "output": "packages"}]
def parse_data(self, data_f):
+ """
+ Download and parse packages index. Then download and parse pages for all packages.
+ """
soup = bs4.BeautifulSoup(data_f.read())
packages = soup.table
data = {}
@@ -69,6 +77,9 @@ class PypiDBGenerator(DBGenerator):
return data
def parse_package_page(self, data_f):
+ """
+ Parse package page.
+ """
soup = bs4.BeautifulSoup(data_f.read())
data = {}
data["files"] = []
@@ -150,6 +161,9 @@ class PypiDBGenerator(DBGenerator):
return data
def process_data(self, pkg_db, data, common_config, config):
+ """
+ Process parsed package data.
+ """
category = "dev-python"
pkg_db.add_category(category)