Coverage for mfutil/jinja2_extensions.py: 0%
16 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-13 15:33 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-13 15:33 +0000
1import uuid
2import hashlib
3from jinja2.ext import Extension
6def uuid_filter(value):
7 v = str(uuid.uuid4()) + value
8 return hashlib.md5(v.encode()).hexdigest()
11class UUIDExtension(Extension):
12 def __init__(self, environment):
13 super(UUIDExtension, self).__init__(environment)
14 environment.filters['uuid'] = uuid_filter
17def alnum_filter(value):
18 return ''.join(c for c in value if c.isalnum())
21class AlphaNumericExtension(Extension):
22 def __init__(self, environment):
23 super(AlphaNumericExtension, self).__init__(environment)
24 environment.filters['alnum'] = alnum_filter