diff --git a/client/equo.py b/client/equo.py index dd2090554..cf1233f60 100644 --- a/client/equo.py +++ b/client/equo.py @@ -192,6 +192,8 @@ help_opts = [ (2, 'list', 2, _('list packages based on the chosen parameter below')), (3, 'installed', 2, _('list installed packages')), (3, 'available [repos]', 1, _('list available packages')), + (2, 'mimetype', 2, _('search packages able to handle given mimetypes')), + (3, '--installed', 2, _('search among installed packages')), (2, 'needed', 2, _('show runtime libraries needed by the provided atoms')), (2, 'orphans', 1, _('search files that do not belong to any package')), (2, 'removal', 1, _('show the removal tree for the specified atoms')), diff --git a/client/text_query.py b/client/text_query.py index 785de93a1..cd2a718b6 100644 --- a/client/text_query.py +++ b/client/text_query.py @@ -56,7 +56,7 @@ def query(options): multi_match = True elif (opt == "--multirepo") and (first_opt == "match"): multi_repo = True - elif (opt == "--installed") and (first_opt == "match"): + elif (opt == "--installed") and (first_opt in ("match", "mimetype",)): match_installed = True elif (opt == "--showrepo") and (first_opt == "match"): show_repo = True @@ -108,6 +108,9 @@ def query(options): elif myopts[0] == "needed": rc_status = search_needed_libraries(myopts[1:]) + elif myopts[0] == "mimetype": + rc_status = search_mimetype(myopts[1:], installed = match_installed) + elif myopts[0] == "required": rc_status = search_required_libraries(myopts[1:]) @@ -1211,6 +1214,47 @@ def search_package(packages, Equo = None, get_results = False, return rc_results return 0 +def search_mimetype(mimetypes, Equo = None, installed = False): + + if Equo is None: + Equo = EquoInterface() + + if not etpUi['quiet']: + print_info(darkred(" @@ ") + darkgreen("%s..." % (_("Searching mimetype"),) ), + back = True) + found = False + + for mimetype in mimetypes: + + if not etpUi['quiet']: + print_info("%s: %s" % (blue(" # "), bold(mimetype),)) + + if installed: + matches = [(x, etpConst['clientdbid']) for x in \ + Equo.search_installed_mimetype(mimetype)] + else: + matches = Equo.search_available_mimetype(mimetype) + + if matches: + found = True + + for match in matches: + dbconn = Equo.open_repository(match[1]) + print_package_info(match[0], dbconn, Equo = Equo, + extended = etpUi['verbose']) + + if not etpUi['quiet']: + toc = [] + toc.append(("%s:" % (blue(_("Keyword")),), purple(mimetype))) + toc.append(("%s:" % (blue(_("Found")),), "%s %s" % ( + len(matches), brown(_("entries")),))) + print_table(toc) + + if not etpUi['quiet'] and not found: + print_info(darkred(" @@ ") + darkgreen("%s." % (_("No matches"),) )) + + return 0 + def match_package(packages, multiMatch = False, multiRepo = False, showRepo = False, showDesc = False, Equo = None, get_results = False, installed = False): diff --git a/docs/man/equo.pod b/docs/man/equo.pod index 326551a30..287b61916 100644 --- a/docs/man/equo.pod +++ b/docs/man/equo.pod @@ -570,6 +570,18 @@ list installed packages =back +=item B + +search packages able to handle given mimetypes + +=over + +=item B<--installed> + +search inside installed packages + +=back + =item B show runtime libraries needed by the provided atoms diff --git a/docs/man/man1/equo.1 b/docs/man/man1/equo.1 index 62c474297..e80a4deaf 100644 --- a/docs/man/man1/equo.1 +++ b/docs/man/man1/equo.1 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "EQUO 1" -.TH EQUO 1 "2010-04-16" "perl v5.10.1" "Entropy" +.TH EQUO 1 "2010-05-02" "perl v5.10.1" "Entropy" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -575,6 +575,16 @@ list installed packages .RE .RS 4 .RE +.IP "\fBmimetype\fR" 4 +.IX Item "mimetype" +search packages able to handle given mimetypes +.RS 4 +.IP "\fB\-\-installed\fR" 4 +.IX Item "--installed" +search inside installed packages +.RE +.RS 4 +.RE .IP "\fBneeded\fR" 4 .IX Item "needed" show runtime libraries needed by the provided atoms @@ -1160,6 +1170,6 @@ Fabio Erculiani .SH "POD ERRORS" .IX Header "POD ERRORS" Hey! \fBThe above document had some coding errors, which are explained below:\fR -.IP "Around line 1320:" 4 -.IX Item "Around line 1320:" +.IP "Around line 1332:" 4 +.IX Item "Around line 1332:" You forgot a '=back' before '=head1' diff --git a/libraries/entropy/client/interfaces/methods.py b/libraries/entropy/client/interfaces/methods.py index 37839b66e..4174e3ae3 100644 --- a/libraries/entropy/client/interfaces/methods.py +++ b/libraries/entropy/client/interfaces/methods.py @@ -1731,3 +1731,32 @@ class MatchMixin: except OSError: shutil.copy2(tmp_path, mask_file) os.remove(tmp_path) + + def search_installed_mimetype(self, mimetype): + """ + Given a mimetype, return list of installed package identifiers + belonging to packages that can handle it. + + @param mimetype: mimetype string + @type mimetype: string + @return: list of installed package identifiers + @rtype: list + """ + return self._installed_repository.searchProvidedMime(mimetype) + + def search_available_mimetype(self, mimetype): + """ + Given a mimetype, return list of available package matches + belonging to packages that can handle it. + + @param mimetype: mimetype string + @type mimetype: string + @return: list of available package matches + @rtype: list + """ + packages = [] + for repo in self._enabled_repos: + repo_db = self.open_repository(repo) + packages += [(x, repo) for x in \ + repo_db.searchProvidedMime(mimetype)] + return packages