コード例 #1
0
	def makenode():
		with xsc.build():
			with html.html() as e:
				with html.head():
					+html.style("p {color: red;}", type="text/css")
					+html.style("p {color: blue;}", type="text/css", title="blue")
				with html.body():
					+html.p("gurk")
		return e
コード例 #2
0
 def makenode():
     with xsc.build():
         with html.html() as e:
             with html.head():
                 +html.style("p {color: red;}", type="text/css")
                 +html.style(
                     "p {color: blue;}", type="text/css", title="blue")
             with html.body():
                 +html.p("gurk")
     return e
コード例 #3
0
def test_applystylesheets_media():
    # Check that media="screen" picks up the media stylesheet
    with xsc.build():
        with html.html() as e:
            with html.head():
                +html.style("p {color: red;}", type="text/css", media="screen")
            with html.body():
                +html.p("gurk")

    css.applystylesheets(e, media="screen")

    assert str(e.walknodes(html.p)[0].attrs.style) == "color: red;"

    # Check that media="screen" doesn't pick up the print stylesheet
    with xsc.build():
        with html.html() as e:
            with html.head():
                +html.style("p {color: red;}", type="text/css", media="screen")
            with html.body():
                +html.p("gurk")

    css.applystylesheets(e, media="print")

    assert str(e.walknodes(html.p)[0].attrs.style) == ""

    # Check that @media rules are treated properly
    with xsc.build():
        with html.html() as e:
            with html.head():
                +html.style("@media screen { p {color: red;}}",
                            type="text/css")
            with html.body():
                +html.p("gurk")

    css.applystylesheets(e, media="screen")

    assert str(e.walknodes(html.p)[0].attrs.style) == "color: red;"

    with xsc.build():
        with html.html() as e:
            with html.head():
                +html.style("@media screen { p {color: red;}}",
                            type="text/css")
            with html.body():
                +html.p("gurk")

    css.applystylesheets(e, media="print")

    assert str(e.walknodes(html.p)[0].attrs.style) == ""
コード例 #4
0
def test_applystylesheets_media():
	# Check that media="screen" picks up the media stylesheet
	with xsc.build():
		with html.html() as e:
			with html.head():
				+html.style("p {color: red;}", type="text/css", media="screen")
			with html.body():
				+html.p("gurk")

	css.applystylesheets(e, media="screen")

	assert str(e.walknodes(html.p)[0].attrs.style) == "color: red;"

	# Check that media="screen" doesn't pick up the print stylesheet
	with xsc.build():
		with html.html() as e:
			with html.head():
				+html.style("p {color: red;}", type="text/css", media="screen")
			with html.body():
				+html.p("gurk")

	css.applystylesheets(e, media="print")

	assert str(e.walknodes(html.p)[0].attrs.style) == ""

	# Check that @media rules are treated properly
	with xsc.build():
		with html.html() as e:
			with html.head():
				+html.style("@media screen { p {color: red;}}", type="text/css")
			with html.body():
				+html.p("gurk")

	css.applystylesheets(e, media="screen")

	assert str(e.walknodes(html.p)[0].attrs.style) == "color: red;"

	with xsc.build():
		with html.html() as e:
			with html.head():
				+html.style("@media screen { p {color: red;}}", type="text/css")
			with html.body():
				+html.p("gurk")

	css.applystylesheets(e, media="print")

	assert str(e.walknodes(html.p)[0].attrs.style) == ""
コード例 #5
0
def test_applystylesheets1():
	with xsc.build():
		with html.html() as e:
			with html.head():
				+html.style("p {color: red;}", type="text/css")
			with html.body():
				+html.p("gurk")

	css.applystylesheets(e)

	assert str(e.walknodes(html.p)[0].attrs.style) == "color: red;"
	assert list(e.walknodes(html.style)) == []
コード例 #6
0
def test_applystylesheets1():
    with xsc.build():
        with html.html() as e:
            with html.head():
                +html.style("p {color: red;}", type="text/css")
            with html.body():
                +html.p("gurk")

    css.applystylesheets(e)

    assert str(e.walknodes(html.p)[0].attrs.style) == "color: red;"
    assert list(e.walknodes(html.style)) == []
コード例 #7
0
def test_applystylesheets5():
	with xsc.build():
		with html.html() as e:
			with html.head():
				+html.style("p#id42 {color: red;}", type="text/css")
			with html.body():
				+html.p("gurk", id="id42", style="color: blue;")

	css.applystylesheets(e)

	# stylesheet always wins (at least in CSS 2.1 and 3)
	assert str(e.walknodes(html.p)[0].attrs.style) == "color: blue;"
	assert list(e.walknodes(html.style)) == []
コード例 #8
0
def test_applystylesheets4():
	with xsc.build():
		with html.html() as e:
			with html.head():
				+html.style("#id42 {color: red;}", type="text/css")
			with html.body():
				+html.p("gurk", id="id42", style="color: blue;")

	css.applystylesheets(e)

	# style attribute wins
	assert str(e.walknodes(html.p)[0].attrs.style) == "color: blue;"
	assert list(e.walknodes(html.style)) == []
コード例 #9
0
def test_applystylesheets5():
    with xsc.build():
        with html.html() as e:
            with html.head():
                +html.style("p#id42 {color: red;}", type="text/css")
            with html.body():
                +html.p("gurk", id="id42", style="color: blue;")

    css.applystylesheets(e)

    # stylesheet always wins (at least in CSS 2.1 and 3)
    assert str(e.walknodes(html.p)[0].attrs.style) == "color: blue;"
    assert list(e.walknodes(html.style)) == []
コード例 #10
0
def test_applystylesheets4():
    with xsc.build():
        with html.html() as e:
            with html.head():
                +html.style("#id42 {color: red;}", type="text/css")
            with html.body():
                +html.p("gurk", id="id42", style="color: blue;")

    css.applystylesheets(e)

    # style attribute wins
    assert str(e.walknodes(html.p)[0].attrs.style) == "color: blue;"
    assert list(e.walknodes(html.style)) == []
コード例 #11
0
ファイル: recipe-483759.py プロジェクト: bhramoss/code
    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)
)

print e.asBytes(encoding="iso-8859-1")
コード例 #12
0
ファイル: recipe-483759.py プロジェクト: zlrs/code-1
    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))

print e.asBytes(encoding="iso-8859-1")