Commit 746441c4 authored by Fred Drake's avatar Fred Drake

- wrap some long lines

- move shared text for warnings so it isn't repeated
parent 7eeb7603
...@@ -669,8 +669,8 @@ class TALGenerator: ...@@ -669,8 +669,8 @@ 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.position, self.xml)
else: else:
i18nattrs = {} i18nattrs = {}
# Convert repldict's name-->expr mapping to a # Convert repldict's name-->expr mapping to a
...@@ -678,7 +678,7 @@ class TALGenerator: ...@@ -678,7 +678,7 @@ class TALGenerator:
for key, value in repldict.items(): for key, value in repldict.items():
if i18nattrs.get(key, None): if i18nattrs.get(key, None):
raise I18NError( raise I18NError(
("attribute [%s] cannot both be part of tal:attributes" + ("attribute [%s] cannot both be part of tal:attributes"
" and have a msgid in i18n:attributes") % key, " and have a msgid in i18n:attributes") % key,
position) position)
ce = self.compileExpression(value) ce = self.compileExpression(value)
...@@ -821,10 +821,12 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, xml): ...@@ -821,10 +821,12 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, xml):
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" % spec, raise TALError(
"illegal i18n:attributes specification: %r" % spec,
position) position)
if len(parts) == 2: if len(parts) == 2:
attr, msgid = parts attr, msgid = parts
...@@ -836,35 +838,35 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, xml): ...@@ -836,35 +838,35 @@ def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, xml):
attr = attr.lower() attr = attr.lower()
if attr in d: if attr in d:
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)
d[attr] = msgid d[attr] = msgid
else: else:
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
d[attr] = msgid d[attr] = msgid
else: else:
import warnings import warnings
warnings.warn('Space separated attributes in i18n:attributes' warnings.warn(I18N_ATTRIBUTES_WARNING, DeprecationWarning)
+ ' are deprecated (i18n:attributes="value title"). Please use'
+ ' semicolon to separate attributes'
+ ' (i18n:attributes="value; title").', DeprecationWarning)
for attr in i18nattrlist: for attr in i18nattrlist:
d[attr] = None d[attr] = None
else: else:
import warnings import warnings
warnings.warn('Space separated attributes in i18n:attributes' warnings.warn(I18N_ATTRIBUTES_WARNING, DeprecationWarning)
+ ' are deprecated (i18n:attributes="value title"). Please use'
+ ' semicolon to separate attributes'
+ ' (i18n:attributes="value; title").', DeprecationWarning)
for attr in i18nattrlist: for attr in i18nattrlist:
d[attr] = None d[attr] = None
return d return d
I18N_ATTRIBUTES_WARNING = (
'Space separated attributes in i18n:attributes are deprecated'
' (i18n:attributes="value title"). Please use a semicolon to'
' separate attributes (i18n:attributes="value; title").')
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