1 """Commands for listing TurboGears default and extension packages info"""
2
3 try:
4 from email.parser import Parser
5 except ImportError:
6 from email.Parser import Parser
7
8 import pkg_resources
9
10 entrypoints = {"tg-admin Commands" : "turbogears.command",
11 "Template Engines" : "python.templating.engines",
12 "Widget Packages" : "turbogears.widgets",
13 "TurboGears Extensions" : "turbogears.extensions",
14 "Identity Providers" : "turbogears.identity.provider",
15 "Visit Managers" : "turbogears.visit.manager",
16 "Toolbox Gadgets" : "turbogears.toolboxcommand"}
17
18 parsestr = Parser().parsestr
19
21 """Retrieve parsed package info from distribution."""
22 return parsestr(distribution.get_metadata('PKG-INFO'))
23
24
26 """Retrieve URL from distribution."""
27 try:
28 info = retrieve_pkg_info(distribution)
29 except Exception:
30 url = None
31 else:
32 url = info['Home-page'] or info['Url'] or info['Download-Url']
33 return url
34
35
45
46
48 """Retrieve default and extension packages info."""
49 format = with_links and add_link or str
50
51 packages = [format(pkg) for pkg in pkg_resources.require("Turbogears")]
52
53 plugins = {}
54 for name, pointname in entrypoints.items():
55 plugins[name] = ["%s (%s)" % (entrypoint.name, format(entrypoint.dist))
56 for entrypoint in pkg_resources.iter_entry_points(pointname)]
57 return packages, plugins
58
59
61 """Shows version info for debugging."""
62
63 desc = "Show version info"
64
67
69 print """TurboGears Complete Version Information
70
71 TurboGears requires:
72 """
73 packages, plugins = retrieve_info()
74 for p in packages:
75 print '*', p
76 for name, pluginlist in plugins.items():
77 print "\n", name, "\n"
78 for plugin in pluginlist:
79 print '*', plugin
80