CMS 3D CMS Logo

Public Member Functions | Static Public Attributes

HTMLExport::HTMLExport Class Reference

Inherits FWCore::GuiBrowsers::FileExportPlugin::FileExportPlugin.

List of all members.

Public Member Functions

def __init__
def data_to_json
def export
def module_to_json
def path_to_json
def produce
def pset_to_json

Static Public Attributes

tuple file_types = ('html', )
string plugin_name = 'HTML Export'

Detailed Description

Definition at line 652 of file HTMLExport.py.


Constructor & Destructor Documentation

def HTMLExport::HTMLExport::__init__ (   self)

Definition at line 657 of file HTMLExport.py.

00658                       :
00659         FileExportPlugin.__init__(self)


Member Function Documentation

def HTMLExport::HTMLExport::data_to_json (   self,
  data 
)

Definition at line 671 of file HTMLExport.py.

00672                                 :
00673         cmssw = None
00674         if 'CMSSW_BASE' in os.environ:
00675             cmssw = os.environ['CMSSW_BASE'].split('/')[-1]
00676         elif 'CMSSW_RELEASE_BASE' in os.environ:
00677             cmssw = os.environ['CMSSW_RELEASE_BASE'].split('/')[-1]
00678         result = {'process': {'name': data.process().name_() if data.process() else '(no process)', 'src': data._filename, 'cmssw':cmssw}}
00679         toplevel = data.children(data.topLevelObjects()[0]) if data.process() else data.topLevelObjects()
00680         for tlo in toplevel:
00681             children = data.children(tlo)
00682             label = tlo._label
00683             if label in ('source', 'services'):
00684                 result[label] = [{'class':data.classname(child), 'pset':self.pset_to_json(child.parameters_()), 'type':data.type(child), 'label':data.classname(child)} for child in children]
00685             elif label in ('essources', 'esproducers', 'esprefers'):
00686                 result[label] = [self.module_to_json(data, child) for child in children]
00687             elif label in ('paths', 'endpaths'):
00688                 result[label] = [self.path_to_json(data, child) for child in children]
00689         return json.dumps(result, indent=4)

def HTMLExport::HTMLExport::export (   self,
  data,
  filename,
  filetype 
)

Definition at line 660 of file HTMLExport.py.

00661                                               :
00662         with open(filename, 'w') as f:
00663             f.write(self.produce(data))

def HTMLExport::HTMLExport::module_to_json (   self,
  data,
  module 
)

Definition at line 723 of file HTMLExport.py.

00724                                           :
00725         return {
00726             'label':data.label(module),
00727             'class':data.classname(module),
00728             'file':data.pypath(module),
00729             'line':data.lineNumber(module),
00730             #'package':data.pypackage(module),
00731             'pset':self.pset_to_json(module.parameters_()),
00732             'type':data.type(module),
00733             'uses':data.uses(module),
00734             'usedby':data.usedBy(module),
00735             'memberof':data.foundIn(module)
00736         }

def HTMLExport::HTMLExport::path_to_json (   self,
  data,
  path 
)

Definition at line 737 of file HTMLExport.py.

00738                                       :
00739         children = data.children(path)
00740         if data.isContainer(path):
00741             json_children = [self.path_to_json(data, child) for child in children]
00742             return {'type':data.type(path), 'label':data.label(path), 
00743                     'path':json_children, 'memberof': data.foundIn(path),
00744                     'file': data.pypath(path), 'line': data.lineNumber(path)}
00745                     #'package': data.pypackage(path)}
00746         else:
00747             return self.module_to_json(data, path)
00748             
00749             
00750                             

def HTMLExport::HTMLExport::produce (   self,
  data 
)

Definition at line 664 of file HTMLExport.py.

00665                            :
00666         return PAGE_TEMPLATE % dict(title=data._filename, jquery=get_jquery(),
00667                                     css=CSS_TEMPLATE, js=JS_TEMPLATE, dirname='.',
00668                                     filename=data._filename, json=self.data_to_json(data),
00669                                     cmslogo=CMSLOGO)
00670         
            
def HTMLExport::HTMLExport::pset_to_json (   self,
  pset 
)

Definition at line 690 of file HTMLExport.py.

00691                                 :
00692         result = []
00693         for k, v in pset.items():
00694             typename = v.pythonTypeName().split('.')[-1]
00695             item = {'label': k, 'type': typename}
00696             if not v.isTracked():
00697                 item['untracked'] = True 
00698             if typename == 'PSet':
00699                 item['value'] = self.pset_to_json(v.parameters_())
00700             elif typename == 'VPSet':   
00701                 item['value'] = [self.pset_to_json(vv.parameters_()) for vv in v]
00702                 item['list'] = True
00703             elif typename == 'VInputTag':
00704                 v_it = []
00705                 for vv in v:
00706                    if type(vv) == cms.InputTag:
00707                      v_it.append(vv)
00708                    elif type(vv) == str:
00709                      v_it.append(cms.InputTag(vv))
00710                    else:
00711                       raise "Unsupported type in VInputTag", type(vv)
00712                 item['value'] = [(vv.moduleLabel, vv.productInstanceLabel, vv.processName) for vv in v_it]
00713                 item['list'] = True
00714             elif typename == 'InputTag':
00715                 item['value'] = [v.moduleLabel, v.productInstanceLabel, v.processName]
00716             elif isinstance(v, mix._ValidatingListBase):
00717                 item['value'] = [str(vv) for vv in v]
00718                 item['list'] = True
00719             else:
00720                 item['value'] = v.pythonValue()
00721             result += [item]
00722         return result


Member Data Documentation

tuple HTMLExport::HTMLExport::file_types = ('html', ) [static]

Definition at line 655 of file HTMLExport.py.

string HTMLExport::HTMLExport::plugin_name = 'HTML Export' [static]

Definition at line 654 of file HTMLExport.py.