Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-commits
Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-commits@g.o
From: "Slava Bacherikov" <slava@...>
Subject: proj/gentoo-packages:master commit in: gpackages/libs/package_info/, gpackages/libs/package_info/generic_metadata/
Date: Sun, 24 Jun 2012 23:21:01 +0000 (UTC)
commit:     8af7afacb90d8b7e787e986110ed7947dee53115
Author:     Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sat Jun 23 18:34:16 2012 +0000
Commit:     Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sat Jun 23 18:34:16 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=8af7afac

Changes in package_metadata, not it not requre gentoolkit

---
 .../libs/package_info/generic_metadata/herds.py    |    4 +-
 .../generic_metadata/package_metadata.py           |   70 ++++++++++++++++----
 gpackages/libs/package_info/mixins.py              |   12 ++--
 3 files changed, 65 insertions(+), 21 deletions(-)

diff --git a/gpackages/libs/package_info/generic_metadata/herds.py b/gpackages/libs/package_info/generic_metadata/herds.py
index dd698dd..25e738a 100644
--- a/gpackages/libs/package_info/generic_metadata/herds.py
+++ b/gpackages/libs/package_info/generic_metadata/herds.py
@@ -35,7 +35,7 @@ class Maintainer(AbstractXmlObject, ToStrMixin):
         - email -- maintainer email
         - role -- maintainer role
     """
-    attrs = ('name', 'email', 'role')
+    attrs = ('name', 'email', 'role', 'description')
 
     def __init__(self, *args, **kwargs):
         super(Maintainer, self).__init__(*args, **kwargs)
@@ -116,7 +116,7 @@ class Herds(ToStrMixin):
             defaultdict(list) with maintainer object as key, and list of herds
             as value.
         Example:
-            {'<Maintainers example@g.o>': ['mozilla','base'], ...}
+            {'<Maintainer example@g.o>': ['mozilla','base'], ...}
         """
         if self._maintainers_dict is not None:
             return self._maintainers_dict

diff --git a/gpackages/libs/package_info/generic_metadata/package_metadata.py b/gpackages/libs/package_info/generic_metadata/package_metadata.py
index e89d387..704a590 100644
--- a/gpackages/libs/package_info/generic_metadata/package_metadata.py
+++ b/gpackages/libs/package_info/generic_metadata/package_metadata.py
@@ -1,23 +1,65 @@
 from __future__ import absolute_import
-from gentoolkit.metadata import MetaData
 from ..generic import ToStrMixin
+#XML
+from .my_etree import etree
+# Maintainers
+from .herds import Maintainer
 
-class FakeMetaData(ToStrMixin):
+class PackageMetaData(ToStrMixin):
 
-    def herds(self):
-        return []
+    def __init__(self, metadata_path):
+        self._metadata_path = metadata_path
+        self.descr = {'en': None}
+        self._herds = ()
+        self._maintainers = ()
+        try:
+            self._metadata_xml = etree.parse(metadata_path)
+        except IOError:
+            pass
+        else:
+            self._parse_all()
 
-    def maintainers(self):
-        return []
+    def _parse_all(self):
+        self._parse_herds()
+        self._parse_description()
+        self._parse_maintainers()
+
+    def _parse_herds(self):
+        herd_set = set()
+        for herd in self._metadata_xml.iterfind('herd'):
+            herd_set.add(herd.text)
+        self._herds = tuple(herd_set)
+
+    def _parse_description(self):
+        for descr in self._metadata_xml.iterfind('longdescription'):
+            lang = descr.attrib.get('lang', 'en')
+            self.descr[lang] = descr.text
+
+    def iter_mainteiner(self):
+        for maintainer_tree in self._metadata_xml.iterfind('maintainer'):
+            yield Maintainer(maintainer_tree)
+
+    def _parse_maintainers(self):
+        maintainers = set()
+        for maintainer in self.iter_mainteiner():
+            maintainers.add(maintainer)
+        self._maintainers = tuple(maintainers)
+
+    @property
+    def description(self):
+        return self.descr['en']
 
     def descriptions(self):
-        return []
+        return self.descr.values()
+
+    def descriptions_dict(self):
+        return self.descr
+
+    def herds(self):
+        return self._herds
+
+    def maintainers(self):
+        return self._maintainers
     
     def __unicode__(self):
-        return 'fake'
-
-def PackageMetaData(path):
-    try:
-        return MetaData(path)
-    except IOError:
-        return FakeMetaData()
+        return self._metadata_path

diff --git a/gpackages/libs/package_info/mixins.py b/gpackages/libs/package_info/mixins.py
index eedd1d7..92188ed 100644
--- a/gpackages/libs/package_info/mixins.py
+++ b/gpackages/libs/package_info/mixins.py
@@ -149,13 +149,15 @@ class PackageBaseMixin(ToStrMixin):
     def descriptions(self):
         return self.metadata.descriptions()
 
-    @property
+    @cached_property
     def description(self):
         "Return first description in package metadata.xml"
-        if len(self.descriptions)>0:
-            return self.descriptions[0]
-        else:
-            return None
+        return self.metadata.description
+
+    @cached_property
+    def descriptions_dict(self):
+        return self.metadata.descriptions_dict()
+
     @property
     def cp(self):
         raise NotImplementedError


Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
proj/perl-overlay:master commit in: dev-perl/Task-Kensho-Testing/
Next by thread:
gentoo-x86 commit in app-emulation/wine: wine-1.2.ebuild wine-1.2.1.ebuild wine-1.2.3.ebuild wine-9999.ebuild wine-1.5.7.ebuild ChangeLog wine-1.2.2.ebuild wine-1.4.1.ebuild
Previous by date:
gentoo-x86 commit in profiles/targets/desktop: package.use
Next by date:
proj/gentoo-packages:master commit in: gpackages/apps/packages/


Updated Jun 26, 2012

Summary: Archive of the gentoo-commits mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.