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