test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
cfg-viewer Namespace Reference

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 = ""
 

Function Documentation

def cfg-viewer.computeConfigs (   args)

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

References reco.if().

Referenced by main().

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

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

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

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

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

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

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

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

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

1265 def JSONFormat(d):
1266  import json
1267  return json.dumps(d)
def JSONFormat
Definition: cfg-viewer.py:1264
def cfg-viewer.listBase (   VList)

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

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

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

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

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

Variable Documentation

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
Initial value:
1 = os.path.abspath(
2  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.

tuple cfg-viewer.process = cms.Process('%(n)s')

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.