__author__ = "Karl Trygve Kalleberg"
__email__ = "karltk@gentoo.org"
-__version__ = "0.1.0"
+__version__ = "0.1.1"
__productname__ = "equery"
__description__ = "Gentoo Package Query Tool"
import sys
import time
import string
-from output import *
-sys.path = ["/usr/lib/portage/pym"] + \
- ["/usr/lib/gentoolkit/pym"] + \
- sys.path
+# portage (output module) and gentoolkit need special path modifications
+sys.path.insert(0, "/usr/lib/portage/pym")
+sys.path.insert(0, "/usr/lib/gentoolkit/pym")
+from output import *
import gentoolkit
# Auxiliary functions
" " + yellow("--md5sum") + " - append md5sum\n" + \
" " + yellow("--type") + " - prepend file type"
def shortHelp(self):
- return yellow("<local-opts> ") + teal("pkgspec") + " - list files owned by " + teal("pkgspec")
+ return yellow("<local-opts> ") + turquoise("pkgspec") + " - list files owned by " + turquoise("pkgspec")
class CmdListBelongs(Command):
break
def shortHelp(self):
- return yellow("<local-opts> ") + teal("file") + " - list all packages owning " + teal("file")
+ return yellow("<local-opts> ") + turquoise("file") + " - list all packages owning " + turquoise("file")
def longHelp(self):
return "List all packages owning a particular file" + \
"\n" + \
turquoise("Note: ") + "Normally, only one package will own a file. If multiple packages own the same file, it usually consitutes a problem, and should be reported.\n" + \
"\n" + \
"Syntax:\n" + \
- " " + green("belongs") + yellow(" <local-opts> ") + teal("filename") + \
+ " " + green("belongs") + yellow(" <local-opts> ") + turquoise("filename") + \
"\n" + \
yellow("<local-opts>") + " is either of: \n" + \
" " + yellow("-c, --category cat") + " - only search in category " + yellow("cat") + "\n" + \
else:
print "[ No USE flags found for :", white(p.get_cpv()), "]"
def shortHelp(self):
- return yellow("<local-opts> ") + teal("pkgspec") + " - display USE flags for " + teal("pkgspec")
+ return yellow("<local-opts> ") + turquoise("pkgspec") + " - display USE flags for " + turquoise("pkgspec")
def longHelp(self):
return "Display USE flags for a given package\n" + \
"\n" + \
"Syntax:\n" + \
- " " + green("uses") + yellow(" <local-opts> ") + teal("pkgspec") + \
+ " " + green("uses") + yellow(" <local-opts> ") + turquoise("pkgspec") + \
"\n" + \
yellow("<local-opts>") + " is either of: \n"
return pkgtbl
def shortHelp(self):
- return yellow("<local-opts> ") + teal("pkgspec") + " - display a dependency tree for " + teal("pkgspec")
+ return yellow("<local-opts> ") + turquoise("pkgspec") + " - display a dependency tree for " + turquoise("pkgspec")
def longHelp(self):
return "Display a dependency tree for a given package\n" + \
"\n" + \
"Syntax:\n" + \
- " " + green("depgraph") + yellow(" <local-opts> ") + teal("pkgspec") + \
+ " " + green("depgraph") + yellow(" <local-opts> ") + turquoise("pkgspec") + \
"\n" + \
yellow("<local-opts>") + " is either of: \n" + \
" " + yellow("-U, --no-useflags") + " - do not show USE flags\n" + \
def shortHelp(self):
- return yellow("<local-opts> ") + teal("pkgspec") + " - print size of files contained in package " + teal("pkgspec")
+ return yellow("<local-opts> ") + turquoise("pkgspec") + " - print size of files contained in package " + turquoise("pkgspec")
def longHelp(self):
return "Print size total size of files contained in a given package" + \
"\n" + \
"Syntax:\n" + \
- " " + green("size") + yellow(" <local-opts> ") + teal("pkgspec") + \
+ " " + green("size") + yellow(" <local-opts> ") + turquoise("pkgspec") + \
"\n" + \
yellow("<local-opts>") + " is either of: \n" + \
" " + yellow("-b, --bytes") + " - report size in bytes\n"
print file + " does not exist"
def shortHelp(self):
- return teal("pkgspec") + " - check package's files against recorded MD5 sums and timestamps"
+ return turquoise("pkgspec") + " - check package's files against recorded MD5 sums and timestamps"
def longHelp(self):
return "Check package's files against recorded MD5 sums and timestamps"
print os.path.normpath(pkg.get_ebuild_path())
def shortHelp(self):
- return teal("pkgspec") + " - print full path to ebuild for package " + teal("pkgspec")
+ return turquoise("pkgspec") + " - print full path to ebuild for package " + turquoise("pkgspec")
def longHelp(self):
return "Print full path to ebuild for a given package"
if (status == 1 and opts["includeInstalled"]) or \
(status == 2 and opts["includePortTree"]) or \
- (status == 3 and opts["includeOverlay"]):
+ (status == 3 and opts["includeOverlayTree"]):
if rx.search(pkg.get_cpv()):
print pfxmodes[status] + " " + pkg.get_cpv()
def shortHelp(self):
- return yellow("<local-opts> ") + teal("pkgspec") + " - list all packages matching " + teal("pkgspec")
+ return yellow("<local-opts> ") + turquoise("pkgspec") + " - list all packages matching " + turquoise("pkgspec")
def longHelp(self):
return "List all packages matching a query pattern" + \
"\n" + \
"Syntax:\n" + \
- " " + green("list") + yellow(" <local-opts> ") + teal("pkgspec") + \
+ " " + green("list") + yellow(" <local-opts> ") + turquoise("pkgspec") + \
"\n" + \
yellow("<local-opts>") + " is either of: \n" + \
" " + yellow("-i, --installed") + " - search installed packages (default)\n" + \
command = None
local_opts = []
-
+ showhelp = 0
+
for i in xrange(len(args)):
x = args[i]
if 0:
pass
elif x in ["-h","--help"]:
- printUsage()
- sys.exit(0)
+ showhelp = 1
elif x in ["-V","--version"]:
printVersion()
sys.exit(0)
elif x in ["-C","--nocolor"]:
- Config.color = 0
+ Config["color"] = 0
elif x in ["-q","--quiet"]:
Config["verbosityLevel"] = 0
elif x in Known_commands.keys():
command = Known_commands[x]
local_opts = args[i+1:]
+ if showhelp:
+ local_opts.append("--help")
break
# Set up colour output correctly
Config["color"] == 0:
nocolor()
+ if not command and showhelp:
+ printUsage()
+ sys.exit(0)
+
return (command, local_opts)
if __name__ == "__main__":
(cmd, local_opts) = parseArgs(sys.argv[1:])
if cmd:
cmd.perform(local_opts)
-
+ else:
+ print "No command or unknown command given"
+ printUsage()
#
# --| Changes |------------------------------------------------------
#
+# * etcat-0.3.1 (08 Jan 2004) [genone]
+# - adding missing python searchpath modification
+# - fixing sort order
# * etcat-0.3.0 (12 Jul 2003) [karltk]
# - Refactored interesting stuff into the Gentoolkit module
# * etcat-0.2.0 (13 Jun 2003)
import os,sys,string,re,pprint
import getopt,glob
+
+# portage and gentoolkit need special path modifications
+sys.path.insert(0, "/usr/lib/portage/pym")
+sys.path.insert(0, "/usr/lib/gentoolkit/pym")
+
import gentoolkit
from stat import *
from output import *
__author__ = "Alastair Tse"
__email__ = "liquidx@gentoo.org"
-__version__ = "0.2.0"
+__version__ = "0.3.1"
__productname__ = "etcat"
__description__ = "Portage Information Extractor"
-# .-------------------------------------------------------.
-# | Initialise Paths |
-# `-------------------------------------------------------'
-
-sys.path = ["/usr/lib/portage/pym"] + sys.path
-
# .-------------------------------------------------------.
# | Initialise Colour Settings |
# `-------------------------------------------------------'
if not report_matches(query,matches):
return
+ # sorting result list
+ matches = gentoolkit.sort_package_list(matches)
+
# FIXME: old version printed result of regex search on name,
# so "ant" would return app-emacs/semantic, etc...
__description__ = "Gentoolkit Common Library"
import os
+import sys
+sys.path.insert(0, "/usr/lib/portage/pym")
import portage
import re
import string
def __init__(self,cpv):
self._cpv = cpv
self._scpv = portage.catpkgsplit(self._cpv)
+ if not self._scpv:
+ raise Exception("invalid cpv: %s" % cpv)
self._db = None
self._settings = None
def get_name(self):
return string.join(sp[:-1],"/")
def get_env_var(self, var):
"""Returns one of the predefined env vars DEPEND, RDEPEND, SRC_URI,...."""
- r=vartree.dbapi.aux_get(self._cpv,[var])
+ r=porttree.dbapi.aux_get(self._cpv,[var])
if not r:
raise "WTF??"
if len(r)!=1:
def compare_version(self,other):
"""Compares this package's version to another's CPV; returns -1, 0, 1"""
v1=self._scpv
- v2=portage.catpkgsplit(other)
+ v2=portage.catpkgsplit(other.get_cpv())
if v1[0] != v2[0] or v1[1] != v2[1]:
return None
return portage.pkgcmp(v1[1:],v2[1:])
def find_all_installed_packages(prefilter=None):
"""Returns a list of all installed packages, after applying the prefilter
function"""
- t=vartree.getallcpv()
+ t=vartree.cpv_all()
if prefilter:
t=filter(prefilter,t)
- return map(lambda x: Package(x), t)
+ return [Package(x) for x in t]
def find_all_uninstalled_packages(prefilter=None):
"""Returns a list of all uninstalled packages, after applying the prefilter
function"""
- t=porttree.getallcpv()
- if prefilter:
- t=filter(prefilter,t)
- return map(lambda x: Package(x), t)
+ alist = find_all_packages(prefilter)
+ return [x for x in alist if not x.is_installed()]
def find_all_packages(prefilter=None):
"""Returns a list of all known packages, installed or not, after applying
t2=[]
for x in t:
t2 += portage.portdb.cp_list(x)
- return map(lambda x: Package(x), t2)
+ return [Package(x) for x in t2]
def split_package_name(name):
"""Returns a list on the form [category, name, version, revision]. Revision will
r[0] = ''
return r
+def sort_package_list(pkglist):
+ """Returns the list ordered in the same way portage would do with lowest version
+ at the head of the list."""
+ pkglist.sort(Package.compare_version)
+ return pkglist
+
if __name__ == "__main__":
print "This module is for import only"