예제 #1
0
def __test_Table():
    print("\n%{:=^34s}%\n".format("Table"))
    target = Page(Table())
    __print_test(target, True)
    target = Page(Table([
        Tr(),
    ]))
    __print_test(target, True)
    target = Page(Table([
        H1(Text("Hello World!")),
    ]))
    __print_test(target, False)
예제 #2
0
def test():
    parse = SQLParse('')
    v = parse.splitString('id varchar(3)default getvalue(ffd)',' ' ,'\t' ,')')
    print v
    v = parse.splitString('; fim',' ','\t',';')
    print v

    testFld = 'id integer primary key, --@ ол╣Щ'

    table = Table('table1')
    parse.parseField(table,testFld)
    for n,t in table.getFields().items():
        print t.name
        print t.type
        print t.length
        print t.comment
예제 #3
0
def test():
    parse = SQLParse('')
    v = parse.splitString('id varchar(3)default getvalue(ffd)', ' ', '\t', ')')
    print v
    v = parse.splitString('; fim', ' ', '\t', ';')
    print v

    testFld = 'id integer primary key, --@ ол╣Щ'

    table = Table('table1')
    parse.parseField(table, testFld)
    for n, t in table.getFields().items():
        print t.name
        print t.type
        print t.length
        print t.comment
예제 #4
0
    def parseTable(self, line):
        """parse table definition."""
        # get table name
        m = re_table_start.search(line)
        if m:
            tblname = line[m.end():]
            tblname = tblname.strip(' (\t')
        tbl = Table()
        tbl.name = tblname
        if len(self.tblcomments) > 0:
            tbl.comment = self.tblcomments.pop()
        # parse each field step by step.
        li = self.handle.readline()
        while li:
            # if it's the end of create table
            if li.strip(' \t\n') == ');': break
            if not self.parseField(tbl, li): return
            li = self.handle.readline()
        # save table
        for p in self.currPrimaryKeys:
            if tbl.getFields()[p]:
                tbl.getFields()[p].setPrimaryKey(True)

        self.currPrimaryKeys = []
        self.tables.append(tbl)
예제 #5
0
    def parseTable(self ,line):
        """parse table definition."""
        # get table name
        m = re_table_start.search(line)
        if m :
        	tblname = line[m.end():]
        	tblname = tblname.strip(' (\t')
        tbl = Table()
        tbl.name = tblname
        if len(self.tblcomments) > 0:
            tbl.comment = self.tblcomments.pop()
        # parse each field step by step.
        li = self.handle.readline()
        while li:
            # if it's the end of create table
            if li.strip(' \t\n') == ');': break
            if not self.parseField(tbl,li): return
            li = self.handle.readline()
        # save table
        for p in self.currPrimaryKeys:
            if tbl.getFields()[p]:
                tbl.getFields()[p].setPrimaryKey(True)

        self.currPrimaryKeys = []
        self.tables.append(tbl)
예제 #6
0
        fd = open(filename, 'w')
        fd.write(self.__str__())
        fd.close()


if __name__ == '__main__':
    elem_test_fail = Html([
        Head(Title(Text('"Hello test"'))),
        Body([
            H1(Text('"This is a test"')),
            Span(Text('This is span')),
            Div([Ul([Li(Text('This is a li in a ul'))])]),
            H2(Text('h2 maintenant')),
            P(Text('a p section\nla suite')),
            Table([
                Tr(Th(Text('This is a th in a table'))),
                Tr(Td(Text('this is a td')))
            ]),
            Ol([Li(Text('<')), Li(Text('>')),
                Li(Text('"'))])
        ])
    ])
    elem_test = Html([
        Head(Title(Text('"Hello test"'))),
        Body([
            H1(Text('"This is a test"')),
            Span(Text('This is span')),
            Div([Ul([Li(Text('This is a li in a ul'))])]),
            H2(Text('h2 maintenant')),
            Table([
                Tr(Th(Text('This is a th in a table'))),
                Tr(Td(Text('this is a td')))