def blue(text):
"""
Formats text as blue
"""
return PrettyPrinter._format(PrettyPrinter.Colors.BLUE, text)
python类PrettyPrinter()的实例源码
def light_purple(text):
"""
Formats text as light_purple
"""
return PrettyPrinter._format(PrettyPrinter.Colors.LIGTH_PURPLE, text)
def green(text):
"""
Formats text as green
"""
return PrettyPrinter._format(PrettyPrinter.Colors.GREEN, text)
def dark_green(text):
"""
Formats text as dark_green
"""
return PrettyPrinter._format(PrettyPrinter.Colors.DARK_GREEN, text)
def yellow(text):
"""
Formats text as yellow
"""
return PrettyPrinter._format(PrettyPrinter.Colors.YELLOW, text)
def dark_yellow(text):
"""
Formats text as dark_yellow
"""
return PrettyPrinter._format(PrettyPrinter.Colors.DARK_YELLOW, text)
def orange(text):
"""
Formats text as orange
"""
return PrettyPrinter._format(PrettyPrinter.Colors.ORANGE, text)
def cyan(text):
"""
Formats text as cyan
"""
return PrettyPrinter._format(PrettyPrinter.Colors.CYAN, text)
def magenta(text):
"""
Formats text as magenta
"""
return PrettyPrinter._format(PrettyPrinter.Colors.MAGENTA, text)
def purple(text):
"""
Formats text as purple
"""
return PrettyPrinter._format(PrettyPrinter.Colors.PURPLE, text)
def info(text):
"""
Formats text as info
"""
return PrettyPrinter._format(PrettyPrinter.Colors.LIGHT_YELLOW, text)
def p_bold(text):
"""
Prints text formatted as bold
"""
sys.stdout.write(PrettyPrinter.bold(text))
def pl_bold(text):
"""
Prints text formatted as bold with newline in the end
"""
sys.stdout.write(u"{}\n".format(PrettyPrinter.bold(text)))
def p_blue(text):
"""
Prints text formatted as blue
"""
print(PrettyPrinter.blue(text))
def p_green(text):
"""
Prints text formatted as green
"""
print(PrettyPrinter.green(text))
def p_red(text):
"""
Prints text formatted as red
"""
print(PrettyPrinter.red(text))
def print(self):
import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(self.settings)
def printTest(testDict, solutionDict):
pp = pprint.PrettyPrinter(indent=4)
print "Test case:"
for line in testDict["__raw_lines__"]:
print " |", line
print "Solution:"
for line in solutionDict["__raw_lines__"]:
print " |", line
def pprint_patch():
if isinstance(getattr(pprint.PrettyPrinter, '_dispatch', None), dict):
orig = pprint.PrettyPrinter._dispatch[collections.OrderedDict.__repr__]
pprint.PrettyPrinter._dispatch[collections.OrderedDict.__repr__] = patched_pprint_ordered_dict
try:
yield
finally:
pprint.PrettyPrinter._dispatch[collections.OrderedDict.__repr__] = orig
else:
yield
#
#
#
def process(self, write, request, submit, **kw):
"""Override me: I process a form.
I will only be called when the correct form input data to process this
form has been received.
I take a variable number of arguments, beginning with 'write',
'request', and 'submit'. 'write' is a callable object that will append
a string to the response, 'request' is a twisted.web.request.Request
instance, and 'submit' is the name of the submit action taken.
The remainder of my arguments must be correctly named. They will each be named after one of the
"""
write("<pre>Submit: %s <br /> %s</pre>" % (submit, html.PRE(pprint.PrettyPrinter().pformat(kw))))