示例#1
0
文件: recipes.py 项目: dxphjt/pybombs
 def run_list_recipe_repos(self):
     """
     pybombs recipes list-repos
     """
     all_locations = self.cfg.get_recipe_locations()
     named_locations = self.cfg.get_named_recipe_dirs()
     named_sources = self.cfg.get_named_recipe_sources()
     unnamed_locations = [x for x in all_locations if not x in named_locations.values()]
     table = []
     for name in named_locations.keys():
         table.append({
             'name': name,
             'dir': named_locations.get(name, "FOO"),
             'source': named_sources.get(name, '-'),
         })
     for loc in unnamed_locations:
         table.append({
             'name': '-',
             'dir': loc,
             'source': '-',
         })
     tables.print_table(
         {'name': "Name", 'dir': "Directory", 'source': "Source"},
         table,
         col_order=('dir', 'name', 'source'),
     )
示例#2
0
文件: recipes.py 项目: dxphjt/pybombs
 def run_list_recipe_repos(self):
     """
     pybombs recipes list-repos
     """
     all_locations = self.cfg.get_recipe_locations()
     named_locations = self.cfg.get_named_recipe_dirs()
     named_sources = self.cfg.get_named_recipe_sources()
     unnamed_locations = [
         x for x in all_locations if not x in named_locations.values()
     ]
     table = []
     for name in named_locations.keys():
         table.append({
             'name': name,
             'dir': named_locations.get(name, "FOO"),
             'source': named_sources.get(name, '-'),
         })
     for loc in unnamed_locations:
         table.append({
             'name': '-',
             'dir': loc,
             'source': '-',
         })
     tables.print_table(
         {
             'name': "Name",
             'dir': "Directory",
             'source': "Source"
         },
         table,
         col_order=('dir', 'name', 'source'),
     )
示例#3
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,
     )
示例#4
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,
     )
示例#5
0
 def run_list_recipe_repos(self):
     """
     pybombs recipes list-repos
     """
     all_locations = self.cfg.get_recipe_locations()
     named_locations = self.cfg.get_named_recipe_dirs()
     named_sources = self.cfg.get_named_recipe_sources()
     unnamed_locations = [
         x for x in all_locations if not x in named_locations.values()
     ]
     table = []
     for name in named_locations.keys():
         try:
             pref_index = all_locations.index(
                 named_locations.get(name, "FOO"))
         except ValueError:
             pref_index = -1
         table.append({
             'name': name,
             'dir': named_locations.get(name, "FOO"),
             'source': named_sources.get(name, '-'),
             'pref': pref_index,
         })
     for loc in unnamed_locations:
         try:
             pref_index = all_locations.index(loc)
         except ValueError:
             pref_index = -1
         table.append({
             'name': '-',
             'dir': loc,
             'source': '-',
             'pref': pref_index,
         })
     tables.print_table(
         {
             'pref': "Index",
             'name': "Name",
             'dir': "Directory",
             'source': "Source"
         },
         table,
         col_order=('dir', 'name',
                    'source'),  # Add 'pref' here to print the index
         sort_by='pref',
     )
示例#6
0
    def run_list_recipe_repos(self):
        """
        pybombs recipes list-repos
        """
        all_locations = self.cfg.get_recipe_locations()
        named_locations = self.cfg.get_named_recipe_dirs()
        named_sources = self.cfg.get_named_recipe_sources()
        unnamed_locations = [
            x for x in all_locations if x not in named_locations.values()
        ]
        table = []
        for name in named_locations.keys():
            try:
                pref_index = all_locations.index(named_locations.get(name, "FOO"))
            except ValueError:
                pref_index = -1
            table.append({
                'name': name,
                'dir': named_locations.get(name, "FOO"),
                'source': named_sources.get(name, '-'),
                'pref': pref_index,

            })
        for loc in unnamed_locations:
            try:
                pref_index = all_locations.index(loc)
            except ValueError:
                pref_index = -1
            table.append({
                'name': '-',
                'dir': loc,
                'source': '-',
                'pref': pref_index,
            })
        tables.print_table(
            {'pref': "Index", 'name': "Name", 'dir': "Directory", 'source': "Source"},
            table,
            col_order=('dir', 'name', 'source'), # Add 'pref' here to print the index
            sort_by='pref',
        )