[PATCH 2/3] Parse component name correctly (#866526)

Vratislav Podzimek vpodzime at redhat.com
Tue Oct 16 17:22:46 UTC 2012


Thanks to Jakub Filak <jfilak at redhat.com> for the original version
of this patch.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 meh/dump.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/meh/dump.py b/meh/dump.py
index e9779f0..e8988f1 100644
--- a/meh/dump.py
+++ b/meh/dump.py
@@ -143,7 +143,17 @@ class ExceptionDump(object):
                         "{0}".format(file_))
             package = "{0}-{1}-{2}.{3}".format(header["name"], header["version"],
                                             header["release"], header["arch"])
-            component = header["sourcerpm"].split("-")[0]
+
+            # cuts the name from the NVR format: foo-blah-2.8.8-2.fc17.src.rpm
+            name_end = len(header["sourcerpm"])
+            try:
+                name_end = header["sourcerpm"].rindex('-')
+                name_end = header["sourcerpm"][:name_end].rindex('-')
+            except ValueError as e:
+                # expected exception
+                pass
+
+            component = header["sourcerpm"][:name_end]
 
             return (package, component)
 
-- 
1.7.11.4



More information about the anaconda-patches mailing list