Exemple #1
0
def show(fields, format, remote, location):
    """List the plugins to be loaded at runtime"""
    disabled_plugins = config.plugins.readonly.get('disabled_plugins', [])
    if not fields and not location:
        fields = list(get_option_choices('fields'))
        fields.remove('location')
    if remote:
        plugins = list_plugins_from_remote()
    else:
        plugins = [
            plugin_name(ensure_unicode(plugin))
            for plugin in config.plugins.plugins.list_plugins()
        ]

        def plugin_location(plugin):
            name = plugin.replace("/", "_")
            for path in config.plugins.plugins.searchpath:
                candidate = glob_first(os.path.join(path, name + ".py*"))
                if candidate is not None:
                    return candidate

        vals = [[
            plugin,
            'disabled' if plugin in disabled_plugins else 'enabled',
            load_short_help(plugin.replace('/', '_')),
            plugin_location(plugin),
        ] for plugin in sorted(plugins)]
    with TablePrinter(fields, format) as tp:
        tp.echos(vals)
Exemple #2
0
 def write_version(self):
     if self.frozen_during_migration:
         raise click.UsageError(
             "You cannot edit the configuration if the migration is not persisted"
         )
     makedirs(self.location)
     version = self.version
     createfile(self.version_file_name, ensure_unicode(str(version)), internal=True)
Exemple #3
0
 def plugin_doc(self, plugin):
     try:
         mod = self.plugin_source.load_plugin(plugin)
         if hasattr(mod, '__doc__'):
             return ensure_unicode(mod.__doc__)
     except Exception:
         pass
     return None
Exemple #4
0
def load_help(plugin):
    from click_project.plugins import plugins
    try:
        mod = plugins.load_plugin(plugin)
        if hasattr(mod, '__doc__'):
            return ensure_unicode(mod.__doc__)
    except Exception:
        pass
    return None