Commit 020c91d3 authored by Godefroid Chapelle's avatar Godefroid Chapelle

reformatted for Fred

parent 54192638
...@@ -669,8 +669,9 @@ class TALGenerator: ...@@ -669,8 +669,9 @@ class TALGenerator:
else: else:
repldict = {} repldict = {}
if i18nattrs: if i18nattrs:
i18nattrs = _parseI18nAttributes(i18nattrs, attrlist, repldict, self.position, i18nattrs = _parseI18nAttributes(i18nattrs, attrlist, repldict,
self.xml, self.source_file) self.position, self.xml,
self.source_file)
else: else:
i18nattrs = {} i18nattrs = {}
# Convert repldict's name-->expr mapping to a # Convert repldict's name-->expr mapping to a
...@@ -825,19 +826,20 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, ...@@ -825,19 +826,20 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position,
attr = attr.lower() attr = attr.lower()
if attr in dic: if attr in dic:
raise TALError( raise TALError(
"attribute may only be specified once in i18n:attributes: %r" "attribute may only be specified once in i18n:attributes: "
% attr, + attr,
position) position)
dic[attr] = msgid dic[attr] = msgid
d = {} d = {}
if ';' in i18nattrs: if ';' in i18nattrs:
i18nattrlist = i18nattrs.split(';') i18nattrlist = i18nattrs.split(';')
i18nattrlist = [attr.strip().split() for attr in i18nattrlist if attr.strip()] i18nattrlist = [attr.strip().split()
for attr in i18nattrlist if attr.strip()]
for parts in i18nattrlist: for parts in i18nattrlist:
if len(parts) > 2: if len(parts) > 2:
raise TALError("illegal i18n:attributes specification: %r" % parts, raise TALError("illegal i18n:attributes specification: %r"
position) % parts, position)
if len(parts) == 2: if len(parts) == 2:
attr, msgid = parts attr, msgid = parts
else: else:
...@@ -849,16 +851,13 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, ...@@ -849,16 +851,13 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position,
i18nattrlist = i18nattrs.split() i18nattrlist = i18nattrs.split()
if len(i18nattrlist) == 2: if len(i18nattrlist) == 2:
staticattrs = [attr[0] for attr in attrlist if len(attr) == 2] staticattrs = [attr[0] for attr in attrlist if len(attr) == 2]
if (not i18nattrlist[1] in staticattrs) and (not i18nattrlist[1] in repldict): if (not i18nattrlist[1] in staticattrs) and (
not i18nattrlist[1] in repldict):
attr, msgid = i18nattrlist attr, msgid = i18nattrlist
addAttribute(d, attr, msgid, position, xml) addAttribute(d, attr, msgid, position, xml)
else: else:
import warnings import warnings
warnings.warn('Space separated attributes in i18n:attributes' warnings.warn(I18N_ATTRIBUTES_WARNING
+ ' are deprecated (i18n:attributes="value title"). Please use'
+ ' semicolon to separate attributes'
+ ' (i18n:attributes="value; title").'
+ '\nFile %s at row, column %s\nAttributes %s'
% (source_file, str(position), i18nattrs) % (source_file, str(position), i18nattrs)
, DeprecationWarning) , DeprecationWarning)
msgid = None msgid = None
...@@ -866,11 +865,7 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, ...@@ -866,11 +865,7 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position,
addAttribute(d, attr, msgid, position, xml) addAttribute(d, attr, msgid, position, xml)
else: else:
import warnings import warnings
warnings.warn('Space separated attributes in i18n:attributes' warnings.warn(I18N_ATTRIBUTES_WARNING
+ ' are deprecated (i18n:attributes="value title"). Please use'
+ ' semicolon to separate attributes'
+ ' (i18n:attributes="value; title").'
+ '\nFile %s at row, column %s\nAttributes %s'
% (source_file, str(position), i18nattrs) % (source_file, str(position), i18nattrs)
, DeprecationWarning) , DeprecationWarning)
msgid = None msgid = None
...@@ -878,6 +873,13 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, ...@@ -878,6 +873,13 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position,
addAttribute(d, attr, msgid, position, xml) addAttribute(d, attr, msgid, position, xml)
return d return d
I18N_ATTRIBUTES_WARNING = (
'Space separated attributes in i18n:attributes'
' are deprecated (i18n:attributes="value title"). Please use'
' semicolon to separate attributes'
' (i18n:attributes="value; title").'
'\nFile %s at row, column %s\nAttributes %s')
def test(): def test():
t = TALGenerator() t = TALGenerator()
t.pushProgram() t.pushProgram()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment