+ 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)