Mercurial > p > roundup > code
annotate roundup/template_parser.py @ 962:540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
| author | Gordon B. McMillan <gmcm@users.sourceforge.net> |
|---|---|
| date | Tue, 20 Aug 2002 14:24:19 +0000 |
| parents | fdcf16b444a9 |
| children |
| rev | line source |
|---|---|
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 import htmllib, formatter |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 class Require: |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 ''' Encapsulates a parsed <require attributes>...[<else>...]</require> |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 ''' |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 def __init__(self, attributes): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 self.attributes = attributes |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 self.current = self.ok = [] |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 self.fail = [] |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 def __len__(self): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 return len(self.current) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 def __getitem__(self, n): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 return self.current[n] |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 def __setitem__(self, n, data): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 self.current[n] = data |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 def append(self, data): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 self.current.append(data) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 def elseMode(self): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 self.current = self.fail |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
20 def __repr__(self): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
21 return '<Require %r ok:%r fail:%r>'%(self.attributes, self.ok, |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
22 self.fail) |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 class Display: |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 ''' Encapsulates a parsed <display attributes> |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 ''' |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 def __init__(self, attributes): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 self.attributes = attributes |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
29 def __repr__(self): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
30 return '<Display %r>'%self.attributes |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 class Property: |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 ''' Encapsulates a parsed <property attributes> |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 ''' |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 def __init__(self, attributes): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 self.attributes = attributes |
|
934
fdcf16b444a9
Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
932
diff
changeset
|
37 self.current = self.ok = [] |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
38 def __len__(self): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
39 return len(self.current) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
40 def __getitem__(self, n): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
41 return self.current[n] |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
42 def __setitem__(self, n, data): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
43 self.current[n] = data |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
44 def append(self, data): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
45 self.current.append(data) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
46 def __repr__(self): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
47 return '<Property %r %r>'%(self.attributes, self.structure) |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
49 class RoundupTemplate(htmllib.HTMLParser): |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
50 ''' Parse Roundup's HTML template structure into a list of components: |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
52 'string': this is just plain data to be displayed |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
53 Display : instances indicate that display functions are to be called |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 Require : if/else style check using the conditions in the attributes, |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 displaying the "ok" list of components or "fail" list |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 ''' |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
58 def __init__(self): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
59 htmllib.HTMLParser.__init__(self, formatter.NullFormatter()) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 self.current = self.structure = [] |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 self.stack = [] |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 def handle_data(self, data): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 self.append_data(data) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
65 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 def append_data(self, data): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 if self.current and isinstance(self.current[-1], type('')): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
68 self.current[-1] = self.current[-1] + data |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
69 else: |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
70 self.current.append(data) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 def unknown_starttag(self, tag, attributes): |
|
962
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
73 self.append_data('<%s' % tag) |
|
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
74 closeit = 1 |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
75 for name, value in attributes: |
|
962
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
76 pos = value.find('<') |
|
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
77 if pos > -1: |
|
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
78 self.append_data(' %s="%s' % (name, value[:pos])) |
|
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
79 closeit = 0 |
|
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
80 else: |
|
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
81 self.append_data(' %s="%s"' % (name, value)) |
|
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
82 if closeit: |
|
540fc5fb20d4
Fix so it can do <display...> inside an attribute of another tag.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
934
diff
changeset
|
83 self.append_data('>') |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
84 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
85 def handle_starttag(self, tag, method, attributes): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
86 if tag in ('require', 'else', 'display', 'property'): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
87 method(attributes) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
88 else: |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
89 self.unknown_starttag(tag, attributes) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
90 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
91 def unknown_endtag(self, tag): |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
92 if tag in ('require','property'): |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
93 self.current = self.stack.pop() |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
94 else: |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
95 self.append_data('</%s>'%tag) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
96 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
97 def handle_endtag(self, tag, method): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
98 self.unknown_endtag(tag) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
99 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
100 def close(self): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
101 htmllib.HTMLParser.close(self) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
102 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
103 def do_display(self, attributes): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
104 self.current.append(Display(attributes)) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
105 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
106 def do_property(self, attributes): |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
107 p = Property(attributes) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
108 self.current.append(p) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
109 self.stack.append(self.current) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
110 self.current = p |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
111 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
112 def do_require(self, attributes): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
113 r = Require(attributes) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
114 self.current.append(r) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
115 self.stack.append(self.current) |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
116 self.current = r |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
117 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
118 def do_else(self, attributes): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
119 self.current.elseMode() |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
120 |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
121 def __repr__(self): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
122 return '<RoundupTemplate %r>'%self.structure |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
123 |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
124 def display(structure, indent=''): |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
125 ''' Pretty-print the parsed structure for debugging |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
126 ''' |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
127 l = [] |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
128 for entry in structure: |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
129 if isinstance(entry, type('')): |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
130 l.append("%s%s"%(indent, entry)) |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
131 elif isinstance(entry, Require): |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
132 l.append('%sTEST: %r\n'%(indent, entry.attributes)) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
133 l.append('%sOK...'%indent) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
134 l.append(display(entry.ok, indent+' ')) |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
135 if entry.fail: |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
136 l.append('%sFAIL...'%indent) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
137 l.append(display(entry.fail, indent+' ')) |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
138 elif isinstance(entry, Display): |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
139 l.append('%sDISPLAY: %r'%(indent, entry.attributes)) |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
140 elif isinstance(entry, Property): |
|
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
141 l.append('%sPROPERTY: %r'%(indent, entry.attributes)) |
|
934
fdcf16b444a9
Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents:
932
diff
changeset
|
142 l.append(display(entry.ok, indent+' ')) |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
143 return ''.join(l) |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
144 |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 if __name__ == '__main__': |
|
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
146 import sys |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
147 parser = RoundupTemplate() |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
148 parser.feed(open(sys.argv[1], 'r').read()) |
|
932
a43fa69c1b70
fixes to the new template parser
Richard Jones <richard@users.sourceforge.net>
parents:
931
diff
changeset
|
149 print display(parser.structure) |
|
931
3dba266f94d8
this oughta be better
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
150 |
