Herds have been removed 2 years ago. It's time to clean up the remaining
bits of their support from Portage code.
---
 pym/_emerge/EbuildPhase.py                   |   4 +-
 pym/portage/xml/metadata.py                  |  94 +------------------
 repoman/pym/repoman/checks/herds/__init__.py |   0
 repoman/pym/repoman/checks/herds/herdbase.py | 135 ---------------------------
 repoman/pym/repoman/checks/herds/metadata.py |  26 ------
 5 files changed, 5 insertions(+), 254 deletions(-)
 delete mode 100644 repoman/pym/repoman/checks/herds/__init__.py
 delete mode 100644 repoman/pym/repoman/checks/herds/herdbase.py
 delete mode 100644 repoman/pym/repoman/checks/herds/metadata.py

diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py
index d3fada622..13bedf51b 100644
--- a/pym/_emerge/EbuildPhase.py
+++ b/pym/_emerge/EbuildPhase.py
@@ -83,10 +83,8 @@ class EbuildPhase(CompositeTask):
                        upstr_str = ""
                        metadata_xml_path = 
os.path.join(os.path.dirname(self.settings['EBUILD']), "metadata.xml")
                        if MetaDataXML is not None and 
os.path.isfile(metadata_xml_path):
-                               herds_path = 
os.path.join(self.settings['PORTDIR'],
-                                       'metadata/herds.xml')
                                try:
-                                       metadata_xml = 
MetaDataXML(metadata_xml_path, herds_path)
+                                       metadata_xml = 
MetaDataXML(metadata_xml_path)
                                        maint_str = 
metadata_xml.format_maintainer_string()
                                        upstr_str = 
metadata_xml.format_upstream_string()
                                except SyntaxError:
diff --git a/pym/portage/xml/metadata.py b/pym/portage/xml/metadata.py
index 9e48dddde..99e0474c1 100644
--- a/pym/portage/xml/metadata.py
+++ b/pym/portage/xml/metadata.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2017 Gentoo Foundation
+# Copyright 2010-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 """Provides an easy-to-use python interface to Gentoo's metadata.xml file.
@@ -8,8 +8,6 @@
                >>> pkg_md = 
MetaDataXML('/usr/portage/app-misc/gourmet/metadata.xml')
                >>> pkg_md
                <MetaDataXML '/usr/portage/app-misc/gourmet/metadata.xml'>
-               >>> pkg_md.herds()
-               ['no-herd']
                >>> for maint in pkg_md.maintainers():
                ...     print "{0} ({1})".format(maint.email, maint.name)
                ...
@@ -198,13 +196,11 @@ class _Upstream(object):
 class MetaDataXML(object):
        """Access metadata.xml"""
 
-       def __init__(self, metadata_xml_path, herds):
+       def __init__(self, metadata_xml_path):
                """Parse a valid metadata.xml file.
 
                @type metadata_xml_path: str
                @param metadata_xml_path: path to a valid metadata.xml file
-               @type herds: str or ElementTree
-               @param herds: path to a herds.xml, or a pre-parsed ElementTree
                @raise IOError: if C{metadata_xml_path} can not be read
                """
 
@@ -220,85 +216,15 @@ class MetaDataXML(object):
                except ExpatError as e:
                        raise SyntaxError("%s" % (e,))
 
-               if isinstance(herds, etree.ElementTree):
-                       herds_etree = herds
-                       herds_path = None
-               else:
-                       herds_etree = None
-                       herds_path = herds
-
                # Used for caching
-               self._herdstree = herds_etree
-               self._herds_path = herds_path
                self._descriptions = None
                self._maintainers = None
-               self._herds = None
                self._useflags = None
                self._upstream = None
 
        def __repr__(self):
                return "<%s %r>" % (self.__class__.__name__, 
self.metadata_xml_path)
 
-       def _get_herd_email(self, herd):
-               """Get a herd's email address.
-
-               @type herd: str
-               @param herd: herd whose email you want
-               @rtype: str or None
-               @return: email address or None if herd is not in herds.xml
-               @raise IOError: if $PORTDIR/metadata/herds.xml can not be read
-               """
-
-               if self._herdstree is None:
-                       try:
-                               self._herdstree = 
etree.parse(_unicode_encode(self._herds_path,
-                                       encoding=_encodings['fs'], 
errors='strict'),
-                                       
parser=etree.XMLParser(target=_MetadataTreeBuilder()))
-                       except (ImportError, IOError, SyntaxError):
-                               return None
-
-               # Some special herds are not listed in herds.xml
-               if herd in ('no-herd', 'maintainer-wanted', 
'maintainer-needed'):
-                       return None
-
-               try:
-                       # Python 2.7 or >=3.2
-                       iterate = self._herdstree.iter
-               except AttributeError:
-                       iterate = self._herdstree.getiterator
-
-               for node in iterate('herd'):
-                       if node.findtext('name') == herd:
-                               return node.findtext('email')
-
-       def herds(self, include_email=False):
-               """Return a list of text nodes for <herd>.
-
-               @type include_email: bool
-               @keyword include_email: if True, also look up the herd's email
-               @rtype: tuple
-               @return: if include_email is False, return a list of strings;
-                        if include_email is True, return a list of tuples 
containing:
-                                        [('herd1', 'he...@gentoo.org'), 
('no-herd', None);
-               """
-               if self._herds is None:
-                       if self._xml_tree is None:
-                               self._herds = tuple()
-                       else:
-                               herds = []
-                               for elem in self._xml_tree.findall('herd'):
-                                       text = elem.text
-                                       if text is None:
-                                               text = ''
-                                       if include_email:
-                                               herd_mail = 
self._get_herd_email(text)
-                                               herds.append((text, herd_mail))
-                                       else:
-                                               herds.append(text)
-                               self._herds = tuple(herds)
-
-               return self._herds
-
        def descriptions(self):
                """Return a list of text nodes for <longdescription>.
 
@@ -369,12 +295,11 @@ class MetaDataXML(object):
                return self._upstream
 
        def format_maintainer_string(self):
-               """Format string containing maintainers and herds (emails if 
possible).
+               """Format string containing maintainers.
                Used by emerge to display maintainer information.
-               Entries are sorted according to the rules stated on the bug 
wranglers page.
 
                @rtype: String
-               @return: a string containing maintainers and herds
+               @return: a string containing maintainers
                """
                maintainers = []
                for maintainer in self.maintainers():
@@ -384,17 +309,6 @@ class MetaDataXML(object):
                        else:
                                maintainers.append(maintainer.email)
 
-               for herd, email in self.herds(include_email=True):
-                       if herd == "no-herd":
-                               continue
-                       if email is None or not email.strip():
-                               if herd and herd.strip():
-                                       maintainers.append(herd)
-                       else:
-                               maintainers.append(email)
-
-               maintainers = list(unique_everseen(maintainers))
-
                maint_str = ""
                if maintainers:
                        maint_str = maintainers[0]
diff --git a/repoman/pym/repoman/checks/herds/__init__.py 
b/repoman/pym/repoman/checks/herds/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/repoman/pym/repoman/checks/herds/herdbase.py 
b/repoman/pym/repoman/checks/herds/herdbase.py
deleted file mode 100644
index ebe6a19b4..000000000
--- a/repoman/pym/repoman/checks/herds/herdbase.py
+++ /dev/null
@@ -1,135 +0,0 @@
-# -*- coding: utf-8 -*-
-# repoman: Herd database analysis
-# Copyright 2010-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2 or later
-
-from __future__ import print_function, unicode_literals
-
-import errno
-import xml.etree.ElementTree
-try:
-       from xml.parsers.expat import ExpatError
-except (SystemExit, KeyboardInterrupt):
-       raise
-except (ImportError, SystemError, RuntimeError, Exception):
-       # broken or missing xml support
-       # https://bugs.python.org/issue14988
-       # This means that python is built without xml support.
-       # We tolerate global scope import failures for optional
-       # modules, so that ImportModulesTestCase can succeed (or
-       # possibly alert us about unexpected import failures).
-       pass
-
-from portage import _encodings, _unicode_encode
-from portage.exception import FileNotFound, ParseError, PermissionDenied
-from portage import os
-
-from repoman.errors import err
-
-__all__ = [
-       "make_herd_base", "get_herd_base"
-]
-
-
-def _make_email(nick_name):
-       if not nick_name.endswith('@gentoo.org'):
-               nick_name = nick_name + '@gentoo.org'
-       return nick_name
-
-
-class HerdBase(object):
-       def __init__(self, herd_to_emails, all_emails):
-               self.herd_to_emails = herd_to_emails
-               self.all_emails = all_emails
-
-       def known_herd(self, herd_name):
-               return herd_name in self.herd_to_emails
-
-       def known_maintainer(self, nick_name):
-               return _make_email(nick_name) in self.all_emails
-
-       def maintainer_in_herd(self, nick_name, herd_name):
-               return _make_email(nick_name) in self.herd_to_emails[herd_name]
-
-
-class _HerdsTreeBuilder(xml.etree.ElementTree.TreeBuilder):
-       """
-       Implements doctype() as required to avoid deprecation warnings with
-       >=python-2.7.
-       """
-       def doctype(self, name, pubid, system):
-               pass
-
-
-def make_herd_base(filename):
-       herd_to_emails = dict()
-       all_emails = set()
-
-       try:
-               xml_tree = xml.etree.ElementTree.parse(
-                       _unicode_encode(
-                               filename, encoding=_encodings['fs'], 
errors='strict'),
-                       parser=xml.etree.ElementTree.XMLParser(
-                               target=_HerdsTreeBuilder()))
-       except ExpatError as e:
-               raise ParseError("metadata.xml: %s" % (e,))
-       except EnvironmentError as e:
-               func_call = "open('%s')" % filename
-               if e.errno == errno.EACCES:
-                       raise PermissionDenied(func_call)
-               elif e.errno == errno.ENOENT:
-                       raise FileNotFound(filename)
-               raise
-
-       herds = xml_tree.findall('herd')
-       for h in herds:
-               _herd_name = h.find('name')
-               if _herd_name is None:
-                       continue
-               herd_name = _herd_name.text.strip()
-               del _herd_name
-
-               maintainers = h.findall('maintainer')
-               herd_emails = set()
-               for m in maintainers:
-                       _m_email = m.find('email')
-                       if _m_email is None:
-                               continue
-                       m_email = _m_email.text.strip()
-
-                       herd_emails.add(m_email)
-                       all_emails.add(m_email)
-
-               herd_to_emails[herd_name] = herd_emails
-
-       return HerdBase(herd_to_emails, all_emails)
-
-
-def get_herd_base(repoman_settings):
-       try:
-               herd_base = make_herd_base(
-                       os.path.join(repoman_settings["PORTDIR"], 
"metadata/herds.xml"))
-       except (EnvironmentError, ParseError, PermissionDenied) as e:
-               err(str(e))
-       except FileNotFound:
-               # TODO: Download as we do for metadata.dtd, but add a way to
-               # disable for non-gentoo repoman users who may not have herds.
-               herd_base = None
-       return herd_base
-
-
-if __name__ == '__main__':
-       h = make_herd_base('/usr/portage/metadata/herds.xml')
-
-       assert(h.known_herd('sound'))
-       assert(not h.known_herd('media-sound'))
-
-       assert(h.known_maintainer('sping'))
-       assert(h.known_maintainer('sp...@gentoo.org'))
-       assert(not h.known_maintainer('portage'))
-
-       assert(h.maintainer_in_herd('zmed...@gentoo.org', 'tools-portage'))
-       assert(not h.maintainer_in_herd('p...@gentoo.org', 'tools-portage'))
-
-       import pprint
-       pprint.pprint(h.herd_to_emails)
diff --git a/repoman/pym/repoman/checks/herds/metadata.py 
b/repoman/pym/repoman/checks/herds/metadata.py
deleted file mode 100644
index b4a433ed7..000000000
--- a/repoman/pym/repoman/checks/herds/metadata.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# -*- coding:utf-8 -*-
-
-
-class UnknownHerdsError(ValueError):
-       def __init__(self, herd_names):
-               _plural = len(herd_names) != 1
-               super(UnknownHerdsError, self).__init__(
-                       'Unknown %s %s' % (
-                               _plural and 'herds' or 'herd',
-                               ','.join('"%s"' % e for e in herd_names)))
-
-
-def check_metadata_herds(xml_tree, herd_base):
-       herd_nodes = xml_tree.findall('herd')
-       unknown_herds = [
-               name for name in (
-                       e.text.strip() for e in herd_nodes if e.text is not 
None)
-               if not herd_base.known_herd(name)]
-
-       if unknown_herds:
-               raise UnknownHerdsError(unknown_herds)
-
-
-def check_metadata(xml_tree, herd_base):
-       if herd_base is not None:
-               check_metadata_herds(xml_tree, herd_base)
-- 
2.16.1


Reply via email to