Skip to content
Snippets Groups Projects
Commit 8e8ad965 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Merge branch 'componenthelp' into 'master'

extract gaudiComponentHelp from hive

gaudiComponentHelp is a tool to print a help message for a given component.

Fixes GAUDI-1091.

See merge request !17
parents 850d8016 deb66af0
No related branches found
No related tags found
No related merge requests found
......@@ -569,6 +569,16 @@ class Configurable( object ):
return props
def getPropertiesWithDescription( self ):
"""Get all properties with their description string as { name : (value, desc) }."""
props = {}
for name, proxy in self._properties.items():
try:
props[ name ] = ( proxy.__get__( self ), proxy.__doc__)
except AttributeError:
props[ name ] = ( Configurable.propertyNoValue, proxy.__doc__)
return props
def getValuedProperties( self ):
props = {}
for name, proxy in self._properties.items():
......
#!/usr/bin/env python
"""
Print help messages for gaudi components
"""
from Gaudi import Configuration
import Configurables
import os, sys
if __name__ == "__main__":
from optparse import OptionParser
parser = OptionParser(prog = os.path.basename(sys.argv[0]), usage = "%prog [options] ")
parser.add_option("-l", "--list", action="store_true", dest="list", default = False, help="list all available components.")
parser.add_option("-n", "--name", action="store", dest="name", help="dump all info about component of given name.")
parser.set_defaults(root = os.path.join("..","python"))
opts, args = parser.parse_args()
if len(args)!=0 :
parser.print_help()
sys.exit(1)
cfgDb = Configuration.cfgDb
if opts.list:
print "Available components:\n%s" %(21*"=")
for item in sorted(cfgDb):
print " %s (from %s)" %(item, cfgDb[item]["lib"])
sys.exit()
elif opts.name:
name = opts.name
if name not in cfgDb:
print "Component %s not found." %(name)
sys.exit()
print "\nDumping component information for %s:\n%s" %(name, (35 + len(name))*"=")
print " Library: %s" %(cfgDb[name]["lib"])
print " Package: %s" %(cfgDb[name]["package"])
print "\nProperties:\n%s" %(11*"-")
try:
properties = getattr(Configurables,name)().getPropertiesWithDescription()
except AttributeError:
print " Not a configurable component. No properties to show."
sys.exit()
for label, (value, desc) in sorted(properties.iteritems()):
print (" %s\t : %s\t (%s) " %(label, value, str(desc).replace("None", " no description ") )).expandtabs(30)
sys.exit()
else:
parser.print_help()
sys.exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment