simple document
| 25 | |
| 26 | |
| 27 | class Document(Element): |
| 28 | """ simple document """ |
| 29 | |
| 30 | DECL = '<?xml version="1.0" encoding="UTF-8"?>' |
| 31 | |
| 32 | def __init__(self, root=None): |
| 33 | Element.__init__(self, 'document') |
| 34 | if root is not None: |
| 35 | self.append(root) |
| 36 | |
| 37 | def root(self): |
| 38 | if len(self.children): |
| 39 | return self.children[0] |
| 40 | else: |
| 41 | return None |
| 42 | |
| 43 | def str(self): |
| 44 | s = [] |
| 45 | s.append(self.DECL) |
| 46 | s.append('\n') |
| 47 | if self.root() is not None: |
| 48 | s.append(self.root().str()) |
| 49 | return ''.join(s) |
| 50 | |
| 51 | def plain(self): |
| 52 | s = [] |
| 53 | s.append(self.DECL) |
| 54 | s.append(self.root().plain()) |
| 55 | return ''.join(s) |
| 56 | |
| 57 | def __str__(self): |
| 58 | return self.str() |
| 59 | |
| 60 | def __unicode__(self): |
| 61 | return self.str() |
no outgoing calls
no test coverage detected