#!/usr/bin/python # # Copyright 2001 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Simple web server for browsing dependency graph data. This script is inlined into the final executable and spawned by it when needed. """ import BaseHTTPServer import subprocess import sys import webbrowser def match_strip(prefix, line): if not line.startswith(prefix): print prefix, line assert line.startswith(prefix) return line[len(prefix):] def parse(text): lines = text.split('\n') node = lines.pop(0) node = node[:-1] # strip trailing colon input = [] if lines and lines[0].startswith(' input:'): input.append(match_strip(' input: ', lines.pop(0))) while lines and lines[0].startswith(' '): input.append(lines.pop(0).strip()) outputs = [] while lines: output = [] output.append(match_strip(' output: ', lines.pop(0))) while lines and lines[0].startswith(' '): output.append(lines.pop(0).strip()) outputs.append(output) return (node, input, outputs) def generate_html(data): node, input, outputs = data print ''' ''' print '
'
print '%s' % node print ' | ||
'
print 'input' if input: print '%s: ' % input[0] print '
| '
print '' print ' | '
print 'outputs' for output in outputs: print '%s: ' % output[0] print '
|