-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml.py
More file actions
53 lines (34 loc) · 866 Bytes
/
html.py
File metadata and controls
53 lines (34 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
This file is part of the Python HTML Helper project
"""
class TAG:
"""
Generic html tag.
"""
name = 'tag'
attr = []
nodes = []
def __init__(self, *args, **kwargs):
for arg in args:
self.nodes.append(arg)
for kwarg in kwargs:
self.attr.append(kwarg)
def __xml__():
pass
def __str__(self):
result = ['<', self.name, '>']
nodes = self.__getnodes__()
for node in nodes:
result.append('\n ')
result.append(node.__str__())
result.extend(['\n','</', self.name, '>'])
return ''.join(result)
def __getitem__(self):
pass
def __getattr__(self):
pass
def __getnodes__(self):
return self.nodes
if __name__ == '__main__':
tag = TAG('a', 'b')
print tag.__str__()