From b7b6e4dc0d0d1c6fa613d4e13098984be277b5a2 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@cd1c1023-2f26-0410-ae45-c471fc1f0318> Date: Sat, 15 Mar 2008 05:25:47 +0000 Subject: [PATCH] Equo: - added 'equo match' tool, it is more or less the same of 'equo search' except it uses EquoInterface.atomMatch() git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1478 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- TODO | 2 +- client/equo | 32 ++++++++++++++++++++++++++- client/text_query.py | 51 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index e878b6b90..88ba01dc6 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ TODO list: + - create a meta-packages list ... I hate Joost - during "equo remove" show disk size for each package - - add "equo match" tool - NEEDED + ldconfig -p ? - make an ETP_DIR switching function - lilo.conf trigger? diff --git a/client/equo b/client/equo index f7b6b2f4f..503e94eee 100644 --- a/client/equo +++ b/client/equo @@ -39,7 +39,11 @@ def print_help(): print_info(" \t"+blue("repoinfo")+brown("\t show enabled repositories")) print_info(" \t"+blue("status")+brown("\t\t show respositories status")) - print_info(" \t"+blue("search")+brown("\t\t search a package trough repositories")) + print_info(" \t"+blue("search")+brown("\t\t search a package in repositories")) + print_info(" \t"+blue("match")+brown("\t\t match a package in repositories")) + print_info(" \t\t"+red("--multimatch")+"\t\t return all the possible matches") + print_info(" \t\t"+red("--multirepo")+"\t\t return matches from every repository") + print_info(" \t\t"+red("--showrepo")+"\t\t print repository information") print_info(" \t"+blue("world")+brown("\t\t update system with the latest available packages")) print_info(" \t\t"+red("--ask")+"\t\t\t ask before making any changes") @@ -309,6 +313,32 @@ try: else: rc = -10 + elif (options[0] == "match"): + rc = -10 + multiMatch = False + multiRepo = False + showRepo = False + myoptions = [] + for opt in options: + if opt == "--multimatch": + multiMatch = True + elif opt == "--multirepo": + multiRepo = True + elif opt == "--showrepo": + showRepo = True + else: + myoptions.append(opt) + if len(myoptions) > 1: + import text_query + # repoMatch can be made using @repository + rc = text_query.matchPackage(myoptions[1:], + multiMatch = multiMatch, + multiRepo = multiRepo, + showRepo = showRepo + ) + else: + rc = -10 + elif (options[0] == "database"): entropyTools.applicationLockCheck("database") import text_rescue diff --git a/client/text_query.py b/client/text_query.py index 00f18426e..6929b0aa4 100644 --- a/client/text_query.py +++ b/client/text_query.py @@ -693,6 +693,50 @@ def searchPackage(packages, idreturn = False): return dataInfo return 0 +def matchPackage(packages, idreturn = False, multiMatch = False, multiRepo = False, showRepo = False): + + global Equo + if Equo == None: + Equo = EquoInterface() + + dataInfo = set() # when idreturn is True + + if (not idreturn) and (not etpUi['quiet']): + print_info(darkred(" @@ ")+darkgreen("Matching..."), back = True) + found = False + + for package in packages: + + if (not idreturn) and (not etpUi['quiet']): + print_info(blue(" # ")+bold(package)) + + match = Equo.atomMatch(package, multiMatch = multiMatch, multiRepo = multiRepo) + if match[1] != 1: + if not multiMatch: + if multiRepo: + matches = match[0] + else: + matches = [match] + else: + matches = match[0] + for match in matches: + if (idreturn): + dataInfo.add(tuple(match)) + else: + dbconn = Equo.openRepositoryDatabase(match[1]) + printPackageInfo(match[0],dbconn, showRepoOnQuiet = showRepo) + found = True + if (not idreturn) and (not etpUi['quiet']): + print_info(blue(" Keyword: ")+bold("\t"+package)) + print_info(blue(" Found: ")+bold("\t"+str(len(matches)))+red(" entries")) + + if (not idreturn) and (not etpUi['quiet']) and (not found): + print_info(darkred(" @@ ")+darkgreen("No match.")) + + if (idreturn): + return dataInfo + return 0 + def searchSlottedPackages(slots, datareturn = False, dbconn = None): global Equo @@ -874,7 +918,7 @@ def __searchDescriptions(descriptions, dbconn, idreturn = False, EquoConnection print_info(blue(" Found: ")+bold("\t"+str(len(mydescdata[desc])))+red(" entries")) return dataInfo,mydescdata -def printPackageInfo(idpackage, dbconn, clientSearch = False, strictOutput = False, extended = False, EquoConnection = None): +def printPackageInfo(idpackage, dbconn, clientSearch = False, strictOutput = False, extended = False, EquoConnection = None, showRepoOnQuiet = False): if EquoConnection != None: Equo = EquoConnection @@ -888,7 +932,10 @@ def printPackageInfo(idpackage, dbconn, clientSearch = False, strictOutput = Fal # now fetch essential info pkgatom = dbconn.retrieveAtom(idpackage) if (etpUi['quiet']): - print pkgatom + if showRepoOnQuiet: + print "[%s] %s" % (dbconn.dbname, pkgatom) + else: + print pkgatom return if (not strictOutput):