From: W. Trevor King Date: Sun, 11 Nov 2012 21:37:07 +0000 (-0500) Subject: package: update PackageFormatter doctest to use Query X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2c3636ac5977d17dce51003f15d5bfacbfb39a5e;p=gentoolkit.git package: update PackageFormatter doctest to use Query 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. --- diff --git a/pym/gentoolkit/package.py b/pym/gentoolkit/package.py index 682c53a..92fb924 100644 --- a/pym/gentoolkit/package.py +++ b/pym/gentoolkit/package.py @@ -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