From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Sbfby-00080q-KY for garchives@archives.gentoo.org; Mon, 04 Jun 2012 22:18:54 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B74ECE0995; Mon, 4 Jun 2012 22:18:47 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 79E0DE0995 for ; Mon, 4 Jun 2012 22:18:47 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8D9691B4031 for ; Mon, 4 Jun 2012 22:18:46 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 56A33E5430 for ; Mon, 4 Jun 2012 22:18:45 +0000 (UTC) From: "Slava Bacherikov" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Slava Bacherikov" Message-ID: <1338848308.4a9e85eab23a8d0c4e64d0658637a7d85db7b0ae.bacher09@gentoo> Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/ X-VCS-Repository: proj/gentoo-packages X-VCS-Files: gpackages/libs/generic.py gpackages/libs/herds.py gpackages/libs/porttree.py gpackages/libs/use_info.py X-VCS-Directories: gpackages/libs/ X-VCS-Committer: bacher09 X-VCS-Committer-Name: Slava Bacherikov X-VCS-Revision: 4a9e85eab23a8d0c4e64d0658637a7d85db7b0ae X-VCS-Branch: master Date: Mon, 4 Jun 2012 22:18:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: abac538c-2f1d-40a2-94a1-5d51b985a7c9 X-Archives-Hash: 5198e21287bc23f1f4ce25f085a1ab48 commit: 4a9e85eab23a8d0c4e64d0658637a7d85db7b0ae Author: Slava Bacherikov bacher09 org> AuthorDate: Mon Jun 4 22:18:28 2012 +0000 Commit: Slava Bacherikov bacherikov org ua> CommitDate: Mon Jun 4 22:18:28 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoo-packag= es.git;a=3Dcommit;h=3D4a9e85ea Add some docstrings. --- gpackages/libs/generic.py | 3 +++ gpackages/libs/herds.py | 28 +++++++++++++++++++++++++++- gpackages/libs/porttree.py | 14 +++++++++++++- gpackages/libs/use_info.py | 19 +++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/gpackages/libs/generic.py b/gpackages/libs/generic.py index 7fe9cc8..dc15a65 100644 --- a/gpackages/libs/generic.py +++ b/gpackages/libs/generic.py @@ -1,5 +1,8 @@ =20 class ToStrMixin(object): + """Abstract class for inheritence, allow add simple `__str__` and `_= _repr__` + methods + """ def __str__(self): return unicode(self).encode('utf-8') =20 diff --git a/gpackages/libs/herds.py b/gpackages/libs/herds.py index 70ce071..7626d03 100644 --- a/gpackages/libs/herds.py +++ b/gpackages/libs/herds.py @@ -10,6 +10,10 @@ def _gen_func(name): return lambda self: getattr(self, name) =20 class AbstractXmlObject(object): + """Abstract class for iheritance,=20 + dynamicly generate properties by `attrs` param + each generated param return value of `_` + property name variable. + """ attrs =3D () =20 def __new__(cls, *args, **kwargs): @@ -20,6 +24,7 @@ class AbstractXmlObject(object): return ins =20 def __init__(self, xml_object): + "Set internal value for each value in attrs parameter" for val in self.attrs: obj_xml =3D xml_object.find(val)=20 setattr(self, '_' + val, None) @@ -27,6 +32,12 @@ class AbstractXmlObject(object): setattr(self, '_' + val, obj_xml.text) =20 class Maintainer(AbstractXmlObject, ToStrMixin): + """Have 3 atributes: + + - name -- maintainer name + - email -- maintainer email + - role -- maintainer role + """ attrs =3D ('name', 'email', 'role') =20 def __init__(self, *args, **kwargs): @@ -47,6 +58,11 @@ class Maintainer(AbstractXmlObject, ToStrMixin): return self.email =20 class Herd(AbstractXmlObject, ToStrMixin): + """Have 3 atributes: + - name -- herd name + - email -- herd email + - description -- herd description + """ # create name, email and description property attrs =3D ('name', 'email', 'description') =20 @@ -72,7 +88,8 @@ class Herd(AbstractXmlObject, ToStrMixin): =20 =20 class Herds(ToStrMixin): - def __init__(self, herd_path=3D'/usr/portage/metadata/herds.xml'): + "Object that represent herds.xml file " + def __init__(self, herd_path =3D '/usr/portage/metadata/herds.xml'): self._herd_path =3D herd_path self._herd_parse =3D etree.parse(herd_path) self._herds_dict =3D None @@ -83,6 +100,9 @@ class Herds(ToStrMixin): yield Herd(herd_tree) =20 def get_herds_indict(self): + """Returns: + dict with herd name as key and herd object as value + """ if self._herds_dict is not None: return self._herds_dict res =3D {} @@ -92,6 +112,12 @@ class Herds(ToStrMixin): return res =20 def get_maintainers_with_herds(self): + """Returns: + defaultdict(list) with maintainer object as key, and list of= herds + as value. + Example: + {'': ['mozilla','base'], ...= } + """ if self._maintainers_dict is not None: return self._maintainers_dict herd_dict =3D self.get_herds_indict() diff --git a/gpackages/libs/porttree.py b/gpackages/libs/porttree.py index 9b5bb9b..0bf329b 100644 --- a/gpackages/libs/porttree.py +++ b/gpackages/libs/porttree.py @@ -49,9 +49,13 @@ def file_mtime(file_path): return None =20 class Use(ToStrMixin): + "Represend Use flag as object" __slots__ =3D ('name',) =20 def __init__(self, name): + """Args: + name -- name of use flag, may start with + or - + """ if name.startswith('+') or name.startswith('-'): name =3D name[1:] self.name =3D name @@ -69,12 +73,19 @@ class Use(ToStrMixin): return hash(self.name) =20 =20 - class Keyword(ToStrMixin): __slots__ =3D ('name', 'status') status_repr =3D ['','~','-'] =20 def __init__(self, name, status =3D 0): + """Args: + name -- name of keyword, it may start with ~ or -, if so tha= n=20 + status will be auto seting. + status -- status of keyword: 0 - stable,=20 + 1 - utested '~', + 2 - unstable '-' + Also may get by name parameter. + """ if name.startswith('~'): name =3D name[1:] status =3D 1 @@ -89,6 +100,7 @@ class Keyword(ToStrMixin): =20 @property def arch(self): + "Return arch name" return self.name =20 =20 diff --git a/gpackages/libs/use_info.py b/gpackages/libs/use_info.py index faa95ef..b45cda7 100644 --- a/gpackages/libs/use_info.py +++ b/gpackages/libs/use_info.py @@ -20,12 +20,31 @@ def _get_info(filename, re_string, modify_function, r= es_var =3D {}): return res_dict =20 def get_uses_info(filename =3D '/usr/portage/profiles/use.desc'): + """Args: + filename -- full path to use.desc file + Returns: + dict with use flag as key, and description as value + Example: + {'doc': 'Doc description', ...} + Notice: + In portage public api `get_use_flag_dict` + """ def action(res_dict, match): res_dict[match['use']] =3D match['description'] =20 return _get_info(filename, use_re, action) =20 def get_local_uses_info(filename =3D '/usr/portage/profiles/use.local.de= sc'): + """Args: + filename -- full path to use.local.desc file + Returns: + defaultdict(dict) with use flag as first key, package name as se= cond + key, and description as value + Example: + {'api': {'app-emulation/xen-tools': 'Use descr', ...} , ...} + Notice: + In portage public api `get_use_flag_dict` + """ def action(res_dict, match): res_dict[match['use']][match['package']] =3D match['description'= ] =20