public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Jauhien Piatlicki" <piatlicki@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/g-sorcery:master commit in: gs_pypi/, gs_db_tool/
Date: Fri, 20 Sep 2013 14:11:56 +0000 (UTC)	[thread overview]
Message-ID: <1379686162.c4e668b5cf76d31bb1a63bc361b7711b570431e5.jauhien@gentoo> (raw)

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

gs_db_tool and gs_pypi: add docstrings

---
 gs_db_tool/gs_db_tool.py | 21 +++++++++++++++++++++
 gs_pypi/backend.py       |  3 +++
 gs_pypi/ebuild.py        |  6 ++++++
 gs_pypi/pypi_db.py       | 16 +++++++++++++++-
 4 files changed, 45 insertions(+), 1 deletion(-)

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)
 


                 reply	other threads:[~2013-09-20 14:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

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

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

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

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

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

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

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