Skip to content

Commit

Permalink
Restored show only new packages option on search, now it works on RE
Browse files Browse the repository at this point in the history
search too
  • Loading branch information
anaselli committed Jan 11, 2025
1 parent 51748c6 commit 2e1f641
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dnfdragora/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ def onShowUpdates(self, obj):

def onFuzzySearch(self, obj):
'''
Newest Only Changing
Fuzzy Search Changing
'''
if isinstance(obj, yui.YCheckBox):
try:
Expand Down
2 changes: 1 addition & 1 deletion dnfdragora/helpinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __init__(self):
_('<li><b>Do not show groups view</b>: filtering by groups could require CPU if using comps, if this option is checked dnfdragora starts showing all packages.</li></ul>') + \
_('<b>NOTE</b> that the above options require dnfdragora to be restarted.') + \
_('<h2>Search options</h2>') + \
_('<ul><li><b>Show newest packages only</b>: if checked dnfdragora shows only newest packages on search. <i>Note that is valid if searches are not performed by using regular expressions</i></li>') + \
_('<ul><li><b>Show newest packages only</b>: if checked dnfdragora shows only newest packages on search.</li>') + \
_('<li><b>Fuzzy search (legacy mode)</b>: if checked a search without using regular expressions will add "*" to the given words, restoring the behavior dnfdragora had usnig dnffdaemon 4.</li></ul>') + \
_('<h2>Logging options</h2>') + \
_('Enable these options to let dnfdragora log on file called <i>dnfdragora.log</i>.') + \
Expand Down
27 changes: 25 additions & 2 deletions dnfdragora/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2647,14 +2647,37 @@ def _manageDnfDaemonEvent(self):

elif (event == 'RESearch'):
if not info['error']:
packages = info['result']
pkgs = None
packages = None
if self.newest_only:
pkgs = sorted(info['result'], key=lambda p: p.full_nevra, reverse=True)
name = None
packages = []
for p in pkgs:
if p.name != name:
packages.append(p)
name = p.name
else:
packages = info['result']
self._showSearchResult(packages, createTreeItem=True)
else:
self._showErrorAndContinue(_("Search error using regular expression"), info['error'])
logger.error("Search error: %s", info['error'])

elif (event == 'Search'):
if not info['error']:
packages = self.backend.make_pkg_object_with_attr(info['result'])
pkgs = None
packages = None
if self.newest_only:
pkgs = sorted(self.backend.make_pkg_object_with_attr(info['result']), key=lambda p: p.full_nevra, reverse=True)
name = None
packages = []
for p in pkgs:
if p.name != name:
packages.append(p)
name = p.name
else:
packages = self.backend.make_pkg_object_with_attr(info['result'])
self._showSearchResult(packages, createTreeItem=True)
else:
logger.error("Search error: %s", info['error'])
Expand Down

0 comments on commit 2e1f641

Please sign in to comment.