def createelement():
	return html.span(
		1,
		2,
		class_="gurk",
		id=(1, 2, (3, 4)),
		lang=(
			True,
			False,
			url.URL("http://www.python.org/"),
			html.abbr(
				xml.XML(),
				"hurz",
				specials.tab(),
				abbr.xist(),
				None,
				1,
				2.0,
				"3",
				"4",
				(5, 6),
				[7, 8],
				html.span("gurk"),
				title="hurz"
			)
		)
	)
	def convert(self, converter):
		e = xsc.Frag(
			xml.XML(), "\n",
			html.DocTypeXHTML10transitional(), "\n",
			html.html(
				html.head(
					meta.contenttype(),
					html.title(
						"Python code coverage",
						ul4.if_("filename"),
							": ", ul4.printx("filename"),
						ul4.else_(),
							" (", ul4.print_("format(timestamp, '%Y-%m-%d')"), ")",
						ul4.end("if"),
					),
					meta.stylesheet(href="/coverage.css"),
					meta.stylesheet(href="/coverage_sortfilelist.css"),
					htmlspecials.javascript(src="/coverage.js"),
				),
				html.body(
					html.div(
						html.div(
							html.a(
								htmlspecials.autoimg(src="http://www.python.org/images/python-logo.gif", alt="Python", border=0),
								href="http://www.python.org/",
							),
							class_="logo",
						),
						html.div(
							ul4.for_("(i, item) in enumerate(crumbs)"),
								html.span(
									html.span(
										ul4.if_("i"),
											">",
										ul4.else_(),
											"\xbb",
										ul4.end("if"),
										class_="bullet",
									),
									ul4.if_("item.href"),
										html.a(ul4.printx("item.title"), href=ul4.printx("item.href")),
									ul4.else_(),
										html.span(ul4.printx("item.title"), class_="here"),
									ul4.end("if"),
								ul4.end("for"),
								class_="crumb",
							),
							class_="crumbs",
						),
						class_="header",
					),
					html.div(
						self.content,
						class_="content",
					),
					onload=ul4.attr_if(ul4.printx("onload"), cond="onload"),
				),
			),
		)
		return e.convert(converter)
def test_pretty():
	tests = [
		(html.p("apple", "tree"),  b"<p>appletree</p>"),
		(html.p("apple", html.br(), "tree"), b"<p>apple<br />tree</p>"),
		(html.p(php.php("apple")), b"<p>\n\t<?php apple?>\n</p>"),
		(html.p(php.php("apple"), "tree"), b"<p><?php apple?>tree</p>"),
		(
			html.div(2*html.p("apple", "tree"), html.br()),
			b"<div>\n\t<p>appletree</p>\n\t<p>appletree</p>\n\t<br />\n</div>"
		),
		(
			html.div(
				php.php("apple"),
				html.p("apple", "tree"),
				html.div(
					html.p("apple"),
					html.p("tree"),
				),
				html.br()
			),
			b"<div>\n\t<?php apple?>\n\t<p>appletree</p>\n\t<div>\n\t\t<p>apple</p>\n\t\t<p>tree</p>\n\t</div>\n\t<br />\n</div>"
		),
		(
			html.ul(
				ul4.for_("name in names"),
				html.li(
					ul4.printx("name"),
				),
				ul4.end("for"),
			),
			b"<ul>\n\t<?for name in names?>\n\t\t<li>\n\t\t\t<?printx name?>\n\t\t</li>\n\t<?end for?>\n</ul>"
		),
		(
			xsc.Frag(
				ul4.if_("n == 0"),
					html.span("zero"),
				ul4.elif_("n == 1"),
					html.span("one"),
				ul4.else_(),
					html.span("many"),
				ul4.end("if"),
			),
			b"<?if n == 0?>\n\t<span>zero</span>\n<?elif n == 1?>\n\t<span>one</span>\n<?else ?>\n\t<span>many</span>\n<?end if?>"
		),
		(
			xsc.Frag(
				ul4.def_("spam"),
					ul4.printx("eggs"),
				ul4.end("def"),
			),
			b"<?def spam?>\n\t<?printx eggs?>\n<?end def?>"
		),
	]
	for (got, exp) in tests:
		got.pretty().bytes() == exp
def createfrag():
	return xsc.Frag(
		xml.XML(),
		html.DocTypeHTML401transitional(),
		xsc.Comment("gurk"),
		"hurz",
		specials.tab(),
		abbr.xist(),
		None,
		True,
		False,
		1,
		2.0,
		"3",
		"4",
		(5, 6),
		[7, 8],
		html.div(
			align="left"
		),
		url.URL("http://www.python.org/"),
		html.span(
			1,
			2,
			class_="gurk",
			id=(1, 2, (3, 4)),
			lang=(
				True,
				False,
				url.URL("http://www.python.org/"),
				html.abbr(
					xml.XML(),
					"hurz",
					specials.tab(),
					abbr.xist(),
					None,
					1,
					2.0,
					"3",
					"4",
					(5, 6),
					[7, 8],
					html.span("gurk"),
					title="hurz"
				)
			)
		)
	)
def test_allowschemerelurls():
    node = html.a(href="http://www.example.org/index.html")
    assert node.bytes() == b'<a href="http://www.example.org/index.html"></a>'
    assert node.bytes(
        base="http://www.example.org") == b'<a href="index.html"></a>'
    assert node.bytes(base="http://www.example.com"
                      ) == b'<a href="http://www.example.org/index.html"></a>'
    assert node.bytes(base="http://www.example.com", allowschemerelurls=True
                      ) == b'<a href="//www.example.org/index.html"></a>'

    node = specials.url("http://www.example.org/index.html")
    assert node.bytes() == b'http://www.example.org/index.html'
    assert node.bytes(base="http://www.example.org") == b'index.html'
    assert node.bytes(
        base="http://www.example.com") == b'http://www.example.org/index.html'
    assert node.bytes(
        base="http://www.example.com",
        allowschemerelurls=True) == b'//www.example.org/index.html'

    node = html.span(
        style="background: url(http://www.example.org/index.html)")
    assert node.bytes(
    ) == b'<span style="background: url(http://www.example.org/index.html)"></span>'
    assert node.bytes(base="http://www.example.org"
                      ) == b'<span style="background: url(index.html)"></span>'
    assert node.bytes(
        base="http://www.example.com"
    ) == b'<span style="background: url(http://www.example.org/index.html)"></span>'
    assert node.bytes(
        base="http://www.example.com", allowschemerelurls=True
    ) == b'<span style="background: url(//www.example.org/index.html)"></span>'
def test_publishescaped():
    s = """\x04<&'"\xff>"""
    node = xsc.Text(s)
    assert node.bytes(encoding="ascii") == b"""&#4;&lt;&amp;'"&#255;&gt;"""
    node = html.span(class_=s)
    assert node.bytes(
        encoding="ascii",
        xhtml=2) == b"""<span class="&#4;&lt;&amp;'&quot;&#255;&gt;"/>"""
Example #7
0
	def convert(self, converter):
		e = html.li(
			html.span(self[name], class_="name")
		)
		for e2 in self[duration]:
			e.append(" (", e2, ")")
		e.append(self[purchase])
		return e.convert(converter)
Example #8
0
def createelement():
    return html.span(1,
                     2,
                     class_="gurk",
                     id=(1, 2, (3, 4)),
                     lang=(True, False, url.URL("http://www.python.org/"),
                           html.abbr(xml.XML(),
                                     "hurz",
                                     specials.tab(),
                                     abbr.xist(),
                                     None,
                                     1,
                                     2.0,
                                     "3",
                                     "4", (5, 6), [7, 8],
                                     html.span("gurk"),
                                     title="hurz")))
	def convert(self, converter):
		e = html.li(
			html.span(self[name], class_="name")
		)
		for e2 in self[duration]:
			e.append(" (", e2, ")")
		e.append(self[purchase])
		return e.convert(converter)
Example #10
0
def test_pretty():
    tests = [
        (html.p("apple", "tree"), b"<p>appletree</p>"),
        (html.p("apple", html.br(), "tree"), b"<p>apple<br />tree</p>"),
        (html.p(php.php("apple")), b"<p>\n\t<?php apple?>\n</p>"),
        (html.p(php.php("apple"), "tree"), b"<p><?php apple?>tree</p>"),
        (html.div(2 * html.p("apple", "tree"), html.br()),
         b"<div>\n\t<p>appletree</p>\n\t<p>appletree</p>\n\t<br />\n</div>"),
        (html.div(php.php("apple"), html.p("apple", "tree"),
                  html.div(
                      html.p("apple"),
                      html.p("tree"),
                  ), html.br()),
         b"<div>\n\t<?php apple?>\n\t<p>appletree</p>\n\t<div>\n\t\t<p>apple</p>\n\t\t<p>tree</p>\n\t</div>\n\t<br />\n</div>"
         ),
        (html.ul(
            ul4.for_("name in names"),
            html.li(ul4.printx("name"), ),
            ul4.end("for"),
        ),
         b"<ul>\n\t<?for name in names?>\n\t\t<li>\n\t\t\t<?printx name?>\n\t\t</li>\n\t<?end for?>\n</ul>"
         ),
        (xsc.Frag(
            ul4.if_("n == 0"),
            html.span("zero"),
            ul4.elif_("n == 1"),
            html.span("one"),
            ul4.else_(),
            html.span("many"),
            ul4.end("if"),
        ),
         b"<?if n == 0?>\n\t<span>zero</span>\n<?elif n == 1?>\n\t<span>one</span>\n<?else ?>\n\t<span>many</span>\n<?end if?>"
         ),
        (xsc.Frag(
            ul4.def_("spam"),
            ul4.printx("eggs"),
            ul4.end("def"),
        ), b"<?def spam?>\n\t<?printx eggs?>\n<?end def?>"),
    ]
    for (got, exp) in tests:
        got.pretty().bytes() == exp
Example #11
0
def createfrag():
    return xsc.Frag(
        xml.XML(),
        html.DocTypeHTML401transitional(), xsc.Comment("gurk"), "hurz",
        specials.tab(), abbr.xist(), None, True, False, 1, 2.0, "3", "4",
        (5, 6), [7, 8], html.div(align="left"),
        url.URL("http://www.python.org/"),
        html.span(1,
                  2,
                  class_="gurk",
                  id=(1, 2, (3, 4)),
                  lang=(True, False, url.URL("http://www.python.org/"),
                        html.abbr(xml.XML(),
                                  "hurz",
                                  specials.tab(),
                                  abbr.xist(),
                                  None,
                                  1,
                                  2.0,
                                  "3",
                                  "4", (5, 6), [7, 8],
                                  html.span("gurk"),
                                  title="hurz"))))
Example #12
0
def createattrs():
    return html.span.Attrs(lang=(True, False,
                                 url.URL("http://www.python.org/"),
                                 html.abbr(xml.XML(),
                                           "hurz",
                                           specials.tab(),
                                           abbr.xist(),
                                           None,
                                           1,
                                           2.0,
                                           "3",
                                           "4", (5, 6), [7, 8],
                                           html.span("gurk"),
                                           title="hurz")))
Example #13
0
 def convert(self, converter):
     e = html.li(html.span(self[name], class_="name"))
     durations = xsc.Frag(self[duration])
     rcs = xsc.Frag(self[rc])
     if len(durations) or len(rcs):
         e.append(" (")
         if len(durations):
             e.append(durations[0])
             if len(rcs):
                 e.append("; ")
         if len(rcs):
             e.append("RC ", rcs.withsep(", "))
         e.append(")")
     e.append(self[purchase])
     return e.convert(converter)
	def convert(self, converter):
		e = html.li(
			html.span(self[name], class_="name")
		)
		durations = xsc.Frag(self[duration])
		rcs = xsc.Frag(self[rc])
		if len(durations) or len(rcs):
			e.append(" (")
			if len(durations):
				e.append(durations[0])
				if len(rcs):
					e.append("; ")
			if len(rcs):
				e.append("RC ", rcs.withsep(", "))
			e.append(")")
		e.append(self[purchase])
		return e.convert(converter)
def test_allowschemerelurls():
	node = html.a(href="http://www.example.org/index.html")
	assert node.bytes() == b'<a href="http://www.example.org/index.html"></a>'
	assert node.bytes(base="http://www.example.org") == b'<a href="index.html"></a>'
	assert node.bytes(base="http://www.example.com") == b'<a href="http://www.example.org/index.html"></a>'
	assert node.bytes(base="http://www.example.com", allowschemerelurls=True) == b'<a href="//www.example.org/index.html"></a>'

	node = specials.url("http://www.example.org/index.html")
	assert node.bytes() == b'http://www.example.org/index.html'
	assert node.bytes(base="http://www.example.org") == b'index.html'
	assert node.bytes(base="http://www.example.com") == b'http://www.example.org/index.html'
	assert node.bytes(base="http://www.example.com", allowschemerelurls=True) == b'//www.example.org/index.html'

	node = html.span(style="background: url(http://www.example.org/index.html)")
	assert node.bytes() == b'<span style="background: url(http://www.example.org/index.html)"></span>'
	assert node.bytes(base="http://www.example.org") == b'<span style="background: url(index.html)"></span>'
	assert node.bytes(base="http://www.example.com") == b'<span style="background: url(http://www.example.org/index.html)"></span>'
	assert node.bytes(base="http://www.example.com", allowschemerelurls=True) == b'<span style="background: url(//www.example.org/index.html)"></span>'
def test_with():
	with xsc.build():
		with html.ul() as e:
			+html.li(1)
			+html.li(2)
	assert e == html.ul(html.li(1), html.li(2))

	with xsc.build():
		with html.p() as e:
			+html.span(1)
			with html.b():
				+html.span(2)
			+html.span(3)
	assert e == html.p(html.span(1), html.b(html.span(2)), html.span(3))

	with xsc.build():
		with html.p() as e:
			+xsc.Text(1)
	assert e == html.p(1)

	with xsc.build():
		with html.p() as e:
			+xml.Attrs(lang="de")
	assert e == html.p(xml.Attrs(lang="de"))
	assert e.bytes() == b'<p xml:lang="de"></p>'

	with xsc.build():
		with xsc.Frag() as e:
			+xsc.Text(1)
	assert e == xsc.Frag(1)

	# Test add()
	with xsc.build():
		with html.p() as e:
			xsc.add(1)
	assert e == html.p(1)

	with xsc.build():
		with html.p() as e:
			xsc.add(class_="foo")
	assert e == html.p(class_="foo")

	with xsc.build():
		with html.p() as e:
			xsc.add({"class": "foo"})
	assert e == html.p(class_="foo")

	with xsc.build():
		with html.p() as e:
			xsc.add(xml.Attrs(lang="en"))
	assert e == html.p(xml.Attrs(lang="en"))
Example #17
0
def test_with():
    with xsc.build():
        with html.ul() as e:
            +html.li(1)
            +html.li(2)
    assert e == html.ul(html.li(1), html.li(2))

    with xsc.build():
        with html.p() as e:
            +html.span(1)
            with html.b():
                +html.span(2)
            +html.span(3)
    assert e == html.p(html.span(1), html.b(html.span(2)), html.span(3))

    with xsc.build():
        with html.p() as e:
            +xsc.Text(1)
    assert e == html.p(1)

    with xsc.build():
        with html.p() as e:
            +xml.Attrs(lang="de")
    assert e == html.p(xml.Attrs(lang="de"))
    assert e.bytes() == b'<p xml:lang="de"></p>'

    with xsc.build():
        with xsc.Frag() as e:
            +xsc.Text(1)
    assert e == xsc.Frag(1)

    # Test add()
    with xsc.build():
        with html.p() as e:
            xsc.add(1)
    assert e == html.p(1)

    with xsc.build():
        with html.p() as e:
            xsc.add(class_="foo")
    assert e == html.p(class_="foo")

    with xsc.build():
        with html.p() as e:
            xsc.add({"class": "foo"})
    assert e == html.p(class_="foo")

    with xsc.build():
        with html.p() as e:
            xsc.add(xml.Attrs(lang="en"))
    assert e == html.p(xml.Attrs(lang="en"))
def createattr():
	return html.span.Attrs.lang(
		True,
		False,
		url.URL("http://www.python.org/"),
		html.abbr(
			xml.XML(),
			"hurz",
			specials.tab(),
			abbr.xist(),
			None,
			1,
			2.0,
			"3",
			"4",
			(5, 6),
			[7, 8],
			html.span("gurk"),
			title="hurz"
		)
	)
def test_css():
    with xsc.build():
        with html.div(id=1) as e:
            with html.ul(id=2):
                +html.li("foo")
                +html.li()

    assert list(e.walknodes(css.selector("div"))) == [e]
    assert list(e.walknodes(css.selector("li"))) == [e[0][0], e[0][1]]
    assert list(e.walknodes(css.selector("div#1"))) == [e]
    assert list(e.walknodes(css.selector("#2"))) == [e[0]]
    assert list(e.walknodes(css.selector(":empty"))) == [e[0][1]]
    assert list(e.walknodes(css.selector("li:empty"))) == [e[0][1]]
    assert list(e.walknodes(css.selector("div :empty"))) == [e[0][1]]
    assert list(e.walknodes(css.selector("div>*:empty"))) == []
    assert list(e.walknodes(css.selector("div>:empty"))) == []
    assert list(e.walknodes(css.selector("*|li"))) == [e[0][0], e[0][1]]
    assert list(e.walknodes(css.selector("h|li",
                                         prefixes={"h": html
                                                   }))) == [e[0][0], e[0][1]]
    assert list(e.walknodes(css.selector("h|li", prefixes={"h":
                                                           specials}))) == []

    with xsc.build():
        with xsc.Frag() as e:
            +html.div("foo")
            +xsc.Text("filler")
            +html.p("foo")
            +xsc.Text("filler")
            +html.ul(html.li("foo"))

    assert list(e.walknodes(css.selector("div + p"))) == [e[2]]
    assert list(e.walknodes(css.selector("div + ul"))) == []
    assert list(e.walknodes(css.selector("ul + p"))) == []
    assert list(e.walknodes(css.selector("div ~ p"))) == [e[2]]
    assert list(e.walknodes(css.selector("div ~ ul"))) == [e[4]]
    assert list(e.walknodes(css.selector("p ~ div"))) == []
    assert list(e.walknodes(css.selector("div:first-child + p"))) == [e[2]]
    assert list(e.walknodes(css.selector("*:first-child + p"))) == [e[2]]

    with xsc.build():
        with xsc.Frag() as e:
            +html.span(html.b("hurz"), "gurk", html.em("hinz"),
                       html.em("kunz"))
            +html.em("hurz")
            +html.em("hinz")
            +xsc.Text("nix")
            +html.i("kunz")

    assert list(e.walknodes(
        css.selector("*:only-of-type"))) == [e[0], e[0][0], e[4]]
    assert list(e.walknodes(css.selector("*:nth-child(1)"))) == [e[0], e[0][0]]
    assert list(e.walknodes(css.selector("*:nth-child(2)"))) == [e[0][2], e[1]]
    assert list(e.walknodes(
        css.selector("*:nth-last-child(1)"))) == [e[0][3], e[4]]
    assert list(e.walknodes(
        css.selector("*:nth-last-child(2)"))) == [e[0][2], e[2]]
    assert list(e.walknodes(css.selector("*:nth-of-type(1)"))) == [
        e[0], e[0][0], e[0][2], e[1], e[4]
    ]
    assert list(e.walknodes(
        css.selector("*:nth-of-type(2)"))) == [e[0][3], e[2]]
    assert list(e.walknodes(css.selector("*:nth-last-of-type(1)"))) == [
        e[0], e[0][0], e[0][3], e[2], e[4]
    ]
    assert list(e.walknodes(
        css.selector("*:nth-last-of-type(2)"))) == [e[0][2], e[1]]

    e = xsc.Frag(html.span(html.b("hurz"), "gurk"))
    assert list(e.walknodes(css.selector("*:only-child"))) == [e[0], e[0][0]]

    with xsc.build():
        with xsc.Frag() as e:
            +html.em(class_="gurk", lang="en")
            +html.em(class_="gurk hurz", lang="en-us")
            +html.em(class_="hurz", lang="de")

    assert list(e.walknodes(css.selector("em[class='gurk']"))) == [e[0]]
    assert list(e.walknodes(css.selector("em[class~='gurk']"))) == [e[0], e[1]]
    assert list(e.walknodes(css.selector("em[lang|='en']"))) == [e[0], e[1]]
def test_publishescaped():
	s = """\x04<&'"\xff>"""
	node = xsc.Text(s)
	assert node.bytes(encoding="ascii") == b"""&#4;&lt;&amp;'"&#255;&gt;"""
	node = html.span(class_=s)
	assert node.bytes(encoding="ascii", xhtml=2) == b"""<span class="&#4;&lt;&amp;'&quot;&#255;&gt;"/>"""
def test_css():
	with xsc.build():
		with html.div(id=1) as e:
			with html.ul(id=2):
				+html.li("foo")
				+html.li()

	assert list(e.walknodes(css.selector("div"))) == [e]
	assert list(e.walknodes(css.selector("li"))) == [e[0][0], e[0][1]]
	assert list(e.walknodes(css.selector("div#1"))) == [e]
	assert list(e.walknodes(css.selector("#2"))) == [e[0]]
	assert list(e.walknodes(css.selector(":empty"))) == [e[0][1]]
	assert list(e.walknodes(css.selector("li:empty"))) == [e[0][1]]
	assert list(e.walknodes(css.selector("div :empty"))) == [e[0][1]]
	assert list(e.walknodes(css.selector("div>*:empty"))) == []
	assert list(e.walknodes(css.selector("div>:empty"))) == []
	assert list(e.walknodes(css.selector("*|li"))) == [e[0][0], e[0][1]]
	assert list(e.walknodes(css.selector("h|li", prefixes={"h": html}))) == [e[0][0], e[0][1]]
	assert list(e.walknodes(css.selector("h|li", prefixes={"h": specials}))) == []

	with xsc.build():
		with xsc.Frag() as e:
			+html.div("foo")
			+xsc.Text("filler")
			+html.p("foo")
			+xsc.Text("filler")
			+html.ul(html.li("foo"))

	assert list(e.walknodes(css.selector("div + p"))) == [e[2]]
	assert list(e.walknodes(css.selector("div + ul"))) == []
	assert list(e.walknodes(css.selector("ul + p"))) == []
	assert list(e.walknodes(css.selector("div ~ p"))) == [e[2]]
	assert list(e.walknodes(css.selector("div ~ ul"))) == [e[4]]
	assert list(e.walknodes(css.selector("p ~ div"))) == []
	assert list(e.walknodes(css.selector("div:first-child + p"))) == [e[2]]
	assert list(e.walknodes(css.selector("*:first-child + p"))) == [e[2]]

	with xsc.build():
		with xsc.Frag() as e:
			+html.span(html.b("hurz"), "gurk", html.em("hinz"), html.em("kunz"))
			+html.em("hurz")
			+html.em("hinz")
			+xsc.Text("nix")
			+html.i("kunz")

	assert list(e.walknodes(css.selector("*:only-of-type"))) == [e[0], e[0][0], e[4]]
	assert list(e.walknodes(css.selector("*:nth-child(1)"))) == [e[0], e[0][0]]
	assert list(e.walknodes(css.selector("*:nth-child(2)"))) == [e[0][2], e[1]]
	assert list(e.walknodes(css.selector("*:nth-last-child(1)"))) == [e[0][3], e[4]]
	assert list(e.walknodes(css.selector("*:nth-last-child(2)"))) == [e[0][2], e[2]]
	assert list(e.walknodes(css.selector("*:nth-of-type(1)"))) == [e[0], e[0][0], e[0][2], e[1], e[4]]
	assert list(e.walknodes(css.selector("*:nth-of-type(2)"))) == [e[0][3], e[2]]
	assert list(e.walknodes(css.selector("*:nth-last-of-type(1)"))) == [e[0], e[0][0], e[0][3], e[2], e[4]]
	assert list(e.walknodes(css.selector("*:nth-last-of-type(2)"))) == [e[0][2], e[1]]

	e = xsc.Frag(html.span(html.b("hurz"), "gurk"))
	assert list(e.walknodes(css.selector("*:only-child"))) == [e[0], e[0][0]]

	with xsc.build():
		with xsc.Frag() as e:
			+html.em(class_="gurk", lang="en")
			+html.em(class_="gurk hurz", lang="en-us")
			+html.em(class_="hurz", lang="de")

	assert list(e.walknodes(css.selector("em[class='gurk']"))) == [e[0]]
	assert list(e.walknodes(css.selector("em[class~='gurk']"))) == [e[0], e[1]]
	assert list(e.walknodes(css.selector("em[lang|='en']"))) == [e[0], e[1]]
Example #22
0
pre
{
    margin: 0px 30px 10px 30px;
    font-size: 11px;
    line-height: 18px;
    border: 1px solid #eee;
    background-color: #fafafa;
    padding: 1px 5px 2px 5px;
    overflow: auto;
}
"""

now = datetime.datetime.now()

node = xsc.Frag(html.h1("Cronjobs ", html.span("(generated at %s)" % now.strftime("%d.%m.%Y %H:%M"), class_="note")))

for host in hosts:
    node.append(html.h2(host.name))
    for (user, crontab) in sorted(host.getcrontabs()):
        node.append(html.h3(user, "@", host.name))
        node.append(html.pre(crontab.decode("latin-1").strip()))

node = xsc.Frag(
    xml.XML10(), "\n",
    html.head(
        meta.contenttype(),
        html.title("Cronjobs"),
        html.style(style, type="text/css"),
    ),
    html.body(node)
Example #23
0
    margin: 0px 30px 10px 30px;
    font-size: 11px;
    line-height: 18px;
    border: 1px solid #eee;
    background-color: #fafafa;
    padding: 1px 5px 2px 5px;
    overflow: auto;
}
"""

now = datetime.datetime.now()

node = xsc.Frag(
    html.h1(
        "Cronjobs ",
        html.span("(generated at %s)" % now.strftime("%d.%m.%Y %H:%M"),
                  class_="note")))

for host in hosts:
    node.append(html.h2(host.name))
    for (user, crontab) in sorted(host.getcrontabs()):
        node.append(html.h3(user, "@", host.name))
        node.append(html.pre(crontab.decode("latin-1").strip()))

node = xsc.Frag(
    xml.XML10(), "\n",
    html.head(
        meta.contenttype(),
        html.title("Cronjobs"),
        html.style(style, type="text/css"),
    ), html.body(node))