CMS 3D CMS Logo

Classes | Functions
cfg-viewer Namespace Reference

Classes

class  html
 
class  server
 
class  unscheduled
 
class  visitor
 

Functions

def computeConfigs (args)
 
def doTypes (spec, generic)
 
def getParameters (parameters)
 
def getParamSeqDict (params, fil, typ, oType)
 
def JSONFormat (d)
 
def listBase (VList)
 
def main (args, helperDir, htmlFile, quiet, noServer)
 

Function Documentation

def cfg-viewer.computeConfigs (   args)

Definition at line 1383 of file cfg-viewer.py.

References reco.if().

Referenced by main().

1383 def computeConfigs(args):
1384  pyList=[]
1385  for x in args:
1386  if(os.path.isdir(x)):
1387  # get all .py files.
1388  allItems = os.listdir(x)
1389  py = [os.path.join(x,y) for y in allItems if y.endswith(".py")]
1390  pyList.extend(computeConfigs(py))
1391  if(recurse):
1392  # print "recurse"
1393  # if we want to recurse, we look for everything
1394  dirs = []
1395  for y in os.listdir(x):
1396  path = os.path.join(x,y)
1397  if(os.path.isdir(path)):
1398  pyList.extend(computeConfigs([os.path.join(path,z)
1399  for z in os.listdir(path)]))
1400  elif(x.endswith(".py")):
1401  pyList.append(x)
1402  return pyList
1403 
1404 recurse=False
1405 
def computeConfigs(args)
Definition: cfg-viewer.py:1383
if(dp >Float(M_PI)) dp-
def cfg-viewer.doTypes (   spec,
  generic 
)

Definition at line 1261 of file cfg-viewer.py.

Referenced by cfg-viewer.unscheduled._checkType(), cfg-viewer.visitor._doModules(), cfg-viewer.visitor.enter(), getParameters(), and listBase().

1261 def doTypes(spec, generic):
1262  genericTypes[spec] = generic
1263 
def doTypes(spec, generic)
Definition: cfg-viewer.py:1261
def cfg-viewer.getParameters (   parameters)

Definition at line 438 of file cfg-viewer.py.

References doTypes(), reco.if(), listBase(), split, and harvestTrackValidationPlots.str.

Referenced by cfg-viewer.visitor._doModules(), cfg-viewer.unscheduled._doNonSequenceType(), listBase(), and LMFUnique.setByID().

438 def getParameters(parameters):
439  all =[]
440  if(not parameters):
441  return []
442  for (name,valType) in parameters.iteritems():
443  theT= (valType.configTypeName() if(
444  hasattr(valType,"configTypeName")) else "").split(" ",1)[-1]
445  temp = re.sub("<|>|'", "", str(type(valType)))
446  generic, spec = temp.split(".")[-2:]
447  doTypes(spec,generic)
448  theList=[name]
449  if(isinstance(valType,cms._Parameterizable)):
450  theList.append(getParameters(valType.parameters_()))
451  elif(isinstance(valType,cms._ValidatingListBase)):
452  theList.append(listBase(valType))
453  else:
454  if(isinstance(valType,cms._SimpleParameterTypeBase)):
455  value = valType.configValue()
456  else:
457  try:
458  value = valType.pythonValue()
459  except:
460  value = valType
461  theList.append(value)
462  if(theT != "double" and theT !="int" and type(valType)!= str):
463  if(not valType.isTracked()):
464  theList.append("untracked")
465  theList.append(theT)
466  all.append(theList)
467  return all
468 
def getParameters(parameters)
Definition: cfg-viewer.py:438
def doTypes(spec, generic)
Definition: cfg-viewer.py:1261
if(dp >Float(M_PI)) dp-
def listBase(VList)
Definition: cfg-viewer.py:469
double split
Definition: MVATrainer.cc:139
def cfg-viewer.getParamSeqDict (   params,
  fil,
  typ,
  oType 
)

Definition at line 514 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor._doModules(), cfg-viewer.unscheduled._doNonSequenceType(), cfg-viewer.unscheduled._doSequenceTypes(), cfg-viewer.visitor.enter(), and cfg-viewer.visitor.leave().

514 def getParamSeqDict(params, fil, typ, oType):
515  d={}
516  d[dictFeatures[0]] = params
517  d[dictFeatures[1]] = typ
518  d[dictFeatures[2]] = fil
519  d[dictFeatures[3]] = oType
520  return d
521 
def getParamSeqDict(params, fil, typ, oType)
Definition: cfg-viewer.py:514
def cfg-viewer.JSONFormat (   d)
def cfg-viewer.listBase (   VList)

Definition at line 469 of file cfg-viewer.py.

References doTypes(), getParameters(), reco.if(), join(), and harvestTrackValidationPlots.str.

Referenced by cfg-viewer.unscheduled._doNonSequenceType(), and getParameters().

469 def listBase(VList):
470  # we have a list of things..
471  #loop around the list get parameters of inners.
472  #Since ValidatingListBases "*usually* have the same types
473  #throughout, just test first --is this a rule?
474  # Find out and if needed move these ifs to the loop.
475  if(not VList):return ""
476  first = VList[0]
477  if(isinstance(first,cms._Parameterizable)or
478  isinstance(first,cms._ValidatingListBase)):
479  anotherVList=False
480  if(isinstance(first,cms._ValidatingListBase)):
481  anotherVList=True
482  outerList=[]
483  for member in VList:
484  if(member.hasLabel_()):
485  name = member.label()
486  else:
487  name = member.configTypeName()
488  innerList=[name]
489  if(not anotherVList):
490  innerList.append(getParameters(member.parameters_()))
491  else:
492  innerList.append(listBase(member))
493  temp = re.sub("<|>|'", "", str(type(member)))
494  generic, spec = temp.split(".")[-2:]
495  doTypes(spec,generic)
496  innerList.append(spec)
497  outerList.append(innerList)
498  return outerList
499  elif(isinstance(first,cms._SimpleParameterTypeBase)):
500  return ",".join(i.configValue() for i in VList)
501  elif(isinstance(first,cms._ParameterTypeBase)):
502  return ",".join(i.pythonValue() for i in VList)
503  else:
504  #Most things should at least be _ParameterTypeBase, adding this jic
505  try:
506  outcome = ",".join(str(i) for i in VList)
507  return outcome
508  except:
509  return "Unknown types"
510 
511 
512 dictFeatures=["Parameters", "Type", "File", "oType"]
513 # Used to enforce dictionary in datafiles.
def getParameters(parameters)
Definition: cfg-viewer.py:438
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def doTypes(spec, generic)
Definition: cfg-viewer.py:1261
if(dp >Float(M_PI)) dp-
def listBase(VList)
Definition: cfg-viewer.py:469
def cfg-viewer.main (   args,
  helperDir,
  htmlFile,
  quiet,
  noServer 
)

Definition at line 1406 of file cfg-viewer.py.

References computeConfigs(), reco.if(), join(), and python.rootplot.root2matplotlib.replace().

1406 def main(args,helperDir,htmlFile,quiet, noServer):
1407  dirName = "%s-cfghtml"
1408  # new dir format
1409  # cfgViewer.html
1410  # patTuple-html/
1411  # lower.html
1412  # cfgViewerHelper/
1413  # -json files
1414  pyconfigs = computeConfigs(args)
1415  tmpte = '<li><a href ="%(n)s">%(s)s</a></li>'
1416  lis=""
1417  found =0
1418  for x in pyconfigs:
1419  print "-----"
1420  # for every config file
1421  name = os.path.split(x)[1].replace(".py", "")
1422  dirN = dirName%(name)
1423  # we have the dir name now we only need
1424  # now we have thedir for everything to be stored in
1425  #htmlF = opts._htmlfile
1426  #htmldir= os.path.split(htmlFile)[0]
1427  #baseDir = os.path.join(htmldir,dirN)
1428  baseDir = dirN
1429  dirCreated = False
1430  if not os.path.exists(baseDir):
1431  os.makedirs(baseDir)
1432  dirCreated = True
1433  # base Dir under where the htmlFile will be.
1434  lowerHTML = os.path.join(baseDir, htmlFile)
1435  helper = os.path.join(helperDir, "")
1436  helperdir = os.path.join(baseDir, helper, "")
1437  if not os.path.exists(helperdir):
1438  os.makedirs(helperdir)
1439  print "Calculating", x
1440  try:
1441  u = unscheduled(x, lowerHTML, quiet, helper,helperdir)
1442  except Exception as e:
1443  print "File %s is a config file but something went wrong"%(x)
1444  print "%s"%(e)
1445  continue
1446  print "Finished with", x
1447  if(not u._computed and dirCreated):
1448  # remove any directories created
1449  shutil.rmtree(baseDir)
1450  continue
1451  found +=1
1452  lis += tmpte%{"n":os.path.join(dirN,htmlFile),"s":name}
1453  with open("index.html", 'w')as f:
1454  f.write("""
1455 <!DOCTYPE html>
1456 <html>
1457  <head>
1458  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
1459  <title>cfg-browser</title>
1460  </head>
1461  <body>
1462  <h4>Configuration files:</h4>
1463  <ul>
1464  %s
1465  </ul>
1466  </body>
1467 </html>
1468  """%("".join(lis)))
1469  if(found == 0):
1470  print "Sorry, no configuration files were found."
1471  return
1472  print "Finished dealing with configuration files."
1473  server("cfgServer.py")
1474  if(not noServer):
1475  print "-----"
1476  print "Starting the python server.."
1477  import cfgServer
1478  cfgServer.main()
1479 
1480 
def main(args, helperDir, htmlFile, quiet, noServer)
Definition: cfg-viewer.py:1406
def replace(string, replacements)
def computeConfigs(args)
Definition: cfg-viewer.py:1383
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
if(dp >Float(M_PI)) dp-