diff --git a/dnfdragora/dialogs.py b/dnfdragora/dialogs.py index 09d3e38..0a9752d 100644 --- a/dnfdragora/dialogs.py +++ b/dnfdragora/dialogs.py @@ -1117,7 +1117,7 @@ def _openSearchOptions(self): self.factory.createVSpacing(vbox, 0.3) heading.setAutoWrap() - match_all = self.parent.match_all + fuzzy_search = self.parent.fuzzy_search newest_only = self.parent.newest_only self.newest_only = self.factory.createCheckBox(self.factory.createLeft(vbox) , _("Show newest packages only"), newest_only ) @@ -1125,10 +1125,10 @@ def _openSearchOptions(self): self.eventManager.addWidgetEvent(self.newest_only, self.onNewestOnly, True) self.widget_callbacks.append( { 'widget': self.newest_only, 'handler': self.onNewestOnly} ) - self.match_all = self.factory.createCheckBox(self.factory.createLeft(vbox) , _("Match all words"), match_all ) - self.match_all.setNotify(True) - self.eventManager.addWidgetEvent(self.match_all, self.onMatchAll, True) - self.widget_callbacks.append( { 'widget': self.match_all, 'handler': self.onMatchAll} ) + self.fuzzy_search = self.factory.createCheckBox(self.factory.createLeft(vbox) , _("Fuzzy search (legacy mode)"), fuzzy_search ) + self.fuzzy_search.setNotify(True) + self.eventManager.addWidgetEvent(self.fuzzy_search, self.onMatchAll, True) + self.widget_callbacks.append( { 'widget': self.fuzzy_search, 'handler': self.onMatchAll} ) self.factory.createVStretch(vbox) self.config_tab.showChild() @@ -1252,10 +1252,10 @@ def onMatchAll(self, obj): ''' if isinstance(obj, yui.YCheckBox): try: - self.parent.config.userPreferences['settings']['search']['match_all'] = obj.isChecked() + self.parent.config.userPreferences['settings']['search']['fuzzy_search'] = obj.isChecked() except: - self.parent.config.userPreferences['settings']['search'] = { 'match_all' : obj.isChecked() } - self.parent.match_all = obj.isChecked() + self.parent.config.userPreferences['settings']['search'] = { 'fuzzy_search' : obj.isChecked() } + self.parent.fuzzy_search = obj.isChecked() else: logger.error("Invalid object passed %s", obj.widgetClass()) @@ -1357,10 +1357,10 @@ def onRestoreButton(self) : self._openLayoutOptions() elif k == "search": self.parent.config.userPreferences['settings']['search'] = { - 'match_all': True, + 'fuzzy_search': False, 'newest_only': False, } - self.parent.match_all = True + self.parent.fuzzy_search = False self.parent.newest_only = False self._openSearchOptions() elif k == "logging": diff --git a/dnfdragora/helpinfo.py b/dnfdragora/helpinfo.py index 9976016..39d1be5 100644 --- a/dnfdragora/helpinfo.py +++ b/dnfdragora/helpinfo.py @@ -131,7 +131,7 @@ def __init__(self): _('<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>') + \ - _('<li><b>Match all words</b>: if checked a search without using regular expressions will match all the given words into the text field.</li></ul>') + \ + _('<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>.') + \ _('<ul><li><b>Change directory</b>: this option allows to set logging directory, directory must exist and needs write permission.</li>') + \ diff --git a/dnfdragora/ui.py b/dnfdragora/ui.py index 408791d..ec07855 100644 --- a/dnfdragora/ui.py +++ b/dnfdragora/ui.py @@ -219,7 +219,7 @@ def __init__(self, options={}): self.group_icon_path = None self.images_path = '/usr/share/dnfdragora/images/' self.always_yes = False - self.match_all = False + self.fuzzy_search = False self.newest_only = False self.all_updates_filter = False self.log_enabled = False @@ -320,8 +320,8 @@ def _configFileRead(self) : search = {} if 'search' in settings.keys(): search = settings['search'] - if 'match_all' in search.keys(): - self.match_all = search['match_all'] + if 'fuzzy_search' in search.keys(): + self.fuzzy_search = search['fuzzy_search'] if 'newest_only' in search.keys(): self.newest_only = search['newest_only'] @@ -360,8 +360,8 @@ def _configFileRead(self) : search = user_settings['search'] if 'newest_only' in search.keys(): self.newest_only = search['newest_only'] - if 'match_all' in search.keys(): - self.match_all = search['match_all'] + if 'fuzzy_search' in search.keys(): + self.fuzzy_search = search['fuzzy_search'] #### Logging if 'log' in user_settings.keys(): log = user_settings['log'] @@ -1334,10 +1334,11 @@ def _searchPackages(self) : # fixing attribute names if field == 'name' : field = 'fullname' - self.backend.search(filter, field, search_string) else: - strings = re.split('[ ,|:;]',search_string) + strings = [s for s in re.split('[ ,|:;]',search_string) if s] + if self.fuzzy_search: + strings = [s.join(["*","*"]) for s in strings] options = { "scope": filter, @@ -1486,7 +1487,7 @@ def saveUserPreference(self): } search = { - 'match_all': self.match_all, + 'fuzzy_search': self.fuzzy_search, 'newest_only': self.newest_only }