1 __version__ = "$Revision: 1.2 $"[11:-4]
3 from SGML import Markup, Comment
4 from string import lower, join, replace
9 defaults = {'version': '1.0'}
10 attr_translations = {'id': 'ID',
13 'http_equiv': 'http-equiv',
14 'accept_charset': 'accept-charset'}
16 def __init__(self, **attr):
20 self.dict.update(self.defaults)
21 self.dict.update(attr)
23 def __getitem__(self, k): return self.dict[k]
25 def str_attribute(self, k):
26 k2 = self.attr_translations.get(k, k)
28 (k2, self.attlist.get(k, 1) and str(self[k]) or k2) \
30 def str_attribute_list(self):
31 return join(map(self.str_attribute, self.dict.keys()))
33 start_tag_string = "<?%s %s"
34 end_tag_string = " ?>\n"
37 a = self.str_attribute_list()
38 return self.start_tag_string % (self.name, a)
41 return self.end_tag_string