comparison configmix/variables.py @ 357:dd454e1efea4

Use constants for the names of the "None" and "Empty" filters
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 24 Jun 2021 21:20:37 +0200
parents 2b209bdf6995
children d2751a80d9b7
comparison
equal deleted inserted replaced
356:a5c792074ec9 357:dd454e1efea4
15 15
16 import os 16 import os
17 import platform 17 import platform
18 from functools import wraps 18 from functools import wraps
19 19
20 from .compat import PY2, native_os_str_to_text, u 20 from .compat import PY2, native_os_str_to_text, text_to_native_os_str, u
21 from .constants import REF_NAMESPACE 21 from .constants import REF_NAMESPACE, NONE_FILTER, EMPTY_FILTER
22 22
23 23
24 _MARKER = object() 24 _MARKER = object()
25 25
26 26
242 def upper_impl(config, v): 242 def upper_impl(config, v):
243 """Implementation of the `upper` filter function""" 243 """Implementation of the `upper` filter function"""
244 return v.upper() 244 return v.upper()
245 245
246 246
247 @filter("None") 247 @filter(text_to_native_os_str(NONE_FILTER, encoding="ascii"))
248 def None_filter_impl(config, v): 248 def None_filter_impl(config, v):
249 """Identity. 249 """Identity.
250 250
251 The `None` filter is just a marker to not throw `KeyError` but return 251 The `None` filter is just a marker to not throw `KeyError` but return
252 `None`. 252 `None`.
253 253
254 """ 254 """
255 return v 255 return v
256 256
257 257
258 @filter("Empty") 258 @filter(text_to_native_os_str(EMPTY_FILTER, encoding="ascii"))
259 def Empty_filter_impl(config, v): 259 def Empty_filter_impl(config, v):
260 """Identity. 260 """Identity.
261 261
262 The `Empty` filter is just a marker to not throw `KeyError` but return 262 The `Empty` filter is just a marker to not throw `KeyError` but return
263 the empty string. 263 the empty string.