--- a/plugin_pack.py Sat Mar 29 23:22:24 2008 -0400
+++ b/plugin_pack.py Sun Mar 30 03:43:52 2008 -0400
@@ -1,8 +1,42 @@
+# plugin_pack.py - Helper script for obtaining info about the plugin pack +# Copyright (C) 2008 Gary Kramlich <grim@reaperworld.com> +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. +"""Usage: plugin_pack.py [options] + -a, --abusive-plugins Outputs a comma-separated list of the abusive + -D, --dist-dirs Outputs the list of all directories that have + plugins and should be included in the distribution + -d, --default-plugins Outputs a comma-separated list of the default + --dependency-graph Outputs a graphviz diagram showing dependencies + -h, --help Shows usage information + -i, --incomplete-plugins Outputs a comma-separated list of the incomplete + -p, --plugin=<name> Outputs all info about <name> @@ -31,10 +65,18 @@
printerr('\'%s\' has an unknown type of \'%s\'!' % (self.name, self.type))
+ output = 'name: %s\n' % self.name + output += 'type: %s\n' % self.type + output += 'depends: %s\n' % string.join(self.depends, ' ') + output += 'provides: %s\n' % self.provides + output += 'directory: %s\n' % self.directory + output += 'summary: %s\n' % self.summary + output += '%s\n' % self.description
for file in glob.glob('*/plugins.cfg'):
@@ -49,37 +91,148 @@
for plugin in parser.sections():
p = Plugin(os.path.dirname(file), plugin, parser)
+ self.plugins[p.name] = p
+ def list_type(self, type): - for plugin in self.plugins:
+ for name in self.plugins.keys(): + plugin = self.plugins[name] - def dump_list(self, list):
+ def print_names(self, list): + names.append(plugin.name) + print string.join(names, ',') + for name in self.plugins.keys(): + def default_plugins(self): + return self.list_type('default') + def abusive_plugins(self): + return self.list_type('abusive') + def incomplete_plugins(self): + return self.list_type('incomplete') + def dependency_graph(self): + def node_label(plugin): + node = plugin.provides.replace('-', '_') + def print_plugins(list): + node, label = node_label(plugin) + print '\t%s[label="%s"];' % (node, label)
- self.dump_list(self.list('default'))
+ print '\tlabel="Dependency Graph";' + print '\tlabelloc="t";' + print '\tsplines=TRUE;' + print '\toverlap=scale;' + print '\tnode[fontname="sans", style="filled", shape="box"];' + # run through the default plugins + print '\t/* default plugins */' + print '\tnode[fillcolor="palegreen"];' + print_plugins(self.default_plugins()) + # run through the incomplete plugins + print '\t/* incomplete plugins */' + print '\tnode[fillcolor="lightyellow1"];' + print_plugins(self.incomplete_plugins())
- self.dump_list(self.list('abusive'))
+ # run through the abusive plugins + print '\t/* abusive plugins */' + print '\tnode[fillcolor="lightpink"];' + print_plugins(self.abusive_plugins())
- self.dump_list(self.list('incomplete'))
+ # run through again, this time showing the relations + print '\t/* dependencies' + print '\t * exteranl ones that don\'t have nodes get colored to the following' + print '\tnode[fillcolor="powderblue"];' + for name in self.plugins.keys(): + plugin = self.plugins[name] + node, label = node_label(plugin) + for dep in plugin.depends: + dep = dep.replace('-', '_') + print '\t%s -> %s;' % (node, dep) + # create our main instance + # load all our plugin data
+ opts, args = getopt.getopt(sys.argv[1:], shortopts, longopts) + except getopt.error, msg: + if o in ('-a', '--abusive-plugins'): + pp.print_names(pp.abusive_plugins()) + elif o == '--dependency-graph': + elif o in ('-D', '--dist-dirs'): + elif o in ('-d', '--default-plugins'): + pp.print_names(pp.default_plugins()) + elif o in ('-h', '--help'): + elif o in ('-i', '--incomplete-plugins'): + pp.print_names(pp.incomplete_plugins()) + elif o in ('-p', '--plugin'): if __name__ == "__main__":