def handle_form(template_name): template = file(os.path.join(template_path, template_name), 'r').read() generators = LanguageInfo.get_generator_names_descriptions() generators.sort() template = template % { 'template' : template_name, 'generators' : '\n'.join(['<option value="%s">%s</option>' % (name, description) for name, description in generators]), 'encodings' : '\n'.join(['<option value="%s">%s</option>' % (value, name) for value, name in encodings])} print template
def handle_form(template_name): template = file(os.path.join(template_path, template_name), 'r').read() generators = LanguageInfo.get_generator_names_descriptions() generators.sort() template = template % { 'template': template_name, 'generators': '\n'.join([ '<option value="%s">%s</option>' % (name, description) for name, description in generators ]), 'encodings': '\n'.join([ '<option value="%s">%s</option>' % (value, name) for value, name in encodings ]) } print template
generator.generate_html(target_file, source) target_file.write(suffix) if view: target_file.close() webbrowser.open(target_file_name) if __name__ == "__main__": args = sys.argv[1:] if (args == 0) or ("--help" in args) or ("-help" in args): print(usage) sys.exit(0) switches, other_args = collect_options(args) if 'list-generators' in switches: lexers = LanguageInfo.get_generator_names_descriptions() lexers.sort() print("\nGenerator Options:") for name, description in lexers: print(" --generator=%s (%s)" % (name, description)) print() sys.exit(0) if 'clip' in switches: html_args = {} del switches['clip'] elif len(other_args) > 0: html_args = {'source_file_name' : other_args[0]} other_args = other_args[1:] else: print(usage)
target_file.write(suffix) if view: target_file.close() webbrowser.open(target_file_name) if __name__ == "__main__": args = sys.argv[1:] if (args == 0) or ("--help" in args) or ("-help" in args): print usage sys.exit(0) switches, other_args = collect_options(args) if switches.has_key('list-generators'): lexers = LanguageInfo.get_generator_names_descriptions() lexers.sort() print "\nGenerator Options:" for name, description in lexers: print " --generator=%s (%s)" % (name, description) print sys.exit(0) if switches.has_key('clip'): html_args = {} del switches['clip'] elif len(other_args) > 0: html_args = {'source_file_name': other_args[0]} other_args = other_args[1:] else: print usage
def list_generators(): """ This returns a list of generators, a generator is a valid language, so these are things like perl, python, xml etc...""" lexers = LanguageInfo.get_generator_names_descriptions() return lexers