[Zope-Checkins] CVS: Zope/lib/python/TAL - TALGenerator.py:1.63.4.4

Godefroid Chapelle gotcha at swing.be
Wed Aug 20 18:32:37 EDT 2003


Update of /cvs-repository/Zope/lib/python/TAL
In directory cvs.zope.org:/tmp/cvs-serv330

Modified Files:
      Tag: Zope-2_7-branch
	TALGenerator.py 
Log Message:
management of i18n:attributes was not similar
in both space and semicolon separated lists



=== Zope/lib/python/TAL/TALGenerator.py 1.63.4.3 => 1.63.4.4 ===
--- Zope/lib/python/TAL/TALGenerator.py:1.63.4.3	Fri Aug 15 10:14:37 2003
+++ Zope/lib/python/TAL/TALGenerator.py	Wed Aug 20 17:32:37 2003
@@ -670,7 +670,7 @@
                 repldict = {}
             if i18nattrs:
                 i18nattrs = _parseI18nAttributes(i18nattrs, attrlist, repldict, self.position,
-                                                 self.xml)
+                                                 self.xml, self.source_file)
             else:
                 i18nattrs = {}
             # Convert repldict's name-->expr mapping to a
@@ -817,14 +817,26 @@
             self.emitDefineMacro(defineMacro)
 
 
-def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, xml):
+def _parseI18nAttributes(i18nattrs, attrlist, repldict, position,
+                         xml, source_file):
+
+    def addAttribute(dic, attr, msgid, position, xml):
+        if not xml:
+            attr = attr.lower()
+        if attr in dic:
+            raise TALError(
+                "attribute may only be specified once in i18n:attributes: %r"
+                % attr,
+                position)
+        dic[attr] = msgid
+
     d = {}
     if ';' in i18nattrs:
         i18nattrlist = i18nattrs.split(';')
         i18nattrlist = [attr.strip().split() for attr in i18nattrlist if attr.strip()]
         for parts in i18nattrlist:
             if len(parts) > 2:
-                raise TALError("illegal i18n:attributes specification: %r" % spec,
+                raise TALError("illegal i18n:attributes specification: %r" % parts,
                                position)
             if len(parts) == 2:
                 attr, msgid = parts
@@ -832,37 +844,38 @@
                 # len(parts) == 1
                 attr = parts[0]
                 msgid = None
-            if not xml:
-                attr = attr.lower()
-            if attr in d:
-                raise TALError(
-                    "attribute may only be specified once in i18n:attributes: %r"
-                    % attr,
-                    position)
-            d[attr] = msgid
+            addAttribute(d, attr, msgid, position, xml)
     else:
         i18nattrlist = i18nattrs.split()
         if len(i18nattrlist) == 2:
             staticattrs = [attr[0] for attr in attrlist if len(attr) == 2]
             if (not i18nattrlist[1] in staticattrs) and (not i18nattrlist[1] in repldict):
-              attr, msgid = i18nattrlist
-              d[attr] = msgid    
+                attr, msgid = i18nattrlist
+                addAttribute(d, attr, msgid, position, xml)    
             else:
                 import warnings
                 warnings.warn('Space separated attributes in i18n:attributes'
                 + ' are deprecated (i18n:attributes="value title"). Please use'
                 + ' semicolon to separate attributes'
-                + ' (i18n:attributes="value; title").', DeprecationWarning)
+                + ' (i18n:attributes="value; title").'
+                + '\nFile %s at row, column %s\nAttributes %s'
+                % (source_file, str(position), i18nattrs)
+                , DeprecationWarning)
+                msgid = None
                 for attr in i18nattrlist:
-                    d[attr] = None
+                    addAttribute(d, attr, msgid, position, xml)    
         else:    
             import warnings
             warnings.warn('Space separated attributes in i18n:attributes'
             + ' are deprecated (i18n:attributes="value title"). Please use'
             + ' semicolon to separate attributes'
-            + ' (i18n:attributes="value; title").', DeprecationWarning)
+            + ' (i18n:attributes="value; title").'
+            + '\nFile %s at row, column %s\nAttributes %s'
+            % (source_file, str(position), i18nattrs)
+            , DeprecationWarning)
+            msgid = None
             for attr in i18nattrlist:
-                d[attr] = None
+                addAttribute(d, attr, msgid, position, xml)    
     return d
 
 def test():




More information about the Zope-Checkins mailing list