#6630: allow customizing flags for compiling string.Template.idpattern.

This commit is contained in:
Georg Brandl 2010-07-29 17:16:10 +00:00
parent 1cec3e367c
commit 056cb93e7a
3 changed files with 13 additions and 1 deletions

View file

@ -81,7 +81,7 @@ class _TemplateMetaclass(type):
'delim' : _re.escape(cls.delimiter),
'id' : cls.idpattern,
}
cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
cls.pattern = _re.compile(pattern, cls.flags | _re.VERBOSE)
class Template(metaclass=_TemplateMetaclass):
@ -89,6 +89,7 @@ class Template(metaclass=_TemplateMetaclass):
delimiter = '$'
idpattern = r'[_a-z][_a-z0-9]*'
flags = _re.IGNORECASE
def __init__(self, template):
self.template = template