]> git.itanic.dy.fi Git - emerge-timer/commitdiff
list_pretended: Change how the package name is parsed from stdin
authorEsko Kokkonen <esko.kokkonen@gmail.com>
Mon, 29 Aug 2011 10:14:22 +0000 (13:14 +0300)
committerEsko Kokkonen <esko.kokkonen@gmail.com>
Mon, 29 Aug 2011 10:14:22 +0000 (13:14 +0300)
Implement a better way of getting the package name and version from
stdin. This doesn't involve going through a list of all packages in
such a tedious way it was before. Only thing this now requires is that
the version number of any package always starts with a digit. So a
version number like "-1.0" is totally fine, but a version number like
"-r1-1.0" is not. Hopefully the latter ones aren't that common.

emerge-timer.py

index faf4e773a34d70096dbf1d69c8c09d9524c0a9aa..af7858eff11fb11034a8e745fdc9afc01887ab3d 100755 (executable)
@@ -316,9 +316,14 @@ def list_pretended(f):
         if "[ebuild" in line:
             full_name = line.partition('] ')[2].partition(' ')[0]
 
-            for i in all_packages:
-                if i in full_name:
-                    packages.append((i, full_name[len(i):]))
+            version = full_name.partition('/')[2].partition('-')[2]
+            while not version[0].isdigit():
+                version = version.partition('-')[2]
+
+            package_name = full_name[:-len(version)-1]
+
+            packages.append((package_name, '-' + version))
+
 
     if len(packages) == 0:
         return