1 from __future__
import absolute_import
10 import FWCore.ParameterSet.Config
as cms
11 import FWCore.ParameterSet.Modules
as mod
12 import FWCore.ParameterSet.Types
as typ
16 from FWCore.GuiBrowsers.FileExportPlugin
import FileExportPlugin
19 def elem(elemtype, innerHTML='', html_class='', **kwargs):
21 kwargs[
'class'] = html_class
22 args =
' '.
join([
'%s="%s"' % i
for i
in kwargs.items()])
24 return "<%s %s>%s</%s>\n" % (elemtype, args, innerHTML, elemtype)
26 return "<%s>%s</%s>\n" % (elemtype, innerHTML, elemtype)
29 jquery_file = os.path.join(os.path.dirname(sys.modules[__name__].__file__),
'jquery-1.6.2.min.js')
30 if os.path.exists(jquery_file):
31 return elem(
'script', open(jquery_file).read(), type=
'text/javascript')
33 return elem(
'script', type=
'text/javascript', src=JQUERY)
35 JQUERY =
"http://code.jquery.com/jquery-1.6.2.min.js" 36 LXR =
"http://cmslxr.fnal.gov/lxr/ident?" 37 CVS =
"http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/" 38 CMSLOGO =
"http://cms.cern.ch/iCMS/imgs/icms/CMSheader_left.gif" 42 body {border-width:0;margin:0} 43 #header {width:100%;height:10%;background-color:#000} 44 #mlist {position:absolute;width:32%;top:10%;left:0;height:85%;overflow:auto;padding-left:20px} 45 #mview {position:absolute;width:65%;height:85%;top:10%;left:35%;overflow:auto} 46 #footer {position:absolute;top:95%;width:100%;height:5%;background-color:#000} 47 #cmslogo {float:left;vertical-align:middle;margin:5px} 48 #head_filedir {float:left;vertical-align:middle;margin:5px} 49 #searcharea {float:right;vertical-align:middle;margin-top:3px;margin-right:5px;position:relative} 50 #head_dirname {color:#ccc;font-size:12} 51 #head_filename {color:#fff;font-weight:bold;font-size:16} 52 #searchhider {display:none;position:relative;top:-10px} 53 #searchhider a {color:#fff;text-decoration:none} 54 #searchresult {display:none;-moz-border-radius:10px;border-radius:10px;border:2px solid #999;background-color:#ccc;padding:5px;z-index:1000;position:relative;height:700%} 55 #searchscroll {overflow:scroll;height:100%;width:100%} 56 #searchresult div {margin:3px;padding:2px} 57 .searchfrom {color:#999;font-size:small} 59 #mview_header {font-weight:bold;font-size:16;background-color:#cc6;-moz-border-radius:10px;border-radius:10px;margin-top:3px;padding:5px} 60 #mview_header span {border-radius:5px;-moz-border-radius:5px;padding-left:5px;padding-top:2px;margin-top:2px;margin-left:5px} 61 #mview_subheader {background-color:#ffffcc;-moz-border-radius:10px;border-radius:10px;margin-top:3px;padding:5px} 62 #mview_pset {background-color:#ffffcc;-moz-border-radius:10px;border-radius:10px;margin-top:3px;padding:5px} 63 .mview_label {color:#999} 64 .mview_value {border-radius:5px;-moz-border-radius:5px;padding-left:5px;padding-top:2px;margin-top:2px;margin-left:5px;background-color:#cc6} 65 .mview_value a {text-decoration:none} 66 .mview_value span {display:inline-block} 68 #footer_crumbs {float:left;font-size:small;font-weight:bold;color:#fff} 69 #footer_crumbs span {color:#000} 70 #footer_about {float:right} 71 #footer_about a {text-decoration:none;font-weight:bold;color:#fff} 73 .csearch {background-color:#fff} 75 .seq_contain {position:relative;left:-20px} 76 .seq_toggle {position:absolute;left:5px;top:2px;width:15px;vertical-align:middle;text-align:center;font-weight:bold;font-size:20} 77 .seq_right {position:relative;left:20px;border-radius:5px;-moz-border-radius:5px;padding-left:5px;padding-top:3px;margin-top:3px;width:auto;display:inline-block} 78 .seq_label {font-weight:bold;border-radius:5px;-moz-border-radius:5px;padding:3px 1px;display:inline-block;border-width:1px;border-style:solid} 79 .seq_expand {display:none;padding-left:20px} 81 .module {position:relative;border-radius:5px;-moz-border-radius:5px;padding-left:3px;padding-top:1px;margin-top:2px;padding-right:3px;padding-bottom:1px;margin-right:2px;display:inline-block;border-width:1px;border-style:solid} 83 .path {background-color:#3cf;border-color:#3cf} 84 .endpath {background-color:#9cf;border-color:#9cf} 85 .sequence {background-color:#99f;border-color:#99f} 86 .edanalyzer {background-color:#f00;border-color:#f00} 87 .edproducer {background-color:#0f0;border-color:#0f0} 88 .edfilter {background-color:#ff0;border-color:#ff0} 89 .outputmodule {background-color:#f0f;border-color:#f0f} 90 .source {background-color:#f9c;border-color:#f9c} 91 .service {background-color:#f96;border-color:#f96} 92 .sources {background-color:#fcc;border-color:#fcc} 93 .services {background-color:#fc6;border-color:#fc6} 94 .essource {background-color:#9cc;border-color:#9cc} 95 .esproducer {background-color:#3c9;border-color:#3c9} 96 .esprefer {background-color:#096;border-color:#096} 97 .essources {background-color:#9fc;border-color:#9fc} 98 .esproducers {background-color:#3f9;border-color:#3f9} 99 .esprefers {background-color:#0c6;border-color:#0c6} 100 .unknown_type {background-color:#ccc;border-color:#ccc} 102 .used {border-radius:5px;-moz-border-radius:5px;padding:2px 5px;margin-top:2px;margin-right:5px;border-width:1px;border-style:solid} 103 .member {border-radius:5px;-moz-border-radius:5px;padding:2px 5px;margin-top:2px;margin-right:5px;border-width:1px;border-style:solid} 105 .clickable {cursor:pointer} 106 span.clickable:hover {border-color:#fff} 107 div.module.clickable:hover {border-color:#fff} 108 div.seq_label.clickable:hover {border-color:#fff} 110 .pset {border:2px solid #000;background-color:#ffffcc;font-size:small;border-collapse:collapse} 111 .pset td {border-width:1px;border-color:#ccc; border-style:solid none;margin:0;padding:2px 4px} 112 .pset_label {font-weight:bold} 113 .pset_type {color:#aaa} 115 .pset_vector {list-style-type:none;border:1px solid #000;padding-left:5px;margin:1px} 116 .pset_int {font-family:courier;color:blue} 117 .pset_double {font-family:courier;color:purple} 118 .pset_string {font-family:courier;color:brown} 119 .pset_bool {font-family:courier;color:#f0f} 120 .pset_inputtag {font-family:courier} 121 .pset_othertype {font-family:courier} 122 .pset_placehold {display:none;color:#aaa} 124 #about_dialog {position:absolute;width:60%;height:40%;top:30%;left:20%;border-radius:10px;-moz-border-radius:10px;color:#fff;background-color:#00f;border:5px solid #003;display:none;text-align:center} 132 var pset_values = {}; 135 var last_search = ""; 137 var cvsroot = "%(cvs)s"; 138 var lxrroot = "%(lxr)s"; 139 if (data.process.cmssw) { 140 lxrroot = lxrroot + "v=" + data.process.cmssw + ";"; 143 function parse_data() { 144 function _pset_visitor(pset, context) { 147 for (var i in pset) { 149 var name = context + item.label; 150 if (item.type == 'PSet') { 151 result = _pset_visitor(item.value, name+'.'); 152 keys.concat(result.keys); 153 values.concat(result.values); 154 } else if (item.type == 'VPSet') { 155 for (var j in item.value) { 156 result = _pset_visitor(item.value[j], name+'.'); 158 keys.concat(result.keys); //assume they all have equivalent structure 160 values.concat(result.values); 162 } else if (item.type == 'VInputTag') { 164 for (var j in item.value) { 165 values.push(item.value[j][0].toString()); //only modulename 167 } else if (item.type == 'InputTag') { 169 values.push(item.value[0].toString()); 170 } else if (item.list) { 172 for (var j in item.value) { 173 values.push(item.value[j].toString()); 177 values.push(item.value.toString()); 180 return {keys:keys, values:values}; 182 function _path_visitor(path) { 184 sequences[path.label] = path; 185 for (var child in path.path) { 186 _path_visitor(path.path[child]); 189 _module_visitor(path); 192 function _module_visitor(module) { 193 modules[module.label] = module; 195 var result = _pset_visitor(module.pset, ''); 196 pset_keys[module.label] = result.keys; 197 pset_values[module.label] = result.values; 200 function _handle_flat(modlist) { 201 for (var i in modlist) { 202 _module_visitor(modlist[i]); 205 _handle_flat(data.source); 206 _handle_flat(data.services); 207 _handle_flat(data.essources); 208 _handle_flat(data.esproducers); 209 _handle_flat(data.esprefers); 210 for (var p in data.paths) {var path = data.paths[p]; _path_visitor(path);} 211 for (var p in data.endpaths) {var path = data.paths[p]; _path_visitor(path);} 214 function ensure_visible(name) { 215 if (! $("#"+name).is(":visible")) { 216 $("#"+name).parents(".seq_expand").each(function() { 217 if (! $(this).is(":visible")) { 218 var id = $(this).attr("id").slice(7); 223 $("#mlist").animate({"scrollTop": $("#"+name).position().top}, 1000); 226 function show_module(name) { 227 var module = modules[name]; 229 add_breadcrumb("module", name); 230 ensure_visible(name); 235 function show_sequence(name) { 236 var sequence = sequences[name]; 238 add_breadcrumb("sequence", name); 239 ensure_visible(name); 240 show_mview(sequence); 244 function show_mview(module) { 245 function build_memberlist(memberof) { 247 for (var i in memberof) { 248 var sequence = sequences[memberof[i]]; 250 new_html += "<span class='clickable member "+sequence.type.toLowerCase()+"' onclick='show_sequence(\\""+sequence.label+"\\");'>"+sequence.label+"</span>"; 252 new_html += "<span class='member unknown_type'>"+memberof[i]+"</span>"; 257 function build_uselist(uses) { 259 for (var i in uses) { 260 var module = modules[uses[i]]; 262 new_html += "<span class='clickable used "+module.type.toLowerCase()+"' onclick='show_module(\\""+module.label+"\\");'>"+module.label+"</span>"; 264 new_html += "<span class='used unknown_type'>"+uses[i]+"</span>"; 269 function build_pset(pset, context, toplevel) { 270 var typemap = {"string": "string", "double": "double", "int32": "int", "int64": "int", "uint32": "int", "uint64": "int", "bool": "bool"}; 272 var new_html = "<span class='pset_placehold clickable' id='placehold_"+context+"' onclick='pset_toggle(\\""+context+"\\");'>("+pset.length.toString()+" hidden)</span><table id='content_"+context+"' class='pset'>"; 274 var new_html = "<table class='pset'>"; 276 for (var i in pset) { 277 var context2 = context + "_" + i.toString(); 279 if (item.untracked) { 280 var itemtype = "cms.untracked."+item.type; 282 var itemtype = "cms."+item.type; 285 itemtype += "[" + item.value.length.toString() + "]"; 286 new_html += "<tr><td class='pset_label'>"+item.label+"</td><td class='pset_type clickable' onclick='pset_toggle(\\""+context2+"\\");'>"+itemtype+"</td><td>"; 287 } else if (item.type == 'PSet') { 288 new_html += "<tr><td class='pset_label'>"+item.label+"</td><td class='pset_type clickable' onclick='pset_toggle(\\""+context2+"\\");'>"+itemtype+"</td><td>"; 290 new_html += "<tr><td class='pset_label'>"+item.label+"</td><td class='pset_type'>"+itemtype+"</td><td>"; 293 if (item.type == 'PSet') { 294 new_html += build_pset(item.value, context2); 295 } else if (item.type == 'VPSet') { 296 new_html += "<span class='pset_placehold clickable' id='placehold_"+context2+"' onclick='pset_toggle(\\""+context2+"\\");'>("+item.value.length.toString()+" hidden)</span><ul class='pset_vector' id='content_"+context2+"'>"; 297 for (var j in item.value) { 298 new_html += "<li>"+build_pset(item.value[j], context2+"_"+j.toString())+"</li>"; 301 } else if (item.type == 'VInputTag') { 302 new_html += "<span class='pset_placehold clickable' id='placehold_"+context2+"' onclick='pset_toggle(\\""+context2+"\\");'>("+item.value.length.toString()+" hidden)</span><ul class='pset_vector' id='content_"+context2+"'>"; 303 for (var j in item.value) { 304 var tag = item.value[j]; 305 var link = build_uselist([tag[0]]); 306 if (tag[1] || tag[2]) { 307 new_html += "<li><span class='pset_inputtag'>"+link+":"+tag[1]+":"+tag[2]+"</span></li>"; 309 new_html += "<li><span class='pset_inputtag'>"+link+"</span></li>"; 313 } else if (item.type == 'InputTag') { 314 var tag = item.value; 315 var link = build_uselist([tag[0]]); 316 if (tag[1] || tag[2]) { 317 new_html += "<span class='pset_inputtag'>"+link+":"+tag[1]+":"+tag[2]+"</span>"; 319 new_html += "<span class='pset_inputtag'>"+link+"</span>"; 321 } else if (item.list) { 322 new_html += "<span class='pset_placehold clickable' id='placehold_"+context2+"' onclick='pset_toggle(\\""+context2+"\\");'>("+item.value.length.toString()+" hidden)</span><ul class='pset_vector' id='content_"+context2+"'>"; 323 var cmstype = item.type.slice(1); 324 if (typemap[cmstype]) { 325 var css = typemap[cmstype]; 327 var css = "othertype"; 329 for (var j in item.value) { 330 new_html += "<li><span class='pset_"+css+"'>"+item.value[j]+"</span></li>"; 334 var cmstype = item.type; 335 if (typemap[cmstype]) { 336 var css = typemap[cmstype]; 338 var css = "othertype"; 340 new_html += "<span class='pset_"+css+"'>"+item.value+"</span>"; 342 new_html += "</td></tr>"; 344 new_html += "</table>"; 347 var header = "<span class='used "+module.type.toLowerCase()+"'>"+module.label+"</span>"; 348 $("#mview_header").html(header); 349 var table_html = "<tr><td class='mview_label'>Module Type:</td><td class='mview_value'>"+module.type+"</td></tr>"; 350 if (module.file && module.line) { 351 table_html += "<tr><td class='mview_label'>Defined in:</td><td class='mview_value'><a href='"+cvsroot+module.file+"'>"+module.file+"</a>:"+module.line+"</td></tr>"; 352 } else if (module.file) { 353 table_html += "<tr><td class='mview_label'>Defined in:</td><td class='mview_value'><a href='"+cvsroot+module.file+"'>"+module.file+"</a></td></tr>"; 356 table_html += "<tr><td class='mview_label'>Module Class:</td><td class='mview_value'><a href='"+lxrroot+"i="+module.class+"'>"+module.class+"</a></td></tr>"; 359 table_html += "<tr><td class='mview_label'>Uses:</td><td class='mview_value'>"+build_uselist(module.uses)+"</td></tr>"; 362 table_html += "<tr><td class='mview_label'>Used by:</td><td class='mview_value'>"+build_uselist(module.usedby)+"</td></tr>"; 364 if (module.memberof) { 365 table_html += "<tr><td class='mview_label'>Member of:</td><td class='mview_value'>"+build_memberlist(module.memberof)+"</td></tr>"; 367 $("#mview_table").html(table_html); 369 $("#mview_pset").html(build_pset(module.pset, "pset", true)); 370 $("#mview_pset").find("tr,li").filter(":even").css({"background-color": "#ffa"}); 371 $("#mview_pset").find("tr,li").filter(":odd").css({"background-color": "#ffc"}); 372 $("#mview_pset").find('[id^="content_"]').each(function() { 373 var id = $(this).attr("id").slice(8); 374 if ($(this).children().size() > 5) { 379 $("#mview_pset").html(""); 383 function pset_toggle(item) { 384 if ($("#content_"+item).is(":visible")) { 385 $("#content_"+item).hide("fast"); 386 $("#placehold_"+item).show("fast"); 388 $("#content_"+item).show("fast"); 389 $("#placehold_"+item).hide("fast"); 393 function add_breadcrumb(itemtype, item) { 394 if (crumbs.length > 0 && crumbs[crumbs.length-1][1] == item) { 397 if (crumbs.push([itemtype, item]) > 5) { 398 crumbs = crumbs.slice(1); 402 for (var crumb in crumbs) { 403 var c = crumbs[crumb]; 404 if (c[0] == "module") { 405 var module = modules[c[1]]; 407 var css = "used clickable "+module.type.toLowerCase(); 409 var css = "used unknown_type"; 411 new_html += "< <span class='"+css+"' onclick='show_module(\\"" + c[1] + "\\");'>" + c[1] + "</span>"; 412 } else if (c[0] == "sequence") { 413 var sequence = sequences[c[1]]; 415 var css = "used clickable "+sequence.type.toLowerCase(); 417 var css = "used unknown_type"; 419 new_html += "< <span class='"+css+"' onclick='show_sequence(\\"" + c[1] + "\\");'>" + c[1] + "</span>"; 420 } else if (c[0] == "search") { 421 new_html += "< <span class='used clickable csearch' onclick='do_search(\\"" + c[1] + "\\");'>\\"" + c[1] + "\\"?</span>"; 424 $("#footer_crumbs").html(new_html); 427 function toggle_sequence(sequence) { 428 if ($("#expand_"+sequence).is(":visible")) { 429 $("#expand_"+sequence).hide("fast"); 430 $("#toggle_"+sequence).text("+"); 432 $("#expand_"+sequence).show("fast"); 433 $("#toggle_"+sequence).text("-"); 437 function build_mlist() { 438 function build_path(path) { 440 var new_html = "<div class='seq_contain'><div class='seq_toggle clickable' id='toggle_"+path.label+"'>+</div><div class='seq_right "+path.type.toLowerCase()+"'><div id='"+path.label+"' class='seq_label "+path.type.toLowerCase()+"'>"+path.label+"</div><div class='seq_expand' id='expand_"+path.label+"'>"; 441 for (var child in path.path) { 442 new_html += build_path(path.path[child]); 444 new_html += "</div></div></div>"; 447 return build_module(path); 450 function build_module(module) { 451 return "<div id='"+module.label+"' class='module "+module.type.toLowerCase()+"'>"+module.label+"</div>"; 455 new_html += build_path({"label":"Source", "type": "Sources", "path": data.source}); 458 new_html += build_path({"label":"Services", "type": "Services", "path": data.services}); 461 for (var path in data.paths) { 462 new_html += build_path(data.paths[path]); 466 for (var path in data.endpaths) { 467 new_html += build_path(data.endpaths[path]); 470 if (data.essources) { 471 new_html += build_path({"label":"ESSources", "type": "ESSources", "path": data.essources}); 473 if (data.esproducers) { 474 new_html += build_path({"label":"ESProducers", "type": "ESProducers", "path": data.esproducers}); 476 if (data.esprefers) { 477 new_html += build_path({"label":"ESPrefers", "type": "ESPrefers", "path": data.esprefers}); 479 $("#mlist").html(new_html); 480 $("#mlist").find(".seq_toggle").each(function() { 481 $(this).click(function() { 482 var id=$(this).attr("id").slice(7); 486 $("#mlist").find(".seq_label").each(function() { 487 $(this).click(function() {show_sequence($(this).attr("id"));}); 488 $(this).addClass("clickable"); 490 $("#mlist").find(".module").each(function() { 491 $(this).click(function() {show_module($(this).attr("id"));}); 492 $(this).addClass("clickable"); 496 function do_search(query) { 497 if (! query) {return;} 498 add_breadcrumb("search", query); 499 var results = {modules:[], modclass:[], modfile:[], sequences:[], seqfile:[], keys:[], values:[]}; 500 var pattern = new RegExp(query, "gi"); 501 for (var i in modules) { 502 if (i.search(pattern) != -1) { 503 results.modules.push(i); 505 if (modules[i].class.search(pattern) != -1) { 506 results.modclass.push(i); 508 if (modules[i].file) { 509 if (modules[i].file.search(pattern) != -1) { 510 results.modfile.push(i); 514 for (var i in sequences) { 515 if (i.search(pattern) != -1) { 516 results.sequences.push(i); 518 if (sequences[i].file) { 519 if (sequences[i].file.search(pattern) != -1) { 520 results.seqfile.push(i); 524 for (var i in pset_keys) { 525 for (var j in pset_keys[i]) { 526 if (pset_keys[i][j].search(pattern) != -1) { 527 results.keys.push(i); 531 for (var i in pset_values) { 532 for (var j in pset_values[i]) { 533 if (pset_values[i][j].search(pattern) != -1) { 534 results.values.push(i); 539 function _module_div(name, extra) { 541 var module = modules[name]; 543 var module = modules[name]; 544 var onclick = "show_module(\\""+module.label+"\\");toggle_search();"; 545 } else if (sequences[name]) { 546 var module = sequences[name]; 547 var onclick = "show_sequence(\\""+module.label+"\\");toggle_search();"; 551 var label = name.replace(pattern, "<b>$&</b>"); 552 new_html += "<div><span class='used clickable "+module.type.toLowerCase()+"' onclick='"+onclick+"'>"+label+"</span><span class='searchfrom'>("+extra+")</span></div>"; 556 var searchmap = {"module name":results.modules, "module class":results.modclass, "module file":results.modfile, "module pset key":results.keys, "module pset value":results.values, "sequence name":results.sequences, "sequence file":results.seqfiles}; 557 for (var i in searchmap) { 558 for (var j in searchmap[i]) { 559 if (hitlist.indexOf(searchmap[i][j]) == -1) { 560 new_html += _module_div(searchmap[i][j], i); 561 hitlist.push(searchmap[i][j]); 565 n_results = hitlist.length; 567 $("#searchscroll").html(new_html); 568 $("#searchinput").val("search"); 569 if ($("#searchhider").is(":hidden")) {$("#searchhider").show("fast");} 573 function toggle_search(force) { 574 if ($("#searchresult").is(":hidden") || force==true) { 575 $("#searchresult").show("slow"); 576 $("#searchhider a").html("Hide search results"); 578 $("#searchresult").hide("slow"); 579 $("#searchhider a").html("Show results for <b>"+last_search+"</b> ("+n_results.toString()+")"); 584 $("#about_dialog").toggle("slow"); 587 $(document).ready(function() { 590 $('#searchinput').focus(function() {if ($(this).val() == 'search') {$(this).val('');}}); 591 $('#searchsubmit').click(function(event) {event.preventDefault();do_search($('#searchinput').val());}); 593 """ %
dict(cvs=CVS, lxr=LXR)
599 <title>%(title)s</title> 600 <style type="text/css"> 604 <script type="text/javascript"> 611 <div id="cmslogo"><img src="%(cmslogo)s" alt="CMS Logo" height=48 width=48></img></div> 612 <div id="head_filedir"> 613 <div id="head_dirname">%(dirname)s</div> 614 <div id="head_filename">%(filename)s</div> 616 <div id="searcharea"> 618 <form id="searchform"> 619 <input id="searchinput" type="text" value="search"> 620 <input id="searchsubmit" type="submit" value="Search"> 623 <div id='searchhider'><a href='#' onclick='toggle_search();'></a></div> 624 <div id='searchresult'> 625 <div id='searchscroll'></div> 629 <div id="mlist"></div> 631 <div id="mview_header"></div> 632 <div id="mview_subheader"> 633 <table id="mview_table"></table> 635 <div id="mview_pset"></div> 638 <div id="footer_crumbs"></div> 639 <div id="footer_about"><a href='#' onclick='about();'>About</a></div> 641 <div id="about_dialog" onclick='about();'> 642 <div><h2>CMSSW configuration-to-html converter</h2></div> 643 <div>Written by Gordon Ball (Imperial College)</div> 644 <div>Uses CMSSW Config Editor and jQuery</div> 655 plugin_name =
'HTML Export' 656 file_types = (
'html', )
659 FileExportPlugin.__init__(self)
661 def export(self, data, filename, filetype):
662 with open(filename,
'w')
as f:
666 return PAGE_TEMPLATE %
dict(title=data._filename, jquery=
get_jquery(),
667 css=CSS_TEMPLATE, js=JS_TEMPLATE, dirname=
'.',
674 if 'CMSSW_BASE' in os.environ:
675 cmssw = os.environ[
'CMSSW_BASE'].
split(
'/')[-1]
676 elif 'CMSSW_RELEASE_BASE' in os.environ:
677 cmssw = os.environ[
'CMSSW_RELEASE_BASE'].
split(
'/')[-1]
678 result = {
'process': {
'name': data.process().name_()
if data.process()
else '(no process)',
'src': data._filename,
'cmssw':cmssw}}
679 toplevel = data.children(data.topLevelObjects()[0])
if data.process()
else data.topLevelObjects()
681 children = data.children(tlo)
683 if label
in (
'source',
'services'):
684 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]
685 elif label
in (
'essources',
'esproducers',
'esprefers'):
686 result[label] = [self.
module_to_json(data, child)
for child
in children]
687 elif label
in (
'paths',
'endpaths'):
688 result[label] = [self.
path_to_json(data, child)
for child
in children]
689 return json.dumps(result, indent=4)
693 for k, v
in pset.items():
694 typename = v.pythonTypeName().
split(
'.')[-1]
695 item = {
'label': k,
'type': typename}
696 if not v.isTracked():
697 item[
'untracked'] =
True 698 if typename ==
'PSet':
700 elif typename ==
'VPSet':
701 item[
'value'] = [self.
pset_to_json(vv.parameters_())
for vv
in v]
703 elif typename ==
'VInputTag':
706 if isinstance(vv, cms.InputTag):
708 elif isinstance(vv, str):
709 v_it.append(cms.InputTag(vv))
711 raise ValueError(
"Unsupported type in VInputTag "+type(vv))
712 item[
'value'] = [(vv.moduleLabel, vv.productInstanceLabel, vv.processName)
for vv
in v_it]
714 elif typename ==
'InputTag':
715 item[
'value'] = [v.moduleLabel, v.productInstanceLabel, v.processName]
716 elif isinstance(v, mix._ValidatingListBase):
717 item[
'value'] = [
str(vv)
for vv
in v]
720 item[
'value'] = v.pythonValue()
726 'label':data.label(module),
727 'class':data.classname(module),
728 'file':data.pypath(module),
729 'line':data.lineNumber(module),
732 'type':data.type(module),
733 'uses':data.uses(module),
734 'usedby':data.usedBy(module),
735 'memberof':data.foundIn(module)
739 children = data.children(path)
740 if data.isContainer(path):
741 json_children = [self.
path_to_json(data, child)
for child
in children]
742 return {
'type':data.type(path),
'label':data.label(path),
743 'path':json_children,
'memberof': data.foundIn(path),
744 'file': data.pypath(path),
'line': data.lineNumber(path)}
754 plugin_name=
'HTML Export (Static)' 757 FileExportPlugin.__init__(self)
760 def elem(elemtype,innerHTML='',html_class='',**kwargs):
762 kwargs[
'class']=html_class
763 return "<%s %s>%s</%s>\n" % (elemtype,
' '.
join([
'%s="%s"'%(k,v)
for k,v
in kwargs.items()]),innerHTML,elemtype)
764 def div(innerHTML='',html_class='',**kwargs):
765 return elem(
'div',innerHTML,html_class,**kwargs)
768 def linkInputTag(tag):
770 if isinstance(tag,typ.InputTag):
771 inputtag = tag.pythonValue()
779 for k,v
in pset.items():
780 if isinstance(v,mix._ParameterTypeBase):
781 if isinstance(v,mix._SimpleParameterTypeBase):
783 if isinstance(v,typ.bool):
785 if isinstance(v,typ.double):
787 if isinstance(v,typ.string):
789 if isinstance(v,(typ.int32, typ.uint32, typ.int64, typ.uint64)):
791 pset_items_html+=
elem(
'tr',
792 elem(
'td',k,
'param-name')
793 +
elem(
'td',v.pythonTypeName(),
'param-class')
794 +
elem(
'td',v.pythonValue(),
'param-value-%s'%item_class),
797 if isinstance(v,typ.InputTag):
798 pset_items_html+=
elem(
'tr',
799 elem(
'td',k,
'param-name')
800 +
elem(
'td',v.pythonTypeName(),
'param-class')
801 +
elem(
'td',linkInputTag(v),
'param-value-inputtag'),
804 if isinstance(v,typ.PSet):
806 if len(v.parameters_())==0:
807 pset_items_html+=
elem(
'tr',
808 elem(
'td',k,
'param-name')
809 +
elem(
'td',v.pythonTypeName(),
'param-class')
810 +
elem(
'td',
'(empty)',
'label'),
814 pset_items_html+=
elem(
'tr',
815 elem(
'td',k,
'param-name')
816 +
elem(
'td',v.pythonTypeName(),
'param-class')
817 +
elem(
'td',htmlPSet(v.parameters_())),
820 if isinstance(v,mix._ValidatingListBase):
823 list_html =
elem(
'li',
'(empty)',
'label')
825 if isinstance(v,typ.VInputTag):
827 list_html +=
elem(
'li',linkInputTag(vv),
'param-value-inputtag pset-list-item')
828 elif isinstance(v,typ.VPSet):
830 list_html +=
elem(
'li',htmlPSet(vv.parameters_()),
'pset-list-item')
833 if isinstance(v,typ.vbool):
835 if isinstance(v,typ.vdouble):
837 if isinstance(v,typ.vstring):
839 if isinstance(v,(typ.vint32,typ.vuint32,typ.vint64,typ.vuint64)):
844 list_html +=
elem(
'li',vv,
'pset-list-item param-value-%s'%item_class)
845 pset_items_html+=
elem(
'tr',
846 elem(
'td',k,
'param-name')
847 +
elem(
'td',
'%s[%s]'%(v.pythonTypeName(),len(v)),
'param-class')
848 +
elem(
'td',
elem(
'ol',list_html,
'pset-list')),
853 return elem(
'table',pset_items_html,
'pset')
856 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))))
858 mod_table =
elem(
'table',
859 elem(
'tr',
elem(
'td',
'Type',
'label')+
elem(
'td',data.type(mod)))
860 +
elem(
'tr',
elem(
'td',
'Class',
'label')+
elem(
'td',data.classname(mod))),
863 mod_pset = htmlPSet(mod.parameters_())
865 mod_content_html = div(mod_table+mod_pset,
'module_area',id=
'mod_%s'%data.label(mod))
866 return div(mod_label_html+mod_content_html,
'module',id=
'module_'+data.label(mod))
868 def htmlPathRecursive(p):
869 children = data.children(p)
872 if isinstance(p,sqt.Path):
874 if isinstance(p,sqt.EndPath):
876 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))
877 seq_inner_content_html =
''.
join([htmlPathRecursive(c)
for c
in children])
878 seq_content_html = div(seq_inner_content_html,
'sequence_area',id=
'seq_%s'%data.label(p))
879 return div(seq_label_html+seq_content_html,
'sequence')
887 filter_html =
elem(
'span',
'Filter '+
888 elem(
'input',type=
'text',width=50,onkeyup=
"return doFilter();",id=
'input-filter'),
891 header_html = div(
'Config File Visualisation'+filter_html,
'header')
894 for tlo
in data.children(data.topLevelObjects()[0]):
895 children = data.children(tlo)
897 toplevel[tlo._label]=children
899 if 'paths' in toplevel:
900 for path
in toplevel[
'paths']:
901 path_html += div(htmlPathRecursive(path),
'path')
903 file_html = div(
elem(
'span',
'Process:')
904 +
elem(
'span',data.process().name_(),
'title')
905 +
elem(
'span',data._filename,
'right'),
907 head_html =
elem(
'head',
elem(
'title',data.process().name_()))
909 toplevel[
'sequences']=[]
911 toplevel[
'modules']=[]
912 for tlo
in data.topLevelObjects():
913 if data.type(tlo)==
'Sequence':
914 toplevel[
'sequences']+=[tlo]
915 if data.type(tlo)==
'Path':
916 toplevel[
'paths']+=[tlo]
917 if data.type(tlo)
in (
'EDAnalyzer',
'EDFilter',
'EDProducer',
'OutputModule'):
918 toplevel[
'modules']+=[tlo]
923 for path
in toplevel[
'paths']:
924 path_html += div(htmlPathRecursive(path),
'path')
925 for sequence
in toplevel[
'sequences']:
926 sequence_html += htmlPathRecursive(sequence)
927 for module
in toplevel[
'modules']:
928 module_html += htmlModule(module)
929 file_html = div(
elem(
'span',data._filename,
'right'),
'file')
930 path_html += sequence_html
931 path_html += module_html
932 head_html =
elem(
'head',
elem(
'title',data._filename))
933 footer_html = div(
'gordon.ball',
'footer')
937 style_html =
elem(
'style',
939 .title{font-weight:bold} 941 .header{position:fixed;top:0px;left:0px;width:100%;background:#33cc00;font-weight:bold;font-size:120%} 942 .footer{position:fixed;bottom:0px;left:0px;width:100%;background:#33cc00;text-align:right} 943 .canvas{padding:40px 10px 40px 10px} 944 .file{position:relative;background:#bbb;width:100%;padding-left:5px} 945 .right{position:absolute;right:5px} 946 .sequence{border:1px solid #aaa} 947 .sequence:hover{border 1px solid #00ffff} 948 .sequence_label{background:lightskyblue;padding-left:5px} 949 .sequence_label:hover{background:#fff} 950 .sequence_label_hidden{background:grey;padding-left:5px} 951 .sequence_area{padding:5px 0px 5px 5px} 952 .edproducer{border:1px solid red;background-image:url('edproducer.png');background-position:center left;background-repeat:no-repeat;padding:0px 0px 0px 40px} 953 .edfilter{border:1px solid green;background-image:url('edfilter.png');background-position:center left;background-repeat:no-repeat;padding:0px 0px 0px 40px} 954 .edanalyzer{border:1px solid blue;background-image:url('edanalyzer.png');background-position:center left;background-repeat:no-repeat;padding:0px 0px 0px 40px} 955 .outputmodule{border:1px solid green;background-image:url('outputmodule.png');background-position:center left;background-repeat:no-repeat;padding:0px 0px 0px 40px} 957 .module_label:hover{background:#ccc;position:relative} 958 .module_area{display:none;padding:5px 0px 15px 15px;background:beige} 959 .pset{border-spacing:10px 1px;border:1px solid black} 961 .pset-list{list-style-type:none;margin:0px;padding:2px 2px 2px 2px;border:1px solid grey} 962 .pset-list-item{border-top:1px solid lightgrey;border-bottom:1px solid lightgrey} 963 .param-name{font-weight:bold} 964 .param-class{color:grey} 965 .param-value-int{font-family:courier;color:blue} 966 .param-value-double{font-family:courier;color:purple} 967 .param-value-string{font-family:courier;color:brown} 968 .param-value-bool{font-family:courier;color:#f0f} 969 .param-value-inputtag{font-family:courier;color:red} 970 .param-value-other{font-family:courier} 972 .hidden{display:none} 976 script_html =
elem(
'script',
978 function toggleModuleVisible(id) { 979 var elem = document.getElementById(id); 980 if (elem.style.display=='block') { 981 elem.style.display='none'; 983 elem.style.display='block'; 987 function toggleSequenceVisible(id) { 988 var area_elem = document.getElementById('seq_'+id); 989 var hidden_elem = document.getElementById('seq_hidden_'+id); 990 var label_elem = document.getElementById('seq_label_'+id); 991 if (area_elem.style.display=='none') { 992 area_elem.style.display='block'; 993 hidden_elem.style.display='none'; 994 label_elem.className = 'sequence_label'; 996 area_elem.style.display='none'; 997 hidden_elem.style.display='block'; 998 label_elem.className = 'sequence_label_hidden'; 1002 function doFilter() { 1003 var text = document.getElementById('input-filter').value; 1004 var regex = new RegExp(text); 1005 for (var i=0;i<document.all.length;i++) { 1006 if (document.all(i).id.substr(0,7)=="module_") { 1007 var elem = document.all(i); 1008 var elem_name = elem.id.substr(7); 1009 if (regex.test(elem_name)) { 1010 elem.style.display='block'; 1012 elem.style.display='none'; 1018 type=
'text/javascript')
1020 body_html =
elem(
'body',script_html+header_html+footer_html+div(file_html+path_html,
'canvas'))
1022 return elem(
'html',head_html+style_html+body_html)
1030 if filetype==
'html':
1031 htmlfile = open(filename,
'w')
1032 htmlfile.write(html)
def data_to_json(self, data)
def pset_to_json(self, pset)
def module_to_json(self, data, module)
def export(self, data, filename, filetype)
def elem(elemtype, innerHTML='', html_class='', kwargs)
static std::string join(char **cmd)
def path_to_json(self, data, path)
def export(self, data, filename, filetype)