From a4c5d89b082cfbc43c1ea38ef88a281369340ef7 Mon Sep 17 00:00:00 2001 From: Esko Kokkonen Date: Mon, 29 Aug 2011 13:14:22 +0300 Subject: [PATCH] list_pretended: Change how the package name is parsed from stdin 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/emerge-timer.py b/emerge-timer.py index faf4e77..af7858e 100755 --- a/emerge-timer.py +++ b/emerge-timer.py @@ -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 -- 2.45.0