packages[0].add_version(version, emerge_time, start_time)
+def get_package(name):
+ """Take the user-input package name and search for it
+ in PORTDIR. """
-def print_stuff():
- for p in packages:
- p.print_versions()
+ dirlist = os.listdir(PORTDIR)
+ possible_package = []
+
+
+ # If the given name is in the format xxx/zzz
+ # assume that xxx is the package group
+ if '/' in name:
+ group = name.partition('/')[0]
+ pkg = name.partition('/')[2]
+ directory = PORTDIR + group
+
+ if group in dirlist:
+ dirs = os.listdir(directory)
+ if pkg in dirs:
+ possible_package.append(name)
+
+
+ # Go through the directory listing searching for anything
+ # that matches the given name
+ for i in dirlist:
+ directory = PORTDIR + i
+ if os.path.isdir(directory):
+ dirs = os.listdir(directory)
+ if name in dirs:
+ possible_package.append(i + '/' + name)
+
+
+ if len(possible_package) > 1:
+ print("Multiple packages found for '" + name + "'.")
+ print("Possible packages: ")
+ for value in possible_package:
+ print("\t" + value)
+
+
+ elif len(possible_package) == 1:
+ package = possible_package[0]
+ return package
+
+
+ else:
+ print("No package '" + name + "' found")
+
+
+ sys.exit(1)
def main(status, user_package=None):
if status == "package":
+ user_package = get_package(user_package)
+
search_log_for_package(user_package)
- print_stuff()
+ packages[0].print_versions()
elif status == "current":