|
|
eb8139 |
From 7a265cf17fe3531e45dde8ae622c496bef1e17ae Mon Sep 17 00:00:00 2001
|
|
|
eb8139 |
From: Jan Kolarik <jkolarik@redhat.com>
|
|
|
eb8139 |
Date: Wed, 10 Aug 2022 16:24:08 +0200
|
|
|
eb8139 |
Subject: [PATCH] Allow passing plugin parameters with dashes in names
|
|
|
eb8139 |
(RhBug:1980712)
|
|
|
eb8139 |
|
|
|
eb8139 |
= changelog =
|
|
|
eb8139 |
type: bugfix
|
|
|
eb8139 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1980712
|
|
|
eb8139 |
---
|
|
|
eb8139 |
dnf/plugin.py | 20 +++++++++++++++++---
|
|
|
eb8139 |
1 file changed, 17 insertions(+), 3 deletions(-)
|
|
|
eb8139 |
|
|
|
eb8139 |
diff --git a/dnf/plugin.py b/dnf/plugin.py
|
|
|
eb8139 |
index 87c1f08f..b083727d 100644
|
|
|
eb8139 |
--- a/dnf/plugin.py
|
|
|
eb8139 |
+++ b/dnf/plugin.py
|
|
|
eb8139 |
@@ -225,17 +225,17 @@ def _get_plugins_files(paths, disable_plugins, enable_plugins):
|
|
|
eb8139 |
matched = True
|
|
|
eb8139 |
enable_pattern_tested = False
|
|
|
eb8139 |
for pattern_skip in disable_plugins:
|
|
|
eb8139 |
- if fnmatch.fnmatch(plugin_name, pattern_skip):
|
|
|
eb8139 |
+ if _plugin_name_matches_pattern(plugin_name, pattern_skip):
|
|
|
eb8139 |
pattern_disable_found.add(pattern_skip)
|
|
|
eb8139 |
matched = False
|
|
|
eb8139 |
for pattern_enable in enable_plugins:
|
|
|
eb8139 |
- if fnmatch.fnmatch(plugin_name, pattern_enable):
|
|
|
eb8139 |
+ if _plugin_name_matches_pattern(plugin_name, pattern_enable):
|
|
|
eb8139 |
matched = True
|
|
|
eb8139 |
pattern_enable_found.add(pattern_enable)
|
|
|
eb8139 |
enable_pattern_tested = True
|
|
|
eb8139 |
if not enable_pattern_tested:
|
|
|
eb8139 |
for pattern_enable in enable_plugins:
|
|
|
eb8139 |
- if fnmatch.fnmatch(plugin_name, pattern_enable):
|
|
|
eb8139 |
+ if _plugin_name_matches_pattern(plugin_name, pattern_enable):
|
|
|
eb8139 |
pattern_enable_found.add(pattern_enable)
|
|
|
eb8139 |
if matched:
|
|
|
eb8139 |
plugins.append(fn)
|
|
|
eb8139 |
@@ -250,6 +250,20 @@ def _get_plugins_files(paths, disable_plugins, enable_plugins):
|
|
|
eb8139 |
return plugins
|
|
|
eb8139 |
|
|
|
eb8139 |
|
|
|
eb8139 |
+def _plugin_name_matches_pattern(plugin_name, pattern):
|
|
|
eb8139 |
+ """
|
|
|
eb8139 |
+ Checks plugin name matches the pattern.
|
|
|
eb8139 |
+
|
|
|
eb8139 |
+ The alternative plugin name using dashes instead of underscores is tried
|
|
|
eb8139 |
+ in case of original name is not matched.
|
|
|
eb8139 |
+
|
|
|
eb8139 |
+ (see https://bugzilla.redhat.com/show_bug.cgi?id=1980712)
|
|
|
eb8139 |
+ """
|
|
|
eb8139 |
+
|
|
|
eb8139 |
+ try_names = set((plugin_name, plugin_name.replace('_', '-')))
|
|
|
eb8139 |
+ return any(fnmatch.fnmatch(name, pattern) for name in try_names)
|
|
|
eb8139 |
+
|
|
|
eb8139 |
+
|
|
|
eb8139 |
def register_command(command_class):
|
|
|
eb8139 |
# :api
|
|
|
eb8139 |
"""A class decorator for automatic command registration."""
|
|
|
eb8139 |
--
|
|
|
eb8139 |
2.37.1
|
|
|
eb8139 |
|