dbrtools/dbr/help.py
branchDBRToolsDev
changeset 283 398d483e91bb
parent 179 eab8a264a833
equal deleted inserted replaced
245:fd0a8d235c70 283:398d483e91bb
    12 #
    12 #
    13 # Description:
    13 # Description:
    14 # DBR help - displays the DBR help
    14 # DBR help - displays the DBR help
    15 
    15 
    16 import sys
    16 import sys
       
    17 import os
       
    18 import re
    17 
    19 
    18 def main():
    20 def main():
    19   args = sys.argv
    21   args = sys.argv
    20   run(args)
    22   run(args)
    21 
    23 
    24       try:
    26       try:
    25         tool = __import__(args[0])
    27         tool = __import__(args[0])
    26         tool.help()
    28         tool.help()
    27       except ImportError:
    29       except ImportError:
    28         print "No help on %s\n" % args[0]
    30         print "No help on %s\n" % args[0]
    29         usage()
    31         getsummary()
    30     else:
    32     else:
    31       usage()
    33       getsummary()
       
    34 
       
    35 def getsummary():
       
    36   debug = 0
       
    37 
       
    38   print "Usage:"
       
    39   modules = os.listdir(os.path.join(os.path.dirname(sys.argv[0]),'dbr'))
       
    40   for module in sorted(modules):
       
    41     modname = re.match('(.+)\.py$',module)
       
    42     if(modname):
       
    43       module = modname.group(1)
       
    44       try:
       
    45         tool = __import__(module)
       
    46         str = tool.summary()
       
    47         print "\tdbr %s\t- %s" %(module, str)
       
    48       except ImportError:
       
    49         if(debug):
       
    50           print "Couldn't import %s" % module
       
    51       except AttributeError:
       
    52         if(debug):
       
    53           print "Couldn't find summary in %s" % module
       
    54       except NameError: #if it doesn't work...
       
    55         if(debug):
       
    56           print "%s looks broken" % module
       
    57       except SyntaxError: #if it doesn't work...
       
    58         if(debug):
       
    59           print "%s looks broken" % module
       
    60 
       
    61       
       
    62 
       
    63 
       
    64 
       
    65 def oldusage():
    32     
    66     
    33 def usage():    
       
    34     print "Usage:"
    67     print "Usage:"
    35     print "\tdbr intro\t- basic introduction\n"
    68     print "\tdbr intro\t- basic introduction\n"
    36 
    69 
    37     print "\tdbr getenv\t- installs a baseline NOT IMPLEMENTED"
    70     print "\tdbr getenv\t- installs a baseline NOT IMPLEMENTED"
    38     print "\tdbr checkenv\t- Checks current environment"
    71     print "\tdbr checkenv\t- Checks current environment"
    45     print "\tdbr removepatch\t- removes a patch"
    78     print "\tdbr removepatch\t- removes a patch"
    46     print "\tdbr listpatches\t- lists patches"
    79     print "\tdbr listpatches\t- lists patches"
    47     print ""
    80     print ""
    48     print "\tdbr help - help"
    81     print "\tdbr help - help"
    49     
    82     
       
    83 
       
    84 def summary():
       
    85   return "Displays the help"
       
    86 
    50 def help():
    87 def help():
    51   print "No help available!"    
    88   getsummary()