[Yum-devel] regex in yum source

Florian La Roche laroche at redhat.com
Mon Oct 10 16:52:24 UTC 2005


Hello Seth and co,

The following was originally found in pyrpm by Miloslav Trmac.

I think the trailing ".*" could also be left away,
but re.match needs to match from the beginning.

Not sure what todo about "+". Quite a few names have this
char within their name, so we probably optimize this a bit to
not take this as regex char. Still then works differently in
yum/__init__.py compared to yum/packages.py.

greetings,

Florian La Roche



--- yum/__init__.py
+++ yum/__init__.py
@@ -1000,7 +1000,7 @@ class YumBase(depsolve.Depsolve):
         """Takes a search string from the cli for Search or Provides
            and cleans it up so it doesn't make us vomit"""
         
-        if re.match('.*[\*,\[,\],\{,\},\?,\+].*', arg):
+        if re.match('.*[\*\[\]\{\}\?\+].*', arg):
             restring = fnmatch.translate(arg)
         else:
             restring = re.escape(arg)
--- yum/packages.py
+++ yum/packages.py
@@ -78,7 +78,7 @@ def parsePackages(pkgs, usercommands, ca
         else:
             # anything we couldn't find a match for
             # could mean it's not there, could mean it's a wildcard
-            if re.match('.*[\*,\[,\],\{,\},\?].*', command):
+            if re.match('.*[\*\[\]\{\}\?].*', command):
                 trylist = pkgdict.keys()
                 restring = fnmatch.translate(command)
                 if casematch:



More information about the Yum-devel mailing list