package: update PackageFormatter doctest to use Query
authorW. Trevor King <wking@tremily.us>
Sun, 11 Nov 2012 21:37:07 +0000 (16:37 -0500)
committerW. Trevor King <wking@tremily.us>
Sun, 11 Nov 2012 21:37:07 +0000 (16:37 -0500)
helpers.find_packages has been replaced by the query.Query class.

Also temporarily turn off Portage colorization during the doctest,
otherwise the CPV value is printed in green.

pym/gentoolkit/package.py

index 682c53a0bea0bee90b473ebd6610b9258db51a09..92fb92423b3b2f547dcba19aa881b0938a79c5ab 100644 (file)
@@ -418,16 +418,21 @@ class PackageFormatter(object):
        information can then be easily formatted and displayed.
 
        Example usage:
-               >>> from gentoolkit.helpers import find_packages
+               >>> from gentoolkit.query import Query
                >>> from gentoolkit.package import PackageFormatter
-               >>> pkgs = [PackageFormatter(x) for x in find_packages('gcc')]
+               >>> import portage.output
+               >>> q = Query('gcc')
+               >>> pkgs = [PackageFormatter(x) for x in q.find()]
+               >>> havecolor = portage.output.havecolor
+               >>> portage.output.havecolor = False
                >>> for pkg in pkgs:
                ...     # Only print packages that are installed and from the Portage
                ...     # tree
                ...     if set('IP').issubset(pkg.location):
                ...             print(pkg)
                ...
-               [IP-] [  ] sys-devel/gcc-4.3.2-r3 (4.3)
+               [IP-] [  ] sys-devel/gcc-4.5.4:4.5
+               >>> portage.output.havecolor = havecolor
 
        @type pkg: L{gentoolkit.package.Package}
        @param pkg: package to format