Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 427182 - gentoolkit: better herd support (MetaData + herds.xml)
Summary: gentoolkit: better herd support (MetaData + herds.xml)
Status: RESOLVED OBSOLETE
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-19 07:45 UTC by Corentin Chary (RETIRED)
Modified: 2022-07-10 16:25 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Corentin Chary (RETIRED) gentoo-dev 2012-07-19 07:45:09 UTC
The current plan is to use portage.MetaDataXML in gentoolkit.metadata since there is a lot of code duplication. Using a lot of MetaData instance is very slow unless you use a cached herd tree, unfortunately using such a tree makes you copy a lot of code.
Currently, here is all the code you should use in portage to use a cached herdstree:

---------------------------------
import sys

if sys.hexversion < 0x2070000 or \
        (sys.hexversion < 0x3020000 and sys.hexversion >= 0x3000000):
        # Our _MetadataTreeBuilder usage is incompatible with
        # cElementTree in Python 2.6, 3.0, and 3.1:
        #  File "/usr/lib/python2.6/xml/etree/ElementTree.py", line 644, in findall
        #    assert self._root is not None
        import xml.etree.ElementTree as etree
else:
        try:
                import xml.etree.cElementTree as etree
        except (ImportError, SystemError):
                import xml.etree.ElementTree as etree

class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder):
        """
        Implements doctype() as required to avoid deprecation warnings with
        Python >=2.7.
        """
        def doctype(self, name, pubid, system):
                pass
try:
  herdspath = os.path.join(portage.settings['PORTDIR'], 'metadata/herds.xml')
  herdstree = etree.parse(herdspath, parser=etree.XMLParser(target=_MetadataTreeBuilder()))
except (ImportError, IOError, SyntaxError):
  return None


metadata = MetaDataXML('/usr/portage/dev-python/celery/metadata.xml', herdstree)
---------------------------------

What I'd like, is to be able to do something like that when using gentoolkit:

celery = Package('dev-python/celery')
celery.metadata() <- use an automatically cached herds tree, except if PORTDIR changes somehow (could also check herds.xml mtime ?)

metadata = MetaData('/usr/portage/dev-python/celery/metadata.xml') <- also automatically cached

metadata = MetaData('/usr/portage/dev-python/celery/metadata.xml', 'my/herds.xml') <- not cached


It would also be great to have gentoolkit.herd.Herd and gentoolkit.herd.list_herds(herds_path='/usr/portage/metadata/herds.xml') as an interface to read herds.xml inforations.

Reproducible: Always
Comment 1 Brian Dolbec (RETIRED) gentoo-dev 2022-07-10 16:25:51 UTC
Herds are no longer.   Plus the code has been migrated to portage's copy of gentoolkit's MetaData class.