Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /usr/lib/python2.7/dist-packages/twisted/scripts/ |
Upload File : |
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. # """HTML pretty-printing for Python source code.""" __version__ = '$Revision: 1.8 $'[11:-2] from twisted.python import htmlizer, usage from twisted import copyright import os, sys header = '''<html><head> <title>%(title)s</title> <meta name=\"Generator\" content="%(generator)s" /> %(alternate)s %(stylesheet)s </head> <body> ''' footer = """</body>""" styleLink = '<link rel="stylesheet" href="%s" type="text/css" />' alternateLink = '<link rel="alternate" href="%(source)s" type="text/x-python" />' class Options(usage.Options): synopsis = """%s [options] source.py """ % ( os.path.basename(sys.argv[0]),) optParameters = [ ('stylesheet', 's', None, "URL of stylesheet to link to."), ] compData = usage.Completions( extraActions=[usage.CompleteFiles('*.py', descr='source python file')] ) def parseArgs(self, filename): self['filename'] = filename def run(): options = Options() try: options.parseOptions() except usage.UsageError, e: print str(e) sys.exit(1) filename = options['filename'] if options.get('stylesheet') is not None: stylesheet = styleLink % (options['stylesheet'],) else: stylesheet = '' output = open(filename + '.html', 'w') try: output.write(header % { 'title': filename, 'generator': 'htmlizer/%s' % (copyright.longversion,), 'alternate': alternateLink % {'source': filename}, 'stylesheet': stylesheet }) htmlizer.filter(open(filename), output, htmlizer.SmallerHTMLWriter) output.write(footer) finally: output.close()