diff options
author | Dmitry Vasiliev <dima@hlabs.spb.ru> | 2006-01-28 19:52:03 +0000 |
---|---|---|
committer | Dmitry Vasiliev <dima@hlabs.spb.ru> | 2006-01-28 19:52:03 +0000 |
commit | 2b1c9fdc22f68bca98924b0ee1e52a399c846914 (patch) | |
tree | 7913304f1f9bba3247d42ced6b141b2c8d12e4d7 | |
parent | 8ff10f8437077615a2113a418b558d3cf83de11b (diff) | |
download | zope-tal-2b1c9fdc22f68bca98924b0ee1e52a399c846914.tar.gz |
Now we require python 2.4 so dict.fromkeys can be changed to frozenset
-rw-r--r-- | htmltalparser.py | 15 | ||||
-rw-r--r-- | taldefs.py | 7 | ||||
-rw-r--r-- | talinterpreter.py | 3 |
3 files changed, 10 insertions, 15 deletions
diff --git a/htmltalparser.py b/htmltalparser.py index 6f525d7..10c0875 100644 --- a/htmltalparser.py +++ b/htmltalparser.py @@ -23,8 +23,7 @@ from zope.tal.taldefs import ZOPE_METAL_NS, ZOPE_TAL_NS, ZOPE_I18N_NS, \ from zope.tal.talgenerator import TALGenerator -# TODO: In Python 2.4 we can use frozenset() instead of dict.fromkeys() -BOOLEAN_HTML_ATTRS = dict.fromkeys([ +BOOLEAN_HTML_ATTRS = frozenset([ # List of Boolean attributes in HTML that may be given in # minimized form (e.g. <img ismap> rather than <img ismap="">) # From http://www.w3.org/TR/xhtml1/#guidelines (C.10) @@ -33,7 +32,7 @@ BOOLEAN_HTML_ATTRS = dict.fromkeys([ "defer" ]) -EMPTY_HTML_TAGS = dict.fromkeys([ +EMPTY_HTML_TAGS = frozenset([ # List of HTML tags with an empty content model; these are # rendered in minimized form, e.g. <img />. # From http://www.w3.org/TR/xhtml1/#dtds @@ -41,7 +40,7 @@ EMPTY_HTML_TAGS = dict.fromkeys([ "input", "col", "basefont", "isindex", "frame", ]) -PARA_LEVEL_HTML_TAGS = dict.fromkeys([ +PARA_LEVEL_HTML_TAGS = frozenset([ # List of HTML elements that close open paragraph-level elements # and are themselves paragraph-level. "h1", "h2", "h3", "h4", "h5", "h6", "p", @@ -56,17 +55,15 @@ BLOCK_CLOSING_TAG_MAP = { "dt": ("dd", "dt"), } -BLOCK_LEVEL_HTML_TAGS = dict.fromkeys([ +BLOCK_LEVEL_HTML_TAGS = frozenset([ # List of HTML tags that denote larger sections than paragraphs. "blockquote", "table", "tr", "th", "td", "thead", "tfoot", "tbody", "noframe", "ul", "ol", "li", "dl", "dt", "dd", "div", ]) -SECTION_LEVEL_HTML_TAGS = PARA_LEVEL_HTML_TAGS.copy() -SECTION_LEVEL_HTML_TAGS.update(BLOCK_LEVEL_HTML_TAGS) +SECTION_LEVEL_HTML_TAGS = PARA_LEVEL_HTML_TAGS.union(BLOCK_LEVEL_HTML_TAGS) -TIGHTEN_IMPLICIT_CLOSE_TAGS = PARA_LEVEL_HTML_TAGS.copy() -TIGHTEN_IMPLICIT_CLOSE_TAGS.update(BLOCK_CLOSING_TAG_MAP) +TIGHTEN_IMPLICIT_CLOSE_TAGS = PARA_LEVEL_HTML_TAGS.union(BLOCK_CLOSING_TAG_MAP) class NestingError(HTMLParseError): @@ -33,8 +33,7 @@ ZOPE_I18N_NS = "http://xml.zope.org/namespaces/i18n" # zope.i18n.simpletranslationservice module: NAME_RE = "[a-zA-Z_][-a-zA-Z0-9_]*" -# TODO: In Python 2.4 we can use frozenset() instead of dict.fromkeys() -KNOWN_METAL_ATTRIBUTES = dict.fromkeys([ +KNOWN_METAL_ATTRIBUTES = frozenset([ "define-macro", "extend-macro", "use-macro", @@ -42,7 +41,7 @@ KNOWN_METAL_ATTRIBUTES = dict.fromkeys([ "fill-slot", ]) -KNOWN_TAL_ATTRIBUTES = dict.fromkeys([ +KNOWN_TAL_ATTRIBUTES = frozenset([ "define", "condition", "content", @@ -56,7 +55,7 @@ KNOWN_TAL_ATTRIBUTES = dict.fromkeys([ # like <tal:x>, <metal:y>, <i18n:z> ]) -KNOWN_I18N_ATTRIBUTES = dict.fromkeys([ +KNOWN_I18N_ATTRIBUTES = frozenset([ "translate", "domain", "target", diff --git a/talinterpreter.py b/talinterpreter.py index 1149ee8..4b1136e 100644 --- a/talinterpreter.py +++ b/talinterpreter.py @@ -41,8 +41,7 @@ I18nMessageTypes = (MessageID, Message) TypesToTranslate = I18nMessageTypes + (str, unicode) -# TODO: In Python 2.4 we can use frozenset() instead of dict.fromkeys() -BOOLEAN_HTML_ATTRS = dict.fromkeys([ +BOOLEAN_HTML_ATTRS = frozenset([ # List of Boolean attributes in HTML that should be rendered in # minimized form (e.g. <img ismap> rather than <img ismap="">) # From http://www.w3.org/TR/xhtml1/#guidelines (C.10) |