def test_plaintable():
    e = htmlspecials.plaintable().conv()
    assert str(e.attrs.border) == "0"
    assert str(e.attrs.cellspacing) == "0"
    assert str(e.attrs.cellpadding) == "0"

    e = htmlspecials.plaintable(border=1, cellspacing=2, cellpadding=3).conv()
    assert str(e.attrs.border) == "1"
    assert str(e.attrs.cellspacing) == "2"
    assert str(e.attrs.cellpadding) == "3"
def test_plaintable():
	e = htmlspecials.plaintable().conv()
	assert str(e.attrs.border) == "0"
	assert str(e.attrs.cellspacing) == "0"
	assert str(e.attrs.cellpadding) == "0"

	e = htmlspecials.plaintable(border=1, cellspacing=2, cellpadding=3).conv()
	assert str(e.attrs.border) == "1"
	assert str(e.attrs.cellspacing) == "2"
	assert str(e.attrs.cellpadding) == "3"
def sqlservercode():
    return xsc.Frag(
        toxic.args("@search varchar(100)"), toxic.vars("declare @i integer;"),
        htmlspecials.plaintable(
            toxic.code("""
				set @i = 1;

				declare @row_name varchar(100);
				declare person_cursor cursor for
					select name from person where name like @search

				open person_cursor

				while 1 = 1
				begin
					fetch next from person_cursor into @row_name;
					if (@@fetch_status != 0)
						break

					"""),
            html.tr(html.th(toxic.expr("@i"), align="right"),
                    html.td(toxic.expr("schema.xmlescape(@row_name)"))),
            toxic.code("""
					set @i = @i+1;
				end

				close person_cursor
				deallocate person_cursor
			""")))
def sqlservercode():
	return xsc.Frag(
		toxic.args("@search varchar(100)"),
		toxic.vars("declare @i integer;"),
		htmlspecials.plaintable(
			toxic.code("""
				set @i = 1;

				declare @row_name varchar(100);
				declare person_cursor cursor for
					select name from person where name like @search

				open person_cursor

				while 1 = 1
				begin
					fetch next from person_cursor into @row_name;
					if (@@fetch_status != 0)
						break

					"""),
					html.tr(
						html.th(toxic.expr("@i"), align="right"),
						html.td(toxic.expr("schema.xmlescape(@row_name)"))
					),
					toxic.code("""
					set @i = @i+1;
				end

				close person_cursor
				deallocate person_cursor
			""")
		)
	)
Example #5
0
def test_plaintableattrs():
    e = htmlspecials.plaintable(border=3)
    assert isinstance(e["border"], html.table.Attrs.border)
    assert isinstance(e["cellpadding"], html.table.Attrs.cellpadding)
    e = e.conv()
    assert isinstance(e["border"], html.table.Attrs.border)
    assert isinstance(e["cellpadding"], html.table.Attrs.cellpadding)
	def index(self):
		def isimg(name):
			if name.endswith(".gif") or name.endswith(".jpg") or name.endswith(".png"):
				return os.path.isfile(os.path.join(self.directory, name))
			return False

		names = [name for name in os.listdir(self.directory) if isimg(name)]
		names.sort()

		collect = xsc.Frag()
		i = 0

		with xsc.build():
			with xsc.Frag() as e:
				+xml.XML()
				+html.DocTypeXHTML10transitional()
				with html.html():
					with html.head():
						+meta.contenttype()
						+html.title("All images from ", doc.z(self.directory))
						+html.link(rel="stylesheet", type="text/css", href="images.css")
					with html.body():
						with htmlspecials.plaintable():
							for name in names:
								collect.append(html.td(htmlspecials.autoimg(src=("/images/", name)), html.br(), name, align="center"))
								i += 1
								if i == cols:
									+html.tr(collect)
									collect = xsc.Frag()
									i = 0
							if collect:
								+html.tr(collect)

		return e.conv().bytes()
def test_plaintableattrs():
	e = htmlspecials.plaintable(border=3)
	assert isinstance(e["border"], html.table.Attrs.border)
	assert isinstance(e["cellpadding"], html.table.Attrs.cellpadding)
	e = e.conv()
	assert isinstance(e["border"], html.table.Attrs.border)
	assert isinstance(e["cellpadding"], html.table.Attrs.cellpadding)
def oraclecode():
    return xsc.Frag(
        toxic.args("search in varchar2"), toxic.vars("i integer;"),
        htmlspecials.plaintable(
            toxic.code("""
				i := 1;
				for row in (select name from person where name like search) loop
					"""),
            html.tr(html.th(toxic.expr("i"), align="right"),
                    html.td(toxic.expr("xmlescape(row.name)"))),
            toxic.code("""
					i := i+1;
				end loop;
			""")))
def oraclecode():
	return xsc.Frag(
		toxic.args("search in varchar2"),
		toxic.vars("i integer;"),
		htmlspecials.plaintable(
			toxic.code("""
				i := 1;
				for row in (select name from person where name like search) loop
					"""),
					html.tr(
						html.th(toxic.expr("i"), align="right"),
						html.td(toxic.expr("xmlescape(row.name)"))
					),
					toxic.code("""
					i := i+1;
				end loop;
			""")
		)
	)
Example #10
0
    def index(self):
        def isimg(name):
            if name.endswith(".gif") or name.endswith(".jpg") or name.endswith(
                    ".png"):
                return os.path.isfile(os.path.join(self.directory, name))
            return False

        names = [name for name in os.listdir(self.directory) if isimg(name)]
        names.sort()

        collect = xsc.Frag()
        i = 0

        with xsc.build():
            with xsc.Frag() as e:
                +xml.XML()
                +html.DocTypeXHTML10transitional()
                with html.html():
                    with html.head():
                        +meta.contenttype()
                        +html.title("All images from ", doc.z(self.directory))
                        +html.link(rel="stylesheet",
                                   type="text/css",
                                   href="images.css")
                    with html.body():
                        with htmlspecials.plaintable():
                            for name in names:
                                collect.append(
                                    html.td(
                                        htmlspecials.autoimg(src=("/images/",
                                                                  name)),
                                        html.br(),
                                        name,
                                        align="center"))
                                i += 1
                                if i == cols:
                                    +html.tr(collect)
                                    collect = xsc.Frag()
                                    i = 0
                            if collect:
                                +html.tr(collect)

        return e.conv().bytes()
	def convert(self, converter):
		e = xsc.Frag(
			html.h1("Python code coverage for ", ul4.printx("filename")),
			htmlspecials.plaintable(
				html.thead(
					html.tr(
						html.th("#"),
						html.th("count"),
						html.th("content"),
					),
				),
				html.tbody(
					ul4.for_("(i, line) in enumerate(lines)"),
						html.tr(
							html.th(ul4.print_("i+1")),
							html.td(
								ul4.if_("not isnone(line.count) and line.count >= 0"),
									ul4.printx("line.count"),
								ul4.else_(),
									"n/a",
								ul4.end("if"),
								class_="count",
							),
							html.td(ul4.printx("line.content"), class_="line"),
							class_=ul4.attr_if(
								ul4.if_("isnone(line.count) or line.count < 0"),
									"uncoverable",
								ul4.elif_("not line.count"),
									"uncovered",
								ul4.end("if"),
								cond="isnone(line.count) or line.count <= 0",
							),
						),
					ul4.end("for"),
				),
				class_="file",
			)
		)
		return e.convert(converter)
	def convert(self, converter):
		e = xsc.Frag(
			html.h1("Python code coverage"),
			html.p("Generated at ", ul4.printx("format(now, '%Y-%m-%d %H:%M:%S')"), class_="note"),
			html.p("Last commit at ", ul4.printx("format(timestamp, '%Y-%m-%d %H:%M:%S')"), " by ", ul4.printx("author"), class_="note"),
			html.p("Changeset identification hash ", ul4.printx("changesetid"), class_="note"),
			html.p("Local revision number ", ul4.printx("revision"), class_="note"),
			html.p(html.a("Build log", href="buildlog.txt"), " ",html.a("Test log", href="testlog.txt"), class_="note"),
			htmlspecials.plaintable(
				html.thead(
					html.tr(
						html.th("Filename", id="filename"),
						html.th("# lines", id="nroflines"),
						html.th("# coverable lines", id="coverablelines"),
						html.th("# covered lines", id="coveredlines"),
						html.th("coverage", id="coverage"),
						html.th("distribution", id="distibution"),
					),
				),
				html.tbody(
					ul4.for_("file in files"),
						html.tr(
							html.th(
								html.a(
									ul4.printx("file.name"),
									href=(ul4.printx("file.name"), ".html"),
								),
								class_="filename",
							),
							html.td(
								ul4.printx("file.lines"),
								class_="nroflines",
							),
							html.td(
								ul4.printx("file.coverablelines"),
								class_="coverablelines",
							),
							html.td(
								ul4.printx("file.coveredlines"),
								class_="coveredlines",
							),
							html.td(
								ul4.if_("file.coverablelines"),
									ul4.printx("format((100.*file.coveredlines)/file.coverablelines, '.2f')"),
									"%",
								ul4.else_(),
									"n/a",
								ul4.end("if"),
								class_=(
									"coverage",
									ul4.if_("not file.coverablelines"),
										" disabled",
									ul4.end("if"),
								),
							),
							html.td(
								ul4.code("totalwidth = 100"),
								ul4.if_("file.coverablelines"),
									ul4.if_("file.coverablelines < file.lines"),
										ul4.code("width = int(1.*(file.lines-file.coverablelines)/file.lines*100)"),
										htmlspecials.pixel(src="/spc.gif", width=ul4.printx("width"), height=8, style="background-color: #ccc;"),
										ul4.code("totalwidth -= width"),
									ul4.end("if"),
									ul4.if_("file.coveredlines < file.coverablelines"),
										ul4.code("width = int(1.*(file.coverablelines-file.coveredlines)/file.lines*100)"),
										htmlspecials.pixel(src="/spc.gif", width=ul4.printx("width"), height=8, style="background-color: #f00;"),
										ul4.code("totalwidth -= width"),
									ul4.end("if"),
									ul4.if_("totalwidth"),
										htmlspecials.pixel(src="/spc.gif", width=ul4.printx("totalwidth"), height=8, style="background-color: #0c0;"),
									ul4.end("if"),
								ul4.else_(),
									htmlspecials.pixel(src="/spc.gif", width=ul4.printx("totalwidth"), height=8, style="background-color: #000;"),
								ul4.end("if"),
								class_="dist",
							),
							class_="files",
						),
					ul4.end("for"),
					id="files",
				),
				class_="files",
			)
		)
		return e.convert(converter)