From 66c60694bedfde816bdcd955be4303c4c5230943 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 19 Sep 2010 16:37:59 +0200 Subject: Strip version from rpm packages --- whatmaps | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/whatmaps b/whatmaps index f7a62a0..fc6c703 100755 --- a/whatmaps +++ b/whatmaps @@ -172,6 +172,7 @@ class DebianPkg(Pkg): class RedHatDistro(Distro): # Package contains file: rpm -q -f somefile "RPM based distribution""" + _pkg_re = re.compile(r'(?P[\w\-\+]+)-(?P[\w\.]+)-(?P[\w\.]+)\.(?P.+)') @classmethod def pkg(klass, name): @@ -184,7 +185,11 @@ class RedHatDistro(Distro): output = find_file.communicate()[0] if find_file.returncode: return None - pkg = output.strip() + m = klass._pkg_re.match(output.strip()) + if m: + pkg = m.group('pkg') + else: + pkg = output.strip() return RpmPkg(pkg) @classmethod -- cgit v1.2.3