aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Bacherikov <slava@bacher09.org>2012-08-20 15:11:01 +0300
committerSlava Bacherikov <slava@bacher09.org>2012-08-20 15:11:01 +0300
commit0a763893501027b4733413395f557bae1d25047a (patch)
tree66a2957e266369ca1c726f605c9adc31b4039dff
parentUpdate sphinx config (diff)
downloadgentoo-packages-0a763893501027b4733413395f557bae1d25047a.tar.gz
gentoo-packages-0a763893501027b4733413395f557bae1d25047a.tar.bz2
gentoo-packages-0a763893501027b4733413395f557bae1d25047a.zip
Add docs
-rw-r--r--docs/source/generic.rst11
-rw-r--r--docs/source/index.rst3
-rw-r--r--docs/source/model_stats.rst11
-rw-r--r--docs/source/package_info.rst35
-rw-r--r--docs/source/packages.rst17
-rw-r--r--gpackages/apps/generic/views.py40
-rw-r--r--gpackages/apps/model_stats/__init__.py11
-rw-r--r--gpackages/apps/model_stats/models.py23
-rw-r--r--gpackages/libs/package_info/generic.py17
-rw-r--r--gpackages/libs/package_info/generic_metadata/__init__.py1
-rw-r--r--gpackages/libs/package_info/generic_metadata/category_metadata.py5
-rw-r--r--gpackages/libs/package_info/generic_metadata/changelog_highlight.py12
-rw-r--r--gpackages/libs/package_info/generic_metadata/herds.py6
-rw-r--r--gpackages/libs/package_info/generic_metadata/license_groups.py10
-rw-r--r--gpackages/libs/package_info/generic_metadata/my_etree.py8
-rw-r--r--gpackages/libs/package_info/generic_metadata/news.py6
-rw-r--r--gpackages/libs/package_info/generic_metadata/package_metadata.py26
-rw-r--r--gpackages/libs/package_info/generic_metadata/use_info.py31
-rw-r--r--gpackages/libs/package_info/generic_objects.py25
-rw-r--r--gpackages/libs/package_info/parse_cp.py7
20 files changed, 265 insertions, 40 deletions
diff --git a/docs/source/generic.rst b/docs/source/generic.rst
new file mode 100644
index 0000000..2d77fcd
--- /dev/null
+++ b/docs/source/generic.rst
@@ -0,0 +1,11 @@
+generic module
+==============
+
+.. automodule:: generic
+ :members:
+
+generic.views submodule
+------------------------------
+
+.. automodule:: generic.views
+ :members:
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 0211fa1..286ff70 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -29,6 +29,9 @@ Contents:
install
commands
package_info
+ generic
+ model_stats
+ packages
diff --git a/docs/source/model_stats.rst b/docs/source/model_stats.rst
new file mode 100644
index 0000000..ed755e8
--- /dev/null
+++ b/docs/source/model_stats.rst
@@ -0,0 +1,11 @@
+model_stats module
+==================
+
+.. automodule:: model_stats
+ :members:
+
+model_stats.models submodule
+----------------------------
+
+.. automodule:: model_stats.models
+ :members:
diff --git a/docs/source/package_info.rst b/docs/source/package_info.rst
index c526386..68a3b72 100644
--- a/docs/source/package_info.rst
+++ b/docs/source/package_info.rst
@@ -5,7 +5,7 @@ package_info module
:members:
package_info.abstract submodule
-------------------------------
+-------------------------------
.. automodule:: package_info.abstract
:members:
@@ -17,13 +17,13 @@ package_info.generic submodule
:members:
package_info.generic_objects submodule
-------------------------------
+--------------------------------------
.. automodule:: package_info.generic_objects
:members:
package_info.generic_metadata submodule
-------------------------------
+---------------------------------------
.. automodule:: package_info.generic_metadata
:members:
@@ -35,85 +35,84 @@ package_info.generic_metadata.category_metadata submodule
:members:
package_info.generic_metadata.changelog_highlight submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.changelog_highlight
:members:
package_info.generic_metadata.herds submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.herds
:members:
package_info.generic_metadata.license_groups submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.license_groups
:members:
package_info.generic_metadata.license_text submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.license_text
:members:
package_info.generic_metadata.my_etree submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.my_etree
:members:
package_info.generic_metadata.news submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.news
:members:
package_info.generic_metadata.package_metadata submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.package_metadata
:members:
package_info.generic_metadata.repo_const submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.repo_const
:members:
package_info.generic_metadata.repo_info submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.repo_info
:members:
package_info.generic_metadata.use_info submodule
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: package_info.generic_metadata.use_info
:members:
package_info.mixins submodule
-------------------------------
+-----------------------------
.. automodule:: package_info.mixins
:members:
package_info.parse_cp submodule
-------------------------------
+-------------------------------
.. automodule:: package_info.parse_cp
:members:
package_info.utils submodule
-------------------------------
+----------------------------
.. automodule:: package_info.utils
:members:
package_info.validators submodule
-------------------------------
+---------------------------------
.. automodule:: package_info.validators
:members:
diff --git a/docs/source/packages.rst b/docs/source/packages.rst
new file mode 100644
index 0000000..9e94728
--- /dev/null
+++ b/docs/source/packages.rst
@@ -0,0 +1,17 @@
+packages module
+==================
+
+.. automodule:: packages
+ :members:
+
+packages.models submodule
+----------------------------
+
+.. automodule:: packages.models
+ :members:
+
+packages.views submodule
+----------------------------
+
+.. automodule:: packages.views
+ :members:
diff --git a/gpackages/apps/generic/views.py b/gpackages/apps/generic/views.py
index 26b116c..faf8559 100644
--- a/gpackages/apps/generic/views.py
+++ b/gpackages/apps/generic/views.py
@@ -10,6 +10,8 @@ from django.http import Http404
class ContextView(object):
"Mixin to add additional data to context"
extra_context = {}
+ """Attribute that wold be added to context data.
+ Should contains :py:class:`.dict`"""
def get_context_data(self, **kwargs):
ret = super(ContextView, self).get_context_data(**kwargs)
ret.update(self.extra_context)
@@ -70,14 +72,34 @@ def dynamic_order(order_attr, allowed_list, reverse = None):
return order
class MultipleFilterListViewMixin(object):
+ """Mixin for dynamical objects filtering
+ """
allowed_filter = {}
+ """Dict of allowed filters, filter name is key, filter field is value
+ """
allowed_order = {}
+ """Dict of allowed orders, order name is key, order field is value
+ """
boolean_filters = ()
+ """Set or tuple of boolean filters, indicates that filtering by that
+ attribute should done as boolean.
+ """
# allowed_many = {'name': int_count}
allowed_many = {}
+ """Dict where key is filter name, value is integer.
+ Indicates that this filter could search by many values using ``__in`` query.
+ Value is used as limit of max allowed filtering values, if it is 0 then
+ unlimited.
+ """
m2m_filter = set()
+ """Indicates that this attribute is m2m fields and filtering by it should done
+ with ``distinct`` attribute.
+ """
def get_context_data(self, **kwargs):
+ """In addition to default context value will return all filters as
+ :py:class:`.dict`.
+ """
cd = super(MultipleFilterListViewMixin, self).get_context_data(**kwargs)
cd['filters_dict'] = self.queries_dict
return cd
@@ -88,6 +110,8 @@ class MultipleFilterListViewMixin(object):
return qs
def get_filters(self):
+ """Return filters dict
+ """
qs = self.get_base_filters()
newqs = {}
for k, v in qs.iteritems():
@@ -102,6 +126,9 @@ class MultipleFilterListViewMixin(object):
return newqs
def is_reverse(self):
+ """Return boolean value that which indicates that objects should sorted
+ in reverse order
+ """
if self.kwargs.get('rev') is None:
reverse = bool(self.request.GET.get('rev', False))
else:
@@ -110,6 +137,10 @@ class MultipleFilterListViewMixin(object):
return reverse
def get_order(self):
+ """Will return order value for using in
+ :py:meth:`order_by <django:django.db.models.query.QuerySet.order_by>`
+ method or raise :py:class:`Http404 <django:django.http.Http404>` exception.
+ """
reverse = self.is_reverse()
if 'order' in self.request.GET:
@@ -123,6 +154,9 @@ class MultipleFilterListViewMixin(object):
return order
def get_queryset(self):
+ """Will return
+ :py:class:`QuerySet <django:django.db.models.query.QuerySet>` of
+ filtered objects."""
query = super(MultipleFilterListViewMixin, self).get_queryset()
qs = self.get_filters()
order = self.get_order()
@@ -139,6 +173,7 @@ class MultipleFilterListViewMixin(object):
@classmethod
def get_url_part(cls):
+ "Return url sufix for transfering filter params in url."
t = "(?:{0}/(?P<{0}>[^/]+)/)?"
t_bool = "(?:{0}/(?P<{0}>yes|no)/)?"
l =[]
@@ -152,6 +187,9 @@ class MultipleFilterListViewMixin(object):
return ''.join(l) + "(?:order/(?P<order>[a-z]*)/)?(?P<rev>rev/)?"
class FeedWithUpdated(Feed):
+ """Extend Feed class that have ``item_update`` method for object updated
+ date
+ """
def item_extra_kwargs(self, item):
# for future
kwargs = super(FeedWithUpdated, self).item_extra_kwargs(item)
@@ -165,6 +203,8 @@ class FeedWithUpdated(Feed):
# see bug https://code.djangoproject.com/ticket/14656
class RightAtom1Feed(Atom1Feed):
+ """Extended Atom Feed wich have updated attribute
+ """
def add_item_elements(self, handler, item):
if item['pubdate'] is not None:
handler.addQuickElement(u"published",
diff --git a/gpackages/apps/model_stats/__init__.py b/gpackages/apps/model_stats/__init__.py
index e69de29..4b63a7b 100644
--- a/gpackages/apps/model_stats/__init__.py
+++ b/gpackages/apps/model_stats/__init__.py
@@ -0,0 +1,11 @@
+"""This is generic application for precalculation stats.
+
+This application add ``update_stats`` command in addition to django commands.
+This command are used for updating stats in all available models.
+So if you run::
+
+ $ ./manage.py update_stats
+
+This will update stats in all models inherited from :class:`.StatsModel`
+
+"""
diff --git a/gpackages/apps/model_stats/models.py b/gpackages/apps/model_stats/models.py
index 7883f3b..e1e329e 100644
--- a/gpackages/apps/model_stats/models.py
+++ b/gpackages/apps/model_stats/models.py
@@ -36,6 +36,7 @@ def update_stats(model, params):
model.objects.filter(pk = item['pk']).update(**kwargs)
class StatsMixin(object):
+ "Basic mixin for calc stats"
#iterable of 2-tuples
stats_params = ()
@@ -47,6 +48,7 @@ class StatsMixin(object):
update_stats(cls, cls.stats_params)
def get_stats_models(module):
+ "Search stats models in module"
return inspect.getmembers(module, get_predicate)
def update_stats_for_models(models_list):
@@ -86,8 +88,27 @@ class StatsModelBase(ModelBase):
PositiveIntegerField(default = 0, editable = False))
class StatsModel(StatsMixin, models.Model):
- "Base model for models with stats"
+ """Base model for models with stats, should be used instead of
+ default django model class.
+
+ This class will automaticaly add model fields for stats, but you could
+ override this by defining own definition in model class.
+ """
__metaclass__ = StatsModelBase
+ stats_params = ()
+ """This param used for automaticaly add model fields for stats and for
+ stats calculation
+
+ It should contains iterable of 2-tuples
+
+ First value in tuple should be new field name, second Count agreggation value.
+
+ Example:
+ stats_params = [('books_count', 'booksmodel')]
+
+ For more examples see tests.
+ """
+
class Meta:
abstract = True
diff --git a/gpackages/libs/package_info/generic.py b/gpackages/libs/package_info/generic.py
index 86732ed..74f19b5 100644
--- a/gpackages/libs/package_info/generic.py
+++ b/gpackages/libs/package_info/generic.py
@@ -1,3 +1,5 @@
+"""Some generic things used in this module"""
+
import os.path
import hashlib
import types
@@ -31,6 +33,7 @@ def iter_over_gen(iterat, name):
for obj in iterat:
for item in getattr(obj, name)():
yield item
+
def del_from_dict(what_list, dict_todel):
for item in what_list:
if item in dict_todel:
@@ -60,6 +63,7 @@ def toint(val, defval = None):
return defval
class StrThatIgnoreCase(unicode):
+ "Case insensetive string, that remembers case"
__slots__ = ('_forcmp',)
def __init__(self, value):
@@ -90,6 +94,11 @@ class ToStrMixin(object):
def file_get_content(file_path):
+ """Args:
+ file_path -- full path to file
+
+ Returns: return file content or `None`
+ """
if os.path.exists(file_path):
with open(file_path, 'r') as f:
content = f.read()
@@ -98,6 +107,10 @@ def file_get_content(file_path):
return None
def file_sha1(file_path):
+ """Args:
+ file_path -- full path to file
+ Returns: return file sha1 hexdigest or `None`
+ """
sha1 = None
if os.path.exists(file_path):
with open(file_path, 'r') as f:
@@ -105,6 +118,10 @@ def file_sha1(file_path):
return sha1
def file_mtime(file_path):
+ """Args:
+ file_path -- full path to file
+ Returns: return file modification time as python datetime or `None`
+ """
if os.path.exists(file_path):
return datetime.fromtimestamp(os.path.getmtime(file_path))
else:
diff --git a/gpackages/libs/package_info/generic_metadata/__init__.py b/gpackages/libs/package_info/generic_metadata/__init__.py
index e69de29..cc00e8b 100644
--- a/gpackages/libs/package_info/generic_metadata/__init__.py
+++ b/gpackages/libs/package_info/generic_metadata/__init__.py
@@ -0,0 +1 @@
+""" Submodule for accessing some metadata"""
diff --git a/gpackages/libs/package_info/generic_metadata/category_metadata.py b/gpackages/libs/package_info/generic_metadata/category_metadata.py
index b498422..702459c 100644
--- a/gpackages/libs/package_info/generic_metadata/category_metadata.py
+++ b/gpackages/libs/package_info/generic_metadata/category_metadata.py
@@ -6,8 +6,11 @@ from .my_etree import etree
__all__ = ('CategoryMetadata', )
class CategoryMetadata(ToStrMixin):
+ "Represent category metadata.xml as object"
def __init__(self, metadata_path):
+ """Args:
+ metadata_path - full path to category metadata.xml file"""
self._metadata_path = metadata_path
self._descrs = {}
try:
@@ -24,10 +27,12 @@ class CategoryMetadata(ToStrMixin):
@property
def descrs(self):
+ "Dict with language code as key and text as value"
return self._descrs
@property
def default_descr(self):
+ "Return text of English description"
return self._descrs.get('en')
def __unicode__(self):
diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
index 9ee13f1..02e8306 100644
--- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
+++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
@@ -210,13 +210,17 @@ def changelog_style_css():
return f.get_style_defs()
def group_tokens(text):
- """Combine tokens to groups
+ """Combine tokens to groups.
+
Args:
text -- changelog text
+
Yields:
(group_type, group), where group_type are: `None`, `'version'` or \
`'message'`
- group are array of tuples (toke, value)"""
+ group are array of tuples (toke, value)
+
+ """
c = ChangelogLexer()
queue = deque()
group_type = None
@@ -244,6 +248,9 @@ def group_tokens(text):
yield (group_type, group + list(queue))
def latest_message_group(text):
+ """Args:
+ text - changelog text
+ Returns: return latest message group"""
for group_type, group in group_tokens(text):
if group_type == 'message':
return group
@@ -264,6 +271,7 @@ def tokensgroup_to_toknes(groups):
return tk
def tokens_to_text(lex):
+ "Convert tokenized input to text"
mystr = ''
for token, value in lex:
mystr += value
diff --git a/gpackages/libs/package_info/generic_metadata/herds.py b/gpackages/libs/package_info/generic_metadata/herds.py
index 1fe30cb..1dff4da 100644
--- a/gpackages/libs/package_info/generic_metadata/herds.py
+++ b/gpackages/libs/package_info/generic_metadata/herds.py
@@ -101,10 +101,12 @@ class Herds(ToStrMixin):
def get_maintainers_with_herds(self):
"""Returns:
- defaultdict(list) with maintainer object as key, and list of herds
- as value.
+ :py:class:`defaultdict(list) <collections.defaultdict>` with
+ maintainer object as key, and list of herds as value.
+
Example:
{'<Maintainer example@gentoo.org>': ['mozilla','base'], ...}
+
"""
if self._maintainers_dict is not None:
return self._maintainers_dict
diff --git a/gpackages/libs/package_info/generic_metadata/license_groups.py b/gpackages/libs/package_info/generic_metadata/license_groups.py
index ba4255d..835fcc3 100644
--- a/gpackages/libs/package_info/generic_metadata/license_groups.py
+++ b/gpackages/libs/package_info/generic_metadata/license_groups.py
@@ -41,13 +41,16 @@ def parse_groups(groups_str):
def load_groups(file_path = DEFAULT_FILE_PATH):
"""Load file profiles/license_groups and represend it as dict
+
Args:
- file_path -- full path to license_groups file, by default it
- /usr/portage/profiles/license_groups
+ file_path -- full path to license_groups file.
+
Returns:
- dict with license group as key and set of licenses as value
+ dict with license group as key and set of licenses as value.
+
Example:
{u'EULA': set([u'cadsoft', ...]), u'GPL-COMPATIBLE': set([...]), ...}
+
"""
fc = file_get_content(file_path)
@@ -102,6 +105,7 @@ class LicenseGroups(ToStrMixin):
return self.reverse_group_dict[license_name]
def sha1(self):
+ "Return sha1 hash hexdigest of license groups file"
return file_sha1(self.groups_path)
def __unicode__(self):
diff --git a/gpackages/libs/package_info/generic_metadata/my_etree.py b/gpackages/libs/package_info/generic_metadata/my_etree.py
index f7498e4..8ec6b14 100644
--- a/gpackages/libs/package_info/generic_metadata/my_etree.py
+++ b/gpackages/libs/package_info/generic_metadata/my_etree.py
@@ -1,3 +1,11 @@
+
+"""
+Module with universal etree module
+
+"""
+
+__all__ = ('etree', )
+
try:
from lxml import etree
except ImportError:
diff --git a/gpackages/libs/package_info/generic_metadata/news.py b/gpackages/libs/package_info/generic_metadata/news.py
index 6f63da6..68c8b7c 100644
--- a/gpackages/libs/package_info/generic_metadata/news.py
+++ b/gpackages/libs/package_info/generic_metadata/news.py
@@ -12,8 +12,12 @@ NEWS_STR_RE = r'^(?P<date>\d{4,4}-\d{2}-\d{2})-(?P<title>.*)$'
news_re = re.compile(NEWS_STR_RE)
class News(ToStrMixin):
+ "Represent all news in special repositority"
def __init__(self, repo_path = '/usr/portage'):
+ """Args:
+ repo_path -- full path to repository
+ """
self.news_path = os.path.join(repo_path, 'metadata', 'news')
if not os.path.isdir(self.news_path):
raise ValueError
@@ -21,6 +25,7 @@ class News(ToStrMixin):
self.repo_path = repo_path
def iter_news(self):
+ "Yields `NewsItem` object"
for name in os.listdir(self.news_path):
try:
i = NewsItem(self.news_path, name)
@@ -36,6 +41,7 @@ class News(ToStrMixin):
return unicode(self.repo_path)
class NewsItem(ToStrMixin):
+ "Represent news item"
N_ITEM_P = r'^%(name)s\.(?P<lang>[a-z]{2})\.txt$'
diff --git a/gpackages/libs/package_info/generic_metadata/package_metadata.py b/gpackages/libs/package_info/generic_metadata/package_metadata.py
index 3c5a9e5..2431410 100644
--- a/gpackages/libs/package_info/generic_metadata/package_metadata.py
+++ b/gpackages/libs/package_info/generic_metadata/package_metadata.py
@@ -16,8 +16,12 @@ REMOTE_IDS_TYPE = Enum(REMOTE_ID_TYPE)
#TODO: Add support of restrict attribute !!!
class PackageMetaData(ToStrMixin):
+ "Represend package metadata.xml as object"
def __init__(self, metadata_path):
+ """Args:
+ metadata_path -- full path to metadata.xml
+ """
self._metadata_path = metadata_path
self.descr = {'en': None}
self._herds = ()
@@ -48,6 +52,7 @@ class PackageMetaData(ToStrMixin):
self.descr[lang] = descr.text
def iter_mainteiner(self):
+ "Yields `Maintainer` object"
for maintainer_tree in self._metadata_xml.iterfind('maintainer'):
yield Maintainer(maintainer_tree)
@@ -64,31 +69,47 @@ class PackageMetaData(ToStrMixin):
@property
def description(self):
+ "Return description text in English"
return self.descr['en']
def descriptions(self):
return self.descr.values()
def descriptions_dict(self):
+ "Return dict where language code is key and description text is value"
return self.descr
def herds(self):
+ "Return tuple of package herds"
return self._herds
def maintainers(self):
+ "Return tuple of `Maintainers` objects"
return self._maintainers
def __unicode__(self):
return self._metadata_path
class Upstream(ToStrMixin):
+ """Represent upstream node on metadata.xml
+ """
simple_attrs = (('changelog', 'changelog'),
('bugs-to', 'bugs_to'),)
def __init__(self, upstream_t, metadata_path):
self.metadata_path = metadata_path
+ "Full path to metadata.xml"
self.remote_id = {}
+ "Dict with remote ids"
+ self.changelog = None
+ "Link to upstream changelog"
+ self.bugs_to = None
+ "Where send bugs"
+ self.doc = {}
+ """Dict of doc links.
+ Language code is key, doc link is value.
+ """
for name in ('doc',):
res = {}
for item in upstream_t.iterfind(name):
@@ -113,19 +134,24 @@ class Upstream(ToStrMixin):
maintainers.append(m)
self.maintainers = maintainers
+ "List of :class:`.UpstreamMaintainer` objects"
@property
def main_doc(self):
+ "English doc link"
return self.doc.get('en')
def __unicode__(self):
return self.metadata_path
class UpstreamMaintainer(Maintainer):
+ "Represent maintainer node in upstream node"
status_dict = {'inactive' : 0, 'active': 1}
+ "Dict of status mapping"
def __init__(self, xml_object):
super(UpstreamMaintainer, self).__init__(xml_object)
st = xml_object.attrib.get('status','inactive')
self.status = self.status_dict.get(st, 0)
+ "Maintainer status"
diff --git a/gpackages/libs/package_info/generic_metadata/use_info.py b/gpackages/libs/package_info/generic_metadata/use_info.py
index 04a1835..9177c82 100644
--- a/gpackages/libs/package_info/generic_metadata/use_info.py
+++ b/gpackages/libs/package_info/generic_metadata/use_info.py
@@ -28,14 +28,19 @@ def _get_info(filename, re_string, modify_function, res_var = None):
return res_dict
def get_uses_info(filename = '/usr/portage/profiles/use.desc'):
- """Args:
+ """
+ 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`
+
+ .. note::
+ In portage public api exists ``get_use_flag_dict`` method.
+
"""
def action(res_dict, match):
res_dict[match['use'].lower()] = match['description']
@@ -43,15 +48,20 @@ def get_uses_info(filename = '/usr/portage/profiles/use.desc'):
return _get_info(filename, use_re, action)
def get_local_uses_info(filename = '/usr/portage/profiles/use.local.desc'):
- """Args:
+ """
+ Args:
filename -- full path to use.local.desc file
+
Returns:
- defaultdict(dict) with use flag as first key, package name as second
- key, and description as value
+ :class:`defaultdict(dict) <collections.defaultdict>` with use flag as \
+ first key, package name as second key, and description as value.
+
Example:
{'api': {'app-emulation/xen-tools': 'Use descr', ...} , ...}
- Notice:
+
+ .. note::
In portage public api `get_use_flag_dict`
+
"""
def action(res_dict, match):
res_dict[match['use'].lower()][match['package']] = match['description']
@@ -65,11 +75,14 @@ def _set_prefixes(prefix, dct):
return newdct
def get_use_special_info(dirname = '/usr/portage/profiles/desc'):
- """Args:
+ """
+ Args:
dirname -- full path to descrs files, /usr/portage/profiles/desc \
- by default
+ by default
+
Returns:
dict with use flag as key, and description as value
+
Example:
{'kernel_linux': 'KERNEL setting for system using the Linux ...', ...}
"""
diff --git a/gpackages/libs/package_info/generic_objects.py b/gpackages/libs/package_info/generic_objects.py
index 8c8e2aa..8793724 100644
--- a/gpackages/libs/package_info/generic_objects.py
+++ b/gpackages/libs/package_info/generic_objects.py
@@ -39,12 +39,17 @@ class Keyword(ToStrMixin, AbstractKeywords):
def __init__(self, name, status = 0):
"""Args:
- name -- name of keyword, it may start with ~ or -, if so than
+
+ name -- name of keyword, it may start with ~ or -, if so than \
status will be auto seting.
- status -- status of keyword: 0 - stable,
- 1 - utested '~',
- 2 - unstable '-'
- Also may get by name parameter.
+
+ status -- status of keyword:
+
+ * 0 -- stable,
+ * 1 -- utested '~'
+ * 2 -- unstable '-'
+
+ Also ``status`` may automaticaly set by name parameter.
"""
if name.startswith('~'):
name = name[1:]
@@ -53,7 +58,16 @@ class Keyword(ToStrMixin, AbstractKeywords):
name = name[1:]
status = 2
self.name = name
+ "Arch name of keyword"
+
self.status = status
+ """Status of keyword
+
+ * 0 -- stable
+ * 1 -- untested
+ * 2 -- unstable
+
+ """
def __unicode__(self):
return self.status_repr[self.status] + self.name
@@ -86,6 +100,7 @@ class Keyword(ToStrMixin, AbstractKeywords):
return self.name
class KeywordsSet(set):
+ "Set of :class:`Keywords <.Keyword>` objects"
def __init__(self, init_list):
start = defaultdict(list)
for item in init_list:
diff --git a/gpackages/libs/package_info/parse_cp.py b/gpackages/libs/package_info/parse_cp.py
index 445d463..94002bd 100644
--- a/gpackages/libs/package_info/parse_cp.py
+++ b/gpackages/libs/package_info/parse_cp.py
@@ -95,10 +95,14 @@ class EbuildRevMixin(object):
@total_ordering
class VersionParse(ToStrMixin):
+ """Parse ebuild version
+ Could be used for sorting by ebuild version or for validation
+ """
__slots__ = ('version', 'maj', 'min', 'cmp_attr')
def __init__(self, version):
+ "Args: version -- string version"
self.version = version
m = version_parse_re.match(version)
if m is None:
@@ -106,7 +110,9 @@ class VersionParse(ToStrMixin):
dct = m.groupdict()
self.maj = maj_parse(dct['num'], dct['alpha'])
+ "represent major version part as tuple"
self.min = min_parse(dct['prefixes'])
+ "represent minor version part (prefixes) as tuple"
self.cmp_attr = (self.maj, self.min)
def __eq__(self, other):
@@ -157,6 +163,7 @@ class PackageParse(ToStrMixin):
@property
def re_str(self):
+ "String of parsing Regexp"
return PACKAGE_RE_P
@property