EbuildPhase: Display upstream info before setup.
authorMichał Górny <mgorny@gentoo.org>
Wed, 29 Dec 2010 13:37:25 +0000 (14:37 +0100)
committerZac Medico <zmedico@gentoo.org>
Wed, 29 Dec 2010 17:54:11 +0000 (09:54 -0800)
Display upstream maintainers and bugtrackers along with Gentoo
maintainers when emerging a package.

pym/_emerge/EbuildPhase.py
pym/portage/xml/metadata.py

index 6197d81d6cc07db55a9d728ed739d7a68245ac01..e3270c893f1cdfc6dcb472099b064f2a9a7a0db2 100644 (file)
@@ -61,6 +61,7 @@ class EbuildPhase(CompositeTask):
                                use = self.settings['PORTAGE_USE']
 
                        maint_str = ""
+                       upstr_str = ""
                        metadata_xml_path = os.path.join(os.path.dirname(self.settings['EBUILD']), "metadata.xml")
                        if os.path.isfile(metadata_xml_path):
                                herds_path = os.path.join(self.settings['PORTDIR'],
@@ -68,6 +69,7 @@ class EbuildPhase(CompositeTask):
                                try:
                                        metadata_xml = MetaDataXML(metadata_xml_path, herds_path)
                                        maint_str = metadata_xml.format_maintainer_string()
+                                       upstr_str = metadata_xml.format_upstream_string()
                                except SyntaxError:
                                        maint_str = "<invalid metadata.xml>"
 
@@ -77,6 +79,9 @@ class EbuildPhase(CompositeTask):
                                msg.append("Repository: %s" % self.settings['PORTAGE_REPO_NAME'])
                        if maint_str:
                                msg.append("Maintainer: %s" % maint_str)
+                       if upstr_str:
+                               msg.append("Upstream:   %s" % upstr_str)
+
                        msg.append("USE:        %s" % use)
                        relevant_features = []
                        enabled_features = self.settings.features
index 2d62bba992b1a32ceab97bbea8a069b562843778..326a468b3664b73e4dcba0fd25622f02d380a4ea 100644 (file)
@@ -348,3 +348,29 @@ class MetaDataXML(object):
                        maint_str += " " + ",".join(maintainers)
 
                return maint_str
+
+       def format_upstream_string(self):
+               """Format string containing upstream maintainers and bugtrackers.
+               Used by emerge to display upstream information.
+
+               @rtype: String
+               @return: a string containing upstream maintainers and bugtrackers
+               """
+               maintainers = []
+               for upstream in self.upstream():
+                       for maintainer in upstream.maintainers:
+                               if maintainer.email is None or not maintainer.email.strip():
+                                       if maintainer.name and maintainer.name.strip():
+                                               maintainers.append(maintainer.name)
+                               else:
+                                       maintainers.append(maintainer.email)
+
+                       for bugtracker in upstream.bugtrackers:
+                               if bugtracker.startswith("mailto:"):
+                                       bugtracker = bugtracker[7:]
+                               maintainers.append(bugtracker)
+
+
+               maintainers = list(unique_everseen(maintainers))
+               maint_str = " ".join(maintainers)
+               return maint_str