![]() |
![]() |
Classes | |
class | html |
class | server |
class | unscheduled |
class | visitor |
Functions | |
def | computeConfigs |
def | doTypes |
def | getParameters |
def | getParamSeqDict |
def | JSONFormat |
def | listBase |
def | main |
Variables | |
string | action = "store_true" |
default = False, | |
tuple | distBaseDirectory |
tuple | distBinaryBaseDirectory = os.path.join(baseDirectory,"dist") |
list | doesNotExist = [x for x in args if not os.path.exists(x)] |
string | help = "Print minimal messages to stdout" |
string | helper_dir = "cfgViewerJS" |
tuple | parser = OptionParser(usage="%prog <cfg-file> ") |
tuple | process = cms.Process('%(n)s') |
recurse = opts._recurse | |
string | s = "" |
def cfg-viewer::computeConfigs | ( | args | ) |
Definition at line 1383 of file cfg-viewer.py.
01384 : 01385 pyList=[] 01386 for x in args: 01387 if(os.path.isdir(x)): 01388 # get all .py files. 01389 allItems = os.listdir(x) 01390 py = [os.path.join(x,y) for y in allItems if y.endswith(".py")] 01391 pyList.extend(computeConfigs(py)) 01392 if(recurse): 01393 # print "recurse" 01394 # if we want to recurse, we look for everything 01395 dirs = [] 01396 for y in os.listdir(x): 01397 path = os.path.join(x,y) 01398 if(os.path.isdir(path)): 01399 pyList.extend(computeConfigs([os.path.join(path,z) 01400 for z in os.listdir(path)])) 01401 elif(x.endswith(".py")): 01402 pyList.append(x) 01403 return pyList 01404 01405 recurse=False
def cfg-viewer::doTypes | ( | spec, | |
generic | |||
) |
Definition at line 1261 of file cfg-viewer.py.
def cfg-viewer::getParameters | ( | parameters | ) |
Definition at line 438 of file cfg-viewer.py.
Referenced by LMFUnique::setByID().
00439 : 00440 all =[] 00441 if(not parameters): 00442 return [] 00443 for (name,valType) in parameters.iteritems(): 00444 theT= (valType.configTypeName() if( 00445 hasattr(valType,"configTypeName")) else "").split(" ",1)[-1] 00446 temp = re.sub("<|>|'", "", str(type(valType))) 00447 generic, spec = temp.split(".")[-2:] 00448 doTypes(spec,generic) 00449 theList=[name] 00450 if(isinstance(valType,cms._Parameterizable)): 00451 theList.append(getParameters(valType.parameters_())) 00452 elif(isinstance(valType,cms._ValidatingListBase)): 00453 theList.append(listBase(valType)) 00454 else: 00455 if(isinstance(valType,cms._SimpleParameterTypeBase)): 00456 value = valType.configValue() 00457 else: 00458 try: 00459 value = valType.pythonValue() 00460 except: 00461 value = valType 00462 theList.append(value) 00463 if(theT != "double" and theT !="int" and type(valType)!= str): 00464 if(not valType.isTracked()): 00465 theList.append("untracked") 00466 theList.append(theT) 00467 all.append(theList) 00468 return all
def cfg-viewer::getParamSeqDict | ( | params, | |
fil, | |||
typ, | |||
oType | |||
) |
Definition at line 514 of file cfg-viewer.py.
def cfg-viewer::JSONFormat | ( | d | ) |
Definition at line 1264 of file cfg-viewer.py.
def cfg-viewer::listBase | ( | VList | ) |
Definition at line 469 of file cfg-viewer.py.
00470 : 00471 # we have a list of things.. 00472 #loop around the list get parameters of inners. 00473 #Since ValidatingListBases "*usually* have the same types 00474 #throughout, just test first --is this a rule? 00475 # Find out and if needed move these ifs to the loop. 00476 if(not VList):return "" 00477 first = VList[0] 00478 if(isinstance(first,cms._Parameterizable)or 00479 isinstance(first,cms._ValidatingListBase)): 00480 anotherVList=False 00481 if(isinstance(first,cms._ValidatingListBase)): 00482 anotherVList=True 00483 outerList=[] 00484 for member in VList: 00485 if(member.hasLabel_()): 00486 name = member.label() 00487 else: 00488 name = member.configTypeName() 00489 innerList=[name] 00490 if(not anotherVList): 00491 innerList.append(getParameters(member.parameters_())) 00492 else: 00493 innerList.append(listBase(member)) 00494 temp = re.sub("<|>|'", "", str(type(member))) 00495 generic, spec = temp.split(".")[-2:] 00496 doTypes(spec,generic) 00497 innerList.append(spec) 00498 outerList.append(innerList) 00499 return outerList 00500 elif(isinstance(first,cms._SimpleParameterTypeBase)): 00501 return ",".join(i.configValue() for i in VList) 00502 elif(isinstance(first,cms._ParameterTypeBase)): 00503 return ",".join(i.pythonValue() for i in VList) 00504 else: 00505 #Most things should at least be _ParameterTypeBase, adding this jic 00506 try: 00507 outcome = ",".join(str(i) for i in VList) 00508 return outcome 00509 except: 00510 return "Unknown types" 00511 00512 00513 dictFeatures=["Parameters", "Type", "File", "oType"] # Used to enforce dictionary in datafiles.
def cfg-viewer::main | ( | args, | |
helperDir, | |||
htmlFile, | |||
quiet, | |||
noServer | |||
) |
Definition at line 1406 of file cfg-viewer.py.
01407 : 01408 dirName = "%s-cfghtml" 01409 # new dir format 01410 # cfgViewer.html 01411 # patTuple-html/ 01412 # lower.html 01413 # cfgViewerHelper/ 01414 # -json files 01415 pyconfigs = computeConfigs(args) 01416 tmpte = '<li><a href ="%(n)s">%(s)s</a></li>' 01417 lis="" 01418 found =0 01419 for x in pyconfigs: 01420 print "-----" 01421 # for every config file 01422 name = os.path.split(x)[1].replace(".py", "") 01423 dirN = dirName%(name) 01424 # we have the dir name now we only need 01425 # now we have thedir for everything to be stored in 01426 #htmlF = opts._htmlfile 01427 #htmldir= os.path.split(htmlFile)[0] 01428 #baseDir = os.path.join(htmldir,dirN) 01429 baseDir = dirN 01430 dirCreated = False 01431 if not os.path.exists(baseDir): 01432 os.makedirs(baseDir) 01433 dirCreated = True 01434 # base Dir under where the htmlFile will be. 01435 lowerHTML = os.path.join(baseDir, htmlFile) 01436 helper = os.path.join(helperDir, "") 01437 helperdir = os.path.join(baseDir, helper, "") 01438 if not os.path.exists(helperdir): 01439 os.makedirs(helperdir) 01440 print "Calculating", x 01441 try: 01442 u = unscheduled(x, lowerHTML, quiet, helper,helperdir) 01443 except Exception as e: 01444 print "File %s is a config file but something went wrong"%(x) 01445 print "%s"%(e) 01446 continue 01447 print "Finished with", x 01448 if(not u._computed and dirCreated): 01449 # remove any directories created 01450 shutil.rmtree(baseDir) 01451 continue 01452 found +=1 01453 lis += tmpte%{"n":os.path.join(dirN,htmlFile),"s":name} 01454 with open("index.html", 'w')as f: 01455 f.write(""" 01456 <!DOCTYPE html> 01457 <html> 01458 <head> 01459 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 01460 <title>cfg-browser</title> 01461 </head> 01462 <body> 01463 <h4>Configuration files:</h4> 01464 <ul> 01465 %s 01466 </ul> 01467 </body> 01468 </html> 01469 """%("".join(lis))) 01470 if(found == 0): 01471 print "Sorry, no configuration files were found." 01472 return 01473 print "Finished dealing with configuration files." 01474 server("cfgServer.py") 01475 if(not noServer): 01476 print "-----" 01477 print "Starting the python server.." 01478 import cfgServer 01479 cfgServer.main() 01480
string cfg-viewer::action = "store_true" |
Definition at line 1486 of file cfg-viewer.py.
cfg-viewer::default = False, |
Definition at line 1495 of file cfg-viewer.py.
tuple cfg-viewer::distBaseDirectory |
00001 os.path.abspath( 00002 os.path.join(os.path.dirname(__file__),".."))
Definition at line 1503 of file cfg-viewer.py.
tuple cfg-viewer::distBinaryBaseDirectory = os.path.join(baseDirectory,"dist") |
Definition at line 1522 of file cfg-viewer.py.
list cfg-viewer::doesNotExist = [x for x in args if not os.path.exists(x)] |
Definition at line 1527 of file cfg-viewer.py.
string cfg-viewer::help = "Print minimal messages to stdout" |
Definition at line 1487 of file cfg-viewer.py.
string cfg-viewer::helper_dir = "cfgViewerJS" |
Definition at line 1499 of file cfg-viewer.py.
tuple cfg-viewer::parser = OptionParser(usage="%prog <cfg-file> ") |
Definition at line 1484 of file cfg-viewer.py.
Definition at line 1283 of file cfg-viewer.py.
cfg-viewer::recurse = opts._recurse |
Definition at line 1526 of file cfg-viewer.py.
string cfg-viewer::s = "" |
Definition at line 1529 of file cfg-viewer.py.