Beispiel #1
0
 def run_list(self):
     """
     Print a list of recipes.
     """
     pkgmgr = PackageManager()
     recmgr = RecipeListManager()
     self.log.debug("Loading all package names")
     all_recipes = recmgr.list_all()
     if self.args.list is not None:
         all_recipes = [x for x in all_recipes if re.search(self.args.list, x)]
     not_installed_string = '-'
     format_pkg_list = lambda x: [not_installed_string] if not x else x
     rows = []
     row_titles = {
         'id': "Package Name",
         'path': "Recipe Filename",
         'installed_by': "Installed By",
         'available_from': "Available From",
     }
     self.args.format = [x for x in self.args.format.split(",") if len(x)]
     if any(map(lambda x: x not in row_titles, self.args.format)):
         self.log.error("Invalid column formatting: {0}".format(self.args.format))
         return -1
     print("Loading package information...", end="")
     sys.stdout.flush()
     home_dir = os.path.expanduser("~")
     for pkg in all_recipes:
         rec = recipe.get_recipe(pkg, target=None, fail_easy=True)
         if rec is None:
             print()
             self.log.warn("Recipe for `{0}' is invalid.".format(pkg))
             continue
         if rec.target != 'package':
             continue
         print(".", end="")
         sys.stdout.flush()
         row = {
             'id': pkg,
             'path': recmgr.get_recipe_filename(pkg).replace(home_dir, "~"),
             'installed_by': format_pkg_list(pkgmgr.installed(pkg, return_pkgr_name=True)),
             'available_from': ",".join(format_pkg_list(pkgmgr.exists(pkg, return_pkgr_name=True))),
         }
         if self.args.in_prefix and 'source' not in row['installed_by']:
             continue
         if row['installed_by'] == [not_installed_string] and (self.args.installed or self.args.in_prefix):
             continue
         row['installed_by'] = ",".join(row['installed_by'])
         rows.append(row)
     print("")
     tables.print_table(
             row_titles,
             rows,
             self.args.format,
             sort_by=self.args.sort_by,
     )
Beispiel #2
0
 def run_list(self):
     """
     Print a list of recipes.
     """
     pkgmgr = PackageManager()
     recmgr = RecipeListManager()
     self.log.debug("Loading all package names")
     all_recipes = recmgr.list_all()
     if self.args.list is not None:
         all_recipes = [x for x in all_recipes if re.search(self.args.list, x)]
     not_installed_string = '-'
     format_pkg_list = lambda x: [not_installed_string] if not x else x
     rows = []
     row_titles = {
         'id': "Package Name",
         'path': "Recipe Filename",
         'installed_by': "Installed By",
         'available_from': "Available From",
     }
     self.args.format = [x for x in self.args.format.split(",") if len(x)]
     if any((x not in row_titles for x in self.args.format)):
         self.log.error("Invalid column formatting: {0}".format(self.args.format))
         return -1
     print("Loading package information...", end="")
     sys.stdout.flush()
     home_dir = os.path.expanduser("~")
     for pkg in all_recipes:
         rec = recipe.get_recipe(pkg, target=None, fail_easy=True)
         if rec is None:
             print()
             self.log.warn("Recipe for `{0}' is invalid.".format(pkg))
             continue
         if rec.target != 'package':
             continue
         print(".", end="")
         sys.stdout.flush()
         row = {
             'id': pkg,
             'path': recmgr.get_recipe_filename(pkg).replace(home_dir, "~"),
             'installed_by': format_pkg_list(pkgmgr.installed(pkg, return_pkgr_name=True)),
             'available_from': ",".join(format_pkg_list(pkgmgr.exists(pkg, return_pkgr_name=True))),
         }
         if self.args.in_prefix and 'source' not in row['installed_by']:
             continue
         if row['installed_by'] == [not_installed_string] and (self.args.installed or self.args.in_prefix):
             continue
         row['installed_by'] = ",".join(row['installed_by'])
         rows.append(row)
     print("")
     tables.print_table(
         row_titles,
         rows,
         self.args.format,
         sort_by=self.args.sort_by,
     )