[Zope3-checkins] SVN: Zope3/trunk/src/zope/tal/ Now we require python 2.4 so dict.fromkeys can be changed to frozenset

Dmitry Vasiliev dima at hlabs.spb.ru
Sat Jan 28 14:52:03 EST 2006


Log message for revision 41477:
  Now we require python 2.4 so dict.fromkeys can be changed to frozenset
  

Changed:
  U   Zope3/trunk/src/zope/tal/htmltalparser.py
  U   Zope3/trunk/src/zope/tal/taldefs.py
  U   Zope3/trunk/src/zope/tal/talinterpreter.py

-=-
Modified: Zope3/trunk/src/zope/tal/htmltalparser.py
===================================================================
--- Zope3/trunk/src/zope/tal/htmltalparser.py	2006-01-28 19:45:34 UTC (rev 41476)
+++ Zope3/trunk/src/zope/tal/htmltalparser.py	2006-01-28 19:52:03 UTC (rev 41477)
@@ -23,8 +23,7 @@
 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 @@
     "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 @@
     "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 @@
     "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):

Modified: Zope3/trunk/src/zope/tal/taldefs.py
===================================================================
--- Zope3/trunk/src/zope/tal/taldefs.py	2006-01-28 19:45:34 UTC (rev 41476)
+++ Zope3/trunk/src/zope/tal/taldefs.py	2006-01-28 19:52:03 UTC (rev 41477)
@@ -33,8 +33,7 @@
 # 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 @@
     "fill-slot",
     ])
 
-KNOWN_TAL_ATTRIBUTES = dict.fromkeys([
+KNOWN_TAL_ATTRIBUTES = frozenset([
     "define",
     "condition",
     "content",
@@ -56,7 +55,7 @@
                     # like <tal:x>, <metal:y>, <i18n:z>
     ])
 
-KNOWN_I18N_ATTRIBUTES = dict.fromkeys([
+KNOWN_I18N_ATTRIBUTES = frozenset([
     "translate",
     "domain",
     "target",

Modified: Zope3/trunk/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/talinterpreter.py	2006-01-28 19:45:34 UTC (rev 41476)
+++ Zope3/trunk/src/zope/tal/talinterpreter.py	2006-01-28 19:52:03 UTC (rev 41477)
@@ -41,8 +41,7 @@
 
 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)



More information about the Zope3-Checkins mailing list