CMS 3D CMS Logo

Public Member Functions | Static Public Attributes

HTMLExport::HTMLExportStatic Class Reference

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

List of all members.

Public Member Functions

def __init__
def export
def produce

Static Public Attributes

tuple file_types = ('html',)
dictionary options_types = {}
string plugin_name = 'HTML Export (Static)'

Detailed Description

Definition at line 751 of file HTMLExport.py.


Constructor & Destructor Documentation

def HTMLExport::HTMLExportStatic::__init__ (   self)

Definition at line 755 of file HTMLExport.py.

00756                     :
00757     FileExportPlugin.__init__(self)
  

Member Function Documentation

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

Definition at line 1023 of file HTMLExport.py.

01024                                          :
01025     #if not data.process():
01026     #  raise "HTMLExport requires a cms.Process object"
01027     
01028     html = self.produce(data)
01029     
01030     if filetype=='html':
01031       htmlfile = open(filename,'w')
01032       htmlfile.write(html)
01033       htmlfile.close()
def HTMLExport::HTMLExportStatic::produce (   self,
  data 
)

Definition at line 758 of file HTMLExport.py.

00759                         :
00760     def elem(elemtype,innerHTML='',html_class='',**kwargs):
00761       if html_class:
00762         kwargs['class']=html_class
00763       return "<%s %s>%s</%s>\n" % (elemtype,' '.join(['%s="%s"'%(k,v) for k,v in kwargs.items()]),innerHTML,elemtype)
00764     def div(innerHTML='',html_class='',**kwargs):
00765       return elem('div',innerHTML,html_class,**kwargs)
00766     
00767     def htmlPSet(pset):
00768       def linkInputTag(tag):
00769         inputtag=''
00770         if isinstance(tag,typ.InputTag):
00771           inputtag = tag.pythonValue()
00772         else:
00773           inputtag = tag
00774         if len(str(tag))==0:
00775           inputtag = '""'
00776         return inputtag
00777 
00778       pset_items_html=''
00779       for k,v in pset.items():
00780         if isinstance(v,mix._ParameterTypeBase):
00781           if isinstance(v,mix._SimpleParameterTypeBase):
00782             item_class='other'
00783             if isinstance(v,typ.bool):
00784               item_class='bool'
00785             if isinstance(v,typ.double):
00786               item_class='double'
00787             if isinstance(v,typ.string):
00788               item_class='string'
00789             if isinstance(v,(typ.int32, typ.uint32, typ.int64, typ.uint64)):
00790               item_class='int'
00791             pset_items_html+=elem('tr',
00792               elem('td',k,'param-name')
00793              +elem('td',v.pythonTypeName(),'param-class')
00794              +elem('td',v.pythonValue(),'param-value-%s'%item_class),
00795              'pset-item'
00796             )
00797           if isinstance(v,typ.InputTag):
00798             pset_items_html+=elem('tr',
00799               elem('td',k,'param-name')
00800              +elem('td',v.pythonTypeName(),'param-class')
00801              +elem('td',linkInputTag(v),'param-value-inputtag'),
00802              'pset-item'
00803             )
00804           if isinstance(v,typ.PSet):
00805             pset_html = ''
00806             if len(v.parameters_())==0:
00807               pset_items_html+=elem('tr',
00808                 elem('td',k,'param-name')
00809                +elem('td',v.pythonTypeName(),'param-class')
00810                +elem('td','(empty)','label'),
00811                'pset-item'
00812               )
00813             else:
00814               pset_items_html+=elem('tr',
00815                 elem('td',k,'param-name')
00816                +elem('td',v.pythonTypeName(),'param-class')
00817                +elem('td',htmlPSet(v.parameters_())),
00818                'pset-item'
00819               )
00820           if isinstance(v,mix._ValidatingListBase):
00821             list_html = ''
00822             if len(v)==0:
00823               list_html = elem('li','(empty)','label')
00824             else:
00825               if isinstance(v,typ.VInputTag):
00826                 for vv in v:
00827                   list_html += elem('li',linkInputTag(vv),'param-value-inputtag pset-list-item')
00828               elif isinstance(v,typ.VPSet):
00829                 for vv in v:
00830                   list_html += elem('li',htmlPSet(vv.parameters_()),'pset-list-item')
00831               else:
00832                 item_class='other'
00833                 if isinstance(v,typ.vbool):
00834                   item_class='bool'
00835                 if isinstance(v,typ.vdouble):
00836                   item_class='double'
00837                 if isinstance(v,typ.vstring):
00838                   item_class='string'
00839                 if isinstance(v,(typ.vint32,typ.vuint32,typ.vint64,typ.vuint64)):
00840                   item_class='int'
00841                 for vv in v:
00842                   if len(str(vv))==0:
00843                     vv = "''"
00844                   list_html += elem('li',vv,'pset-list-item param-value-%s'%item_class)
00845             pset_items_html+=elem('tr',
00846               elem('td',k,'param-name')
00847              +elem('td','%s[%s]'%(v.pythonTypeName(),len(v)),'param-class')
00848              +elem('td',elem('ol',list_html,'pset-list')),
00849              'pset-item'
00850             )
00851               
00852             
00853       return elem('table',pset_items_html,'pset')
00854       
00855     def htmlModule(mod):
00856       mod_label_html = div(elem('a',data.label(mod),'title',name=data.label(mod)),'module_label '+data.type(mod),onClick='return toggleModuleVisible(\'%s\')'%('mod_%s'%(data.label(mod))))
00857       
00858       mod_table = elem('table',
00859         elem('tr',elem('td','Type','label')+elem('td',data.type(mod)))
00860        +elem('tr',elem('td','Class','label')+elem('td',data.classname(mod))),
00861         'module_table')
00862         
00863       mod_pset = htmlPSet(mod.parameters_())
00864       
00865       mod_content_html = div(mod_table+mod_pset,'module_area',id='mod_%s'%data.label(mod))
00866       return div(mod_label_html+mod_content_html,'module',id='module_'+data.label(mod))
00867       
00868     def htmlPathRecursive(p):
00869       children = data.children(p)
00870       if children:
00871         seq_name='Sequence'
00872         if isinstance(p,sqt.Path):
00873           seq_name='Path'
00874         if isinstance(p,sqt.EndPath):
00875           seq_name='EndPath'
00876         seq_label_html = div(seq_name+' '+elem('span',data.label(p),'title')+' '+elem('span','[%s children hidden]'%len(children),'hidden',id='seq_hidden_%s'%data.label(p)),'sequence_label',onClick='return toggleSequenceVisible(\'%s\')'%data.label(p),id='seq_label_%s'%data.label(p))
00877         seq_inner_content_html = ''.join([htmlPathRecursive(c) for c in children])
00878         seq_content_html = div(seq_inner_content_html,'sequence_area',id='seq_%s'%data.label(p))
00879         return div(seq_label_html+seq_content_html,'sequence')
00880       else:
00881         return htmlModule(p)
00882         
00883     toplevel={}
00884     
00885     
00886     
00887     filter_html = elem('span','Filter  '+
00888                         elem('input',type='text',width=50,onkeyup="return doFilter();",id='input-filter'),
00889                         'right label')
00890     
00891     header_html = div('Config File Visualisation'+filter_html,'header')
00892     
00893     if data.process():
00894       for tlo in data.children(data.topLevelObjects()[0]):
00895         children = data.children(tlo)
00896         if children:
00897           toplevel[tlo._label]=children    
00898       path_html=''
00899       if 'paths' in toplevel:
00900         for path in toplevel['paths']:
00901           path_html += div(htmlPathRecursive(path),'path')
00902     
00903       file_html = div(elem('span','Process:')
00904                    +elem('span',data.process().name_(),'title')
00905                    +elem('span',data._filename,'right'),
00906                 'file')
00907       head_html = elem('head',elem('title',data.process().name_()))
00908     else:
00909       toplevel['sequences']=[]
00910       toplevel['paths']=[]
00911       toplevel['modules']=[]
00912       for tlo in data.topLevelObjects():
00913         if data.type(tlo)=='Sequence':
00914           toplevel['sequences']+=[tlo]
00915         if data.type(tlo)=='Path':
00916           toplevel['paths']+=[tlo]
00917         if data.type(tlo) in ('EDAnalyzer','EDFilter','EDProducer','OutputModule'):
00918           toplevel['modules']+=[tlo]
00919       
00920       path_html = ''
00921       sequence_html = ''
00922       module_html = ''
00923       for path in toplevel['paths']:
00924         path_html += div(htmlPathRecursive(path),'path')
00925       for sequence in toplevel['sequences']:
00926         sequence_html += htmlPathRecursive(sequence)
00927       for module in toplevel['modules']:
00928         module_html += htmlModule(module)
00929       file_html = div(elem('span',data._filename,'right'),'file')
00930       path_html += sequence_html
00931       path_html += module_html
00932       head_html = elem('head',elem('title',data._filename))
00933     footer_html = div('gordon.ball','footer')
00934     
00935     
00936     
00937     style_html = elem('style',
00938     """
00939     .title{font-weight:bold}
00940     .label{color:grey}
00941     .header{position:fixed;top:0px;left:0px;width:100%;background:#33cc00;font-weight:bold;font-size:120%}
00942     .footer{position:fixed;bottom:0px;left:0px;width:100%;background:#33cc00;text-align:right}
00943     .canvas{padding:40px 10px 40px 10px}
00944     .file{position:relative;background:#bbb;width:100%;padding-left:5px}
00945     .right{position:absolute;right:5px}
00946     .sequence{border:1px solid #aaa}
00947     .sequence:hover{border 1px solid #00ffff}
00948     .sequence_label{background:lightskyblue;padding-left:5px}
00949     .sequence_label:hover{background:#fff}
00950     .sequence_label_hidden{background:grey;padding-left:5px}
00951     .sequence_area{padding:5px 0px 5px 5px}
00952     .edproducer{border:1px solid red;background-image:url('edproducer.png');background-position:center left;background-repeat:no-repeat;padding:0px 0px 0px 40px}
00953     .edfilter{border:1px solid green;background-image:url('edfilter.png');background-position:center left;background-repeat:no-repeat;padding:0px 0px 0px 40px}
00954     .edanalyzer{border:1px solid blue;background-image:url('edanalyzer.png');background-position:center left;background-repeat:no-repeat;padding:0px 0px 0px 40px}
00955     .outputmodule{border:1px solid green;background-image:url('outputmodule.png');background-position:center left;background-repeat:no-repeat;padding:0px 0px 0px 40px}
00956     .module{}
00957     .module_label:hover{background:#ccc;position:relative}
00958     .module_area{display:none;padding:5px 0px 15px 15px;background:beige}
00959     .pset{border-spacing:10px 1px;border:1px solid black}
00960     .pset-item{}
00961     .pset-list{list-style-type:none;margin:0px;padding:2px 2px 2px 2px;border:1px solid grey}
00962     .pset-list-item{border-top:1px solid lightgrey;border-bottom:1px solid lightgrey}
00963     .param-name{font-weight:bold}
00964     .param-class{color:grey}
00965     .param-value-int{font-family:courier;color:blue}
00966     .param-value-double{font-family:courier;color:purple}
00967     .param-value-string{font-family:courier;color:brown}
00968     .param-value-bool{font-family:courier;color:#f0f}
00969     .param-value-inputtag{font-family:courier;color:red}
00970     .param-value-other{font-family:courier}
00971     .path{}
00972     .hidden{display:none}
00973     """,
00974     type='text/css')
00975     
00976     script_html = elem('script',
00977     """
00978     function toggleModuleVisible(id) {
00979       var elem = document.getElementById(id);
00980       if (elem.style.display=='block') {
00981         elem.style.display='none';
00982       } else {
00983         elem.style.display='block';      
00984       }
00985     }
00986     
00987     function toggleSequenceVisible(id) {
00988       var area_elem = document.getElementById('seq_'+id);
00989       var hidden_elem = document.getElementById('seq_hidden_'+id);
00990       var label_elem = document.getElementById('seq_label_'+id);
00991       if (area_elem.style.display=='none') {
00992         area_elem.style.display='block';      
00993         hidden_elem.style.display='none';
00994         label_elem.className = 'sequence_label';
00995       } else {
00996         area_elem.style.display='none';
00997         hidden_elem.style.display='block';
00998         label_elem.className = 'sequence_label_hidden';
00999       }
01000     }
01001     
01002     function doFilter() {
01003       var text = document.getElementById('input-filter').value;
01004       var regex = new RegExp(text);
01005       for (var i=0;i<document.all.length;i++) {
01006         if (document.all(i).id.substr(0,7)=="module_") {
01007           var elem = document.all(i);
01008           var elem_name = elem.id.substr(7);
01009           if (regex.test(elem_name)) {
01010             elem.style.display='block';
01011           } else {
01012             elem.style.display='none';
01013           }
01014         }
01015       }
01016     }
01017     """,
01018     type='text/javascript')
01019     
01020     body_html = elem('body',script_html+header_html+footer_html+div(file_html+path_html,'canvas'))
01021     
01022     return elem('html',head_html+style_html+body_html)
    

Member Data Documentation

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

Definition at line 754 of file HTMLExport.py.

Definition at line 752 of file HTMLExport.py.

string HTMLExport::HTMLExportStatic::plugin_name = 'HTML Export (Static)' [static]

Definition at line 753 of file HTMLExport.py.