Dependency is a subclass of Query, so we need to initialize it with a
CPV string, not a Package instance. The old doctest was raising:
File ".../pym/gentoolkit/dependencies.py", line 202, in
gentoolkit.dependencies.Dependencies.graph_reverse_depends
Failed example:
deptree = ffmpeg.graph_reverse_depends(
only_direct=False, # Include indirect revdeps
pkgset=installed) # from installed pkgset
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.2/doctest.py", line 1288, in __run
compileflags, 1), test.globs)
File "<doctest gentoolkit.dependencies.Dependencies.graph_reverse_depends[5]>", line 3, in <module>
pkgset=installed) # from installed pkgset
File ".../pym/gentoolkit/dependencies.py", line 237, in graph_reverse_depends
pkgset = tuple(Dependencies(x) for x in pkgset)
File ".../pym/gentoolkit/dependencies.py", line 237, in <genexpr>
pkgset = tuple(Dependencies(x) for x in pkgset)
File ".../pym/gentoolkit/dependencies.py", line 45, in __init__
Query.__init__(self, query)
File "/home/wking/src/gentoolkit/pym/gentoolkit/query.py", line 51, in __init__
if not set(query).intersection(needed_chars):
TypeError: 'Package' object is not iterable
Also use ffmpeg-9999 (for better future-proofing) and update the
length of the resulting deptree.
Example usage:
>>> from gentoolkit.dependencies import Dependencies
- >>> ffmpeg = Dependencies('media-video/ffmpeg-0.5_p20373')
+ >>> ffmpeg = Dependencies('media-video/ffmpeg-9999')
>>> # I only care about installed packages that depend on me:
... from gentoolkit.helpers import get_installed_cpvs
>>> # I want to pass in a sorted list. We can pass strings or
... # Package or Atom types, so I'll use Package to sort:
... from gentoolkit.package import Package
- >>> installed = sorted(Package(x) for x in get_installed_cpvs())
+ >>> installed = sorted(get_installed_cpvs())
>>> deptree = ffmpeg.graph_reverse_depends(
... only_direct=False, # Include indirect revdeps
... pkgset=installed) # from installed pkgset
>>> len(deptree)
- 44
+ 24
@type pkgset: iterable
@keyword pkgset: sorted pkg cpv strings or anything sublassing