diff options
| author | Matt Turner <mattst88@gentoo.org> | 2022-03-16 11:33:57 -0700 |
|---|---|---|
| committer | Matt Turner <mattst88@gentoo.org> | 2022-03-16 12:02:13 -0700 |
| commit | ac589ba6708f62d41ac6684c5602a45e2c625766 (patch) | |
| tree | 888f4e48b2b12276599980bbed6ebfd556ad78c6 /pym | |
| parent | fa1b6d8bab551576d0d493176c8dbac2cf81db48 (diff) | |
| download | gentoolkit-ac589ba6708f62d41ac6684c5602a45e2c625766.tar.gz | |
Remove remnants of herds support
Signed-off-by: Matt Turner <mattst88@gentoo.org>
Diffstat (limited to 'pym')
| -rw-r--r-- | pym/gentoolkit/equery/meta.py | 35 | ||||
| -rwxr-xr-x | pym/gentoolkit/imlate/imlate.py | 45 | ||||
| -rw-r--r-- | pym/gentoolkit/metadata.py | 105 |
3 files changed, 26 insertions, 159 deletions
diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py index 7747893..4cf4bc6 100644 --- a/pym/gentoolkit/equery/meta.py +++ b/pym/gentoolkit/equery/meta.py @@ -30,7 +30,6 @@ from gentoolkit.query import Query QUERY_OPTS = { "current": False, "description": False, - "herd": False, "keywords": False, "license": False, "maintainer": False, @@ -79,7 +78,6 @@ def print_help(with_description=True, with_usage=True): ( (" -h, --help", "display this help message"), (" -d, --description", "show an extended package description"), - (" -H, --herd", "show the herd(s) for the package"), (" -k, --keywords", "show keywords for all matching package versions"), (" -l, --license", "show licenses for the best maching version"), (" -m, --maintainer", "show the maintainer(s) for the package"), @@ -159,21 +157,6 @@ def filter_keywords(matches): return result -def format_herds(herds): - """Format herd information for display.""" - - result = [] - for herd in herds: - herdstr = "" - email = "(%s)" % herd[1] if herd[1] else "" - herdstr = herd[0] - if CONFIG["verbose"]: - herdstr += " %s" % (email,) - result.append(herdstr) - - return result - - def format_maintainers(maints): """Format maintainer information for display.""" @@ -305,21 +288,6 @@ def call_format_functions(best_match, matches): # Specific information requested, less formatting got_opts = True - if QUERY_OPTS["herd"] or not got_opts: - herds = best_match.metadata.herds(include_email=True) - if any(not h[0] for h in herds): - print( - pp.warn("The packages metadata.xml has an empty <herd> tag"), - file=sys.stderr, - ) - herds = [x for x in herds if x[0]] - herds = format_herds(herds) - if QUERY_OPTS["herd"]: - print_sequence(format_list(herds)) - else: - for herd in herds: - pp.uprint(format_line(herd, "Herd: ", " " * 13)) - if QUERY_OPTS["maintainer"] or not got_opts: maints = format_maintainers(best_match.metadata.maintainers()) if QUERY_OPTS["maintainer"]: @@ -503,8 +471,6 @@ def parse_module_options(module_opts): sys.exit(0) elif opt in ("-d", "--description"): QUERY_OPTS["description"] = True - elif opt in ("-H", "--herd"): - QUERY_OPTS["herd"] = True elif opt in ("-l", "--license"): QUERY_OPTS["license"] = True elif opt in ("-m", "--maintainer"): @@ -528,7 +494,6 @@ def main(input_args): long_opts = ( "help", "description", - "herd", "keywords", "license", "maintainer", diff --git a/pym/gentoolkit/imlate/imlate.py b/pym/gentoolkit/imlate/imlate.py index b553849..d8c9fe0 100755 --- a/pym/gentoolkit/imlate/imlate.py +++ b/pym/gentoolkit/imlate/imlate.py @@ -161,12 +161,6 @@ def _get_metadata(metadata, element, tag): for _element in elements: node = _element.getElementsByTagName(tag) - if tag == "herd" and (not node or not node[0].childNodes): - # print >> stderr, "'%s' is missing a <herd> tag or it is empty," % metadata - # print >> stderr, "please file a bug at https://bugs.gentoo.org and refer to http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml?part=2&chap=4" - values.append("no-herd") - continue - try: values.append(node[0].childNodes[0].data) except IndexError: @@ -202,30 +196,6 @@ def is_maintainer(maintainer, metadata): return False -def is_herd(herd, metadata): - data = [] - - if herd == None: - return True - - hrd = herd.split(",") - data = _get_metadata(metadata, "pkgmetadata", "herd") - - if not data and len(herd) == 0: - return True - elif not data and len(herd) > 0: - return False - else: - for hd in data: - for hd2 in hrd: - if hd == hd2: - return True - if hd.startswith(hd2): - return True - - return False - - # fetch a list of arch (just stable) packages # -* is important to be sure that just arch is used def get_packages(conf): @@ -249,9 +219,6 @@ def get_packages(conf): conf["MAINTAINER"], join(conf["PORTDIR"], cp, "metadata.xml") ): continue - if conf["HERD"] != None: - if not is_herd(conf["HERD"], join(conf["PORTDIR"], cp, "metadata.xml")): - continue cpvrs = conf["portdb"].dbapi.match(cp) @@ -511,17 +478,6 @@ def main(): ) parser.add_option( - "-H", - "--herd", - dest="herd", - action="store", - type="string", - help="Show only packages from the specified herd", - metavar="HERD", - default=None, - ) - - parser.add_option( "-C", "--category", "--categories", @@ -576,7 +532,6 @@ def main(): conf["CATEGORIES"] = options.categories conf["MAINTAINER"] = options.maintainer - conf["HERD"] = options.herd # append to our existing conf = get_settings(conf) diff --git a/pym/gentoolkit/metadata.py b/pym/gentoolkit/metadata.py index 2678611..479456a 100644 --- a/pym/gentoolkit/metadata.py +++ b/pym/gentoolkit/metadata.py @@ -4,31 +4,32 @@ """Provides an easy-to-use python interface to Gentoo's metadata.xml file. - Example usage: - >>> from gentoolkit.metadata import MetaData - >>> pkg_md = MetaData('/usr/portage/app-misc/gourmet/metadata.xml') - >>> pkg_md - <MetaData '/usr/portage/app-misc/gourmet/metadata.xml'> - >>> pkg_md.herds() - [] - >>> for maint in pkg_md.maintainers(): - ... print('{0} ({1})'.format(maint.email, maint.name)) - ... - nixphoeni@gentoo.org (Joe Sapp) - >>> for flag in pkg_md.use(): - ... print(flag.name, '->', flag.description) - ... - rtf -> Enable export to RTF - gnome-print -> Enable pretty Python printing with gnome-print - >>> upstream = pkg_md.upstream() - >>> upstream # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE - [<_Upstream {'node': <Element 'upstream' at 0x...>, - 'remoteids': [], 'docs': [], - 'maintainers': - [<_Maintainer 'Thomas_Hinkle@alumni.brown.edu'>], - 'changelogs': [], 'bugtrackers': []}>] - >>> upstream[0].maintainers[0].name - 'Thomas Mills Hinkle' + Example usage: + >>> pkg_md = MetaData('/var/db/repos/gentoo/app-accessibility/espeak-ng/metadata.xml') + >>> pkg_md + <MetaData '/var/db/repos/gentoo/app-accessibility/espeak-ng/metadata.xml'> + >>> for maint in pkg_md.maintainers(): + ... print('{0} ({1})'.format(maint.email, maint.name)) + ... + williamh@gentoo.org (William Hubbs) + >>> for flag in pkg_md.use(): + ... print(flag.name, '->', flag.description) + ... + async -> Enables asynchronous commands + klatt -> Enables Klatt formant synthesis and implementation + l10n_ru -> Builds extended Russian Dictionary file + l10n_zh -> Builds extended Chinese (Mandarin and Cantonese) Dictionary files + man -> Builds and installs manpage with app-text/ronn + mbrola -> Adds support for mbrola voices + >>> upstream = pkg_md.upstream() + >>> upstream + [<_Upstream {'node': <Element 'upstream' at 0x7f952a73b2c0>, + 'maintainers': [<_Maintainer 'msclrhd@gmail.com'>], + 'changelogs': ['https://github.com/espeak-ng/espeak-ng/releases.atom'], + 'docs': [], 'bugtrackers': [], + 'remoteids': [('espeak-ng/espeak-ng', 'github')]}>] + >>> upstream[0].maintainers[0].name + 'Reece H. Dunn' """ __all__ = ("MetaData",) @@ -38,12 +39,9 @@ __docformat__ = "epytext" # Imports # ======= -import os import re import xml.etree.cElementTree as etree -from portage import settings - # ======= # Classes # ======= @@ -183,7 +181,6 @@ class MetaData: self._xml_tree = etree.parse(metadata_path) # Used for caching - self._herdstree = None self._descriptions = None self._maintainers = None self._useflags = None @@ -192,56 +189,6 @@ class MetaData: def __repr__(self): return "<%s %r>" % (self.__class__.__name__, self.metadata_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: - herds_path = os.path.join(settings["PORTDIR"], "metadata/herds.xml") - try: - self._herdstree = etree.parse(herds_path) - except IOError: - # For some trees, herds.xml may not exist. Bug #300108. - return None - - # Some special herds are not listed in herds.xml - if herd in ("no-herd", "maintainer-wanted", "maintainer-needed"): - return None - - for node in self._herdstree.iter("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: list - @return: if include_email is False, return a list of strings; - if include_email is True, return a list of tuples containing: - [('herd1', 'herd1@gentoo.org'), ('no-herd', None); - """ - - result = [] - 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) - result.append((text, herd_mail)) - else: - result.append(text) - - return result - def descriptions(self): """Return a list of text nodes for <longdescription>. |
