def get_package_metadata(self, name): try: meta = pkginfo.Installed(name) except ValueError as e: print(e) return None return meta
def pre(self, command, output_dir, vars): gocept_package = pkginfo.Installed('gocept.package') vars.update( year=datetime.date.today().year, underline_double=self.underline_double, gocept_package_version=gocept_package.version, )
def dep_versions(): return 'pkginfo: {0}, requests: {1}, setuptools: {2}'.format( pkginfo.Installed(pkginfo).version, # __version__ is always defined but requests does not always have # PKG-INFO to read from requests.__version__, setuptools.__version__, )
def _add_plugins_from_entry_points(self, groups, plugins, disabled_plugins): import pkg_resources import pkginfo if not isinstance(groups, (list, tuple)): groups = [groups] for group in groups: for entry_point in pkg_resources.iter_entry_points(group=group, name=None): key = entry_point.name module_name = entry_point.module_name version = entry_point.dist.version if key in plugins: # plugin is already defined, ignore it continue kwargs = dict(module_name=module_name, version=version) try: module_pkginfo = pkginfo.Installed(module_name) except: self.logger.exception( "Something went wrong while retrieving package info data for module %s" % module_name) else: kwargs.update( dict(name=module_pkginfo.name, summary=module_pkginfo.summary, author=module_pkginfo.author, url=module_pkginfo.home_page, license=module_pkginfo.license)) plugin = self._load_plugin_from_module(key, **kwargs) if plugin: plugin.origin = ("entry_point", group, module_name) if self._is_plugin_disabled(key): plugin.enabled = False disabled_plugins[key] = plugin else: plugins[key] = plugin return plugins, disabled_plugins
""" REST APIs documented and sensible """ import pkginfo from . import config from . import decorators from . import documents from . import resources # PEP 396 __version__ = pkginfo.Installed('rapids').version # EOF
def generate_pkg_metadata(self): """Get metadatsa for 'parent' pyramid package.""" # Get the PKG-INFO metadata for the 'parent' pyramid app pkg_name = self.api.config.package_name self.metadata = pkginfo.Installed(pkg_name)
def test_package_has_gocept_package_version_pinned_to_active(self): self.expand_template() gocept_package = pkginfo.Installed('gocept.package') self.assertIn('gocept.package = %s\n' % gocept_package.version, self.content('versions/versions.cfg'))
def _get_parser(self): info = pkginfo.Installed('pibootctl') parser = argparse.ArgumentParser(description=_( "%(prog)s is a tool for querying and modifying the boot " "configuration of the Raspberry Pi.")) parser.add_argument('--version', action='version', version=info.version) parser.set_defaults(func=self.do_help) commands = parser.add_subparsers(title=_("commands")) help_cmd = commands.add_parser( "help", aliases=["?"], description=_( "With no arguments, displays the list of pibootctl " "commands. If a command name is given, displays the " "description and options for the named command. If a " "setting name is given, displays the description and " "default value for that setting."), help=_("Displays help about the specified command or setting")) help_cmd.add_argument( "cmd", metavar="command-or-setting", nargs='?', help=_("The name of the command or setting to output help for" )).completer = self._complete_help help_cmd.set_defaults(func=self.do_help) dump_cmd = commands.add_parser( "status", aliases=["dump"], description=_( "Output the current value of modified boot time settings " "that match the specified pattern (or all if no pattern " "is provided)."), help=_("Output the current boot time configuration")) dump_cmd.add_argument( "vars", nargs="?", metavar="pattern", help=_("If specified, only displays settings with names that " "match the specified pattern which may include shell " "globbing characters (e.g. *, ?, and simple [classes])" )).completer = self._complete_status dump_cmd.add_argument( "-a", "--all", action="store_true", help=_("Include all settings, regardless of modification, in " "the output; by default, only settings which have been " "modified are included")) Output.add_style_arg(dump_cmd) dump_cmd.set_defaults(func=self.do_status) get_cmd = commands.add_parser( "get", description=_( "Query the status of one or more boot configuration " "settings. If a single setting is requested then just " "that value is output. If multiple values are requested " "then both setting names and values are output. This " "applies whether output is in the default, JSON, YAML, or " "shell-friendly styles."), help=_("Query the state of one or more boot settings")) get_cmd.add_argument( "get_vars", nargs="+", metavar="setting", help=_("The name(s) of the setting(s) to query; if a single " "setting is given its value alone is output, if multiple " "settings are queried the names and values of the " "settings are output")).completer = self._complete_get_vars Output.add_style_arg(get_cmd) get_cmd.set_defaults(func=self.do_get) set_cmd = commands.add_parser( "set", description=_("Change the value of one or more boot configuration " "settings. To reset the value of a setting to its " "default, simply omit the new value."), help=_("Change the state of one or more boot settings")) set_cmd.add_argument( "--no-backup", action="store_false", dest="backup", help=_("Don't take an automatic backup of the current boot " "configuration if one doesn't exist")) group = set_cmd.add_mutually_exclusive_group(required=False) group.add_argument( "--all", dest="context", action="store_const", const="all", help=_( "Set the specified settings on all Pis this SD card is used " "with. This is the default context.")) group.add_argument( "--this-model", dest="context", action="store_const", const="model", help=_("Set the specified settings for this model of Pi only.")) group.add_argument( "--this-serial", dest="context", action="store_const", const="serial", help=_("Set the specified settings for this Pi's serial number " "only.")) # TODO Finish --this-display #group.add_argument( # "--this-display", dest="context", action="store_const", # const="edid", help=_( # "Set the specified settings for the EDID of the specified " # "monitor only.")) group = Output.add_style_arg(set_cmd, required=True) group.add_argument( "set_vars", nargs="*", metavar="name=[value]", default=[], help=_("Specify one or more settings to change on the command " "line; to reset a setting to its default omit the value" )).completer = self._complete_set_vars set_cmd.set_defaults(func=self.do_set, backup=True, context="all") save_cmd = commands.add_parser( "save", description=_("Store the current boot configuration under a given " "name."), help=_("Store the current boot configuration for later use")) save_cmd.add_argument( "name", help=_("The name to save the current boot configuration under; " "can include any characters legal in a filename" )).completer = self._complete_save_name save_cmd.add_argument( "-f", "--force", action="store_true", help=_("Overwrite an existing configuration, if one exists")) save_cmd.set_defaults(func=self.do_save) load_cmd = commands.add_parser( "load", description=_( "Overwrite the current boot configuration with a stored " "one."), help=_("Replace the boot configuration with a saved one")) load_cmd.add_argument( "name", help=_("The name of the boot configuration to restore" )).completer = self._complete_load_name load_cmd.add_argument( "--no-backup", action="store_false", dest="backup", help=_("Don't take an automatic backup of the current boot " "configuration if one doesn't exist")) load_cmd.set_defaults(func=self.do_load) diff_cmd = commands.add_parser( "diff", description=_( "Display the settings that differ between two stored boot " "configurations, or between one stored boot configuration " "and the current configuration."), help=_("Show the differences between boot configurations")) diff_cmd.add_argument( "left", nargs="?", default=Current, help=_("The boot configuration to compare from, or the current " "configuration if omitted" )).completer = self._complete_diff_left diff_cmd.add_argument( "right", help=_("The boot configuration to compare against" )).completer = self._complete_diff_right Output.add_style_arg(diff_cmd) diff_cmd.set_defaults(func=self.do_diff) show_cmd = commands.add_parser( "show", aliases=["cat"], description=_( "Display the specified stored boot configuration, or the " "sub-set of its settings that match the specified " "pattern."), help=_("Show the specified stored configuration")) show_cmd.add_argument( "name", help=_("The name of the boot configuration to display" )).completer = self._complete_show_name show_cmd.add_argument( "vars", nargs="?", metavar="pattern", help=_("If specified, only displays settings with names that " "match the specified pattern which may include shell " "globbing characters (e.g. *, ?, and simple [classes])" )).completer = self._complete_show_vars show_cmd.add_argument( "-a", "--all", action="store_true", help=_("Include all settings, regardless of modification, in " "the output; by default, only settings which have been " "modified are included")) Output.add_style_arg(show_cmd) show_cmd.set_defaults(func=self.do_show) ls_cmd = commands.add_parser( "list", aliases=["ls"], description=_("List all stored boot configurations."), help=_("List the stored boot configurations")) Output.add_style_arg(ls_cmd) ls_cmd.set_defaults(func=self.do_list) rm_cmd = commands.add_parser( "remove", aliases=["rm"], description=_("Remove a stored boot configuration."), help=_("Remove a stored boot configuration")) rm_cmd.add_argument( "name", help=_("The name of the boot configuration to remove" )).completer = self._complete_remove_name rm_cmd.add_argument( "-f", "--force", action="store_true", help=_("Ignore errors if the named configuration does not exist")) rm_cmd.set_defaults(func=self.do_remove) mv_cmd = commands.add_parser( "rename", aliases=["mv"], description=_("Rename a stored boot configuration."), help=_("Rename a stored boot configuration")) mv_cmd.add_argument( "name", help=_("The name of the boot configuration to rename" )).completer = self._complete_rename_name mv_cmd.add_argument("to", help=_("The new name of the boot configuration") ).completer = self._complete_rename_to mv_cmd.add_argument( "-f", "--force", action="store_true", help=_("Overwrite the target configuration, if it exists")) mv_cmd.set_defaults(func=self.do_rename) return parser, commands.choices
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Created on Mon Nov 18 16:10:33 2013 @author: phil """ from . import fp_utils from . import mls from . import gen_utils from . import plt_utils from . import plotly_utils from . import fil_utils from . import dsp_opts from . import verilog_gen from . import verilog_filter # from . import adv_plt from . import adv_pfb from . import vgen_xilinx from . import demod_utils import pkginfo __version__ = pkginfo.Installed('phy_tools').version # part of setuptools