[yum-commits] Branch 'yum-3_2_X' - yum/misc.py yum/packages.py yum/yumRepo.py
James Antill
james at osuosl.org
Wed Sep 23 13:09:18 UTC 2009
yum/misc.py | 29 ++++++++++-------------------
yum/packages.py | 5 ++++-
yum/yumRepo.py | 8 ++++----
3 files changed, 18 insertions(+), 24 deletions(-)
New commits:
commit ef1ed3c6e2eacee62e4c1f556c270636512a4c08
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Tue Sep 22 22:20:56 2009 +0300
Use basic string matching/replacing instead of regexps where appropriate.
diff --git a/yum/misc.py b/yum/misc.py
index 17e5ef6..9793180 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -90,33 +90,24 @@ def re_filename(s):
_re_compiled_filename_match = re.compile('^(/|[*?]|\[[^]]*/[^]]*\])')
return _re_compiled_filename_match.match(s)
-_re_compiled_pri_fnames_match = None
def re_primary_filename(filename):
""" Tests if a filename string, can be matched against just primary.
Note that this can produce false negatives (but not false
positives). """
- global _re_compiled_pri_fnames_match
- if _re_compiled_pri_fnames_match is None:
- one = re.compile('.*bin\/.*')
- two = re.compile('^\/etc\/.*')
- three = re.compile('^\/usr\/lib\/sendmail$')
- _re_compiled_pri_fnames_match = (one, two, three)
- for rec in _re_compiled_pri_fnames_match:
- if rec.match(filename):
- return True
+ if 'bin/' in filename:
+ return True
+ if filename.startswith('/etc/'):
+ return True
+ if filename == '/usr/lib/sendmail':
+ return True
return False
-_re_compiled_pri_dnames_match = None
def re_primary_dirname(dirname):
""" Tests if a dirname string, can be matched against just primary. """
- global _re_compiled_pri_dnames_match
- if _re_compiled_pri_dnames_match is None:
- one = re.compile('.*bin\/.*')
- two = re.compile('^\/etc\/.*')
- _re_compiled_pri_dnames_match = (one, two)
- for rec in _re_compiled_pri_dnames_match:
- if rec.match(dirname):
- return True
+ if 'bin/' in dirname:
+ return True
+ if dirname.startswith('/etc/'):
+ return True
return False
_re_compiled_full_match = None
diff --git a/yum/packages.py b/yum/packages.py
index 9a56fc4..7bbb61d 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -617,7 +617,10 @@ class YumAvailablePackage(PackageObject, RpmBase):
# ignoring "bad" chars.
val = _nf2ascii(val)
# Hacky way to get rid of version numbers...
- self._committer_ret = re.sub("""> .*""", '>', val)
+ ix = val.find('> ')
+ if ix != -1:
+ val = val[0:ix+1]
+ self._committer_ret = val
return self._committer_ret
committer = property(_committer)
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 367a68e..d860ef9 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1607,8 +1607,8 @@ class YumRepository(Repository, config.RepoConf):
for line in content:
if re.match('^\s*\#.*', line) or re.match('^\s*$', line):
continue
- mirror = re.sub('\n$', '', line) # no more trailing \n's
- (mirror, count) = re.subn('\$ARCH', '$BASEARCH', mirror)
+ mirror = line.rstrip() # no more trailing \n's
+ mirror = mirror.replace('$ARCH', '$BASEARCH')
returnlist.append(mirror)
return (returnlist, content)
@@ -1809,8 +1809,8 @@ def getMirrorList(mirrorlist, pdict = None):
for line in content:
if re.match('^\s*\#.*', line) or re.match('^\s*$', line):
continue
- mirror = re.sub('\n$', '', line) # no more trailing \n's
- (mirror, count) = re.subn('\$ARCH', '$BASEARCH', mirror)
+ mirror = line.rstrip() # no more trailing \n's
+ mirror = mirror.replace('$ARCH', '$BASEARCH')
returnlist.append(mirror)
return returnlist
More information about the Yum-commits
mailing list