Ejemplo n.º 1
0
Archivo: loading2.py Proyecto: AvdN/tdi
#!/usr/bin/env python
import warnings as _warnings
_warnings.resetwarnings()
_warnings.filterwarnings('error')

# BEGIN INCLUDE
import tempfile
from tdi import html

file_1 = tempfile.NamedTemporaryFile()
try:
    file_2 = tempfile.NamedTemporaryFile()
    try:
        file_1.write("""<html lang="en"><body tdi:overlay="huh">yay.</body></html>""")
        file_1.flush()

        file_2.write("""<html><body tdi:overlay="huh">file 2!</body></html>""")
        file_2.flush()

        template = html.from_files([file_1.name, file_2.name])
    finally:
        file_2.close()
finally:
    file_1.close()

template.render()
Ejemplo n.º 2
0
        weeks, rest = divmod((self.end - self.start).days, 7)
        weeks += bool(rest)
        # repeat over each displayed week (each monday)
        node.repeat(None, (self.start + _dt.timedelta(week * 7)
            for week in xrange(weeks)
        ))

    def render_col(self, node):
        monday = node.ctx[1]
        # repeat over each weekday
        node.repeat(self.repeat_col, (monday + _dt.timedelta(day)
            for day in xrange(7)
        ))

    def repeat_col(self, node, date):
        node.content = date.day
        if date.weekday() >= 5:
            _html_tools.class_add(node, u'weekend')
        if not(self.first <= date < self.end):
            _html_tools.class_add(node, u'fill')
        if date == self.today:
            _html_tools.class_add(node, u'today')

    def separate_col(self, node):
        if node.ctx[0] != 3:
            node.remove()


tpl = _html.from_files(['layout.html', 'calendar.html'])
tpl.render(Model(2014, 1))
Ejemplo n.º 3
0
Archivo: bug.py Proyecto: AvdN/tdi
#!/usr/bin/env python
"""
Submitted by: Roland Sommer <[email protected]>

segfault in tdi.c
"""
import warnings as _warnings
_warnings.resetwarnings()
_warnings.filterwarnings('error')

import os
from tdi import html

template = html.from_files([
    '_baselayout.html', 'results.html', '_widgets.html',
], basedir=os.path.dirname(os.path.abspath(__file__)))

for _ in xrange(10):
    template.render(startnode="resulttable")
print