Source

pyptug / webpy / gae / __init__.py

Full commit
from web.template import CompiledTemplate, ForLoop, TemplateResult


# coding: utf-8
def simple():
    __lineoffset__ = -5
    loop = ForLoop()
    self = TemplateResult(); extend_ = self.extend
    extend_([u'Hello, world!\n'])

    return self

simple = CompiledTemplate(simple, 'templates/simple.html')
join_ = simple._join; escape_ = simple._escape

# coding: utf-8
def code (program, docopt, author, email, version):
    __lineoffset__ = -4
    loop = ForLoop()
    self = TemplateResult(); extend_ = self.extend
    extend_([u'#!/usr/bin/env python\n'])
    extend_([u'# encoding: utf-8\n'])
    extend_([u'"""Usage:\n'])
    extend_([escape_(program, True), u' ', escape_(docopt[0], True), u'\n'])
    extend_([escape_(program, True), u' ', escape_(docopt[1], True), u'\n'])
    extend_([u'\n'])
    extend_([u'"""\n'])
    extend_([u'from docopt import docopt\n'])
    extend_([u'\n'])
    extend_([u'__author__ = "', escape_(author, True), u'"\n'])
    extend_([u'__email__ = "', escape_(email, True), u'"\n'])
    extend_([u'\n'])
    extend_([u'def main():\n'])
    extend_([u"    arguments = docopt(__doc__, version='", escape_(version, True), u"')\n"])
    extend_([u'    print(arguments)\n'])
    extend_([u'     \n'])
    extend_([u"if __name__ == '__main__':\n"])
    extend_([u'    main()\n'])

    return self

code = CompiledTemplate(code, 'templates/code.py')
join_ = code._join; escape_ = code._escape

# coding: utf-8
def hello (name):
    __lineoffset__ = -4
    loop = ForLoop()
    self = TemplateResult(); extend_ = self.extend
    extend_([u'<!DOCTYPE html>\n'])
    extend_([u'<html>\n'])
    extend_([u'<head>\n'])
    extend_([u'</head>\n'])
    extend_([u'\n'])
    extend_([u'<body>\n'])
    extend_([u'<font size=+5>\n'])
    if name:
        extend_([u'Let me say <em>hello</em> to ', escape_(name, True), u'.\n'])
    else:
        extend_([u'<em>Hello</em>, world!\n'])
    extend_([u'</font>\n'])
    extend_([u'</body>\n'])
    extend_([u'\n'])
    extend_([u'</html>\n'])

    return self

hello = CompiledTemplate(hello, 'templates/hello.html')
join_ = hello._join; escape_ = hello._escape