Permalink
Browse files

implements TAG.__str__()

  • Loading branch information...
1 parent 35845b7 commit 9a556dd5c5d44056d7afc44db322670515cd34e1 Matheus Lima committed Apr 18, 2012
Showing with 18 additions and 19 deletions.
  1. +18 −19 html.py
View
37 html.py
@@ -7,48 +7,47 @@
"""
-__all__ = [
- 'DIV'
-]
-__scape__ = {
- '<':'&lt;',
- '>':'&gt;',
-}
-
-class Tag:
+class TAG:
"""
Generic html tag.
"""
-
+ name = 'tag'
attr = []
- content = []
+ nodes = []
def __init__(self, *args, **kwargs):
for arg in args:
- self.content.append(arg)
+ self.nodes.append(arg)
for kwarg in kwargs:
self.attr.append(kwarg)
def __xml__():
pass
- def __str__():
- 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__():
+ def __getitem__(self):
pass
- def __getattr__():
+ def __getattr__(self):
pass
- def __getcontent__():
- pass
+ def __getnodes__(self):
+ return self.nodes
if __name__ == '__main__':
- tag = Tag('a', 'b')
+ tag = TAG('a', 'b')
+ print tag.__str__()

0 comments on commit 9a556dd

Please sign in to comment.