comparison configmix/variables.py @ 352:2b209bdf6995

Implement the "Empty" filter. This is like the "None" filter but returning an empty string instead of None.
author Franz Glasner <f.glasner@feldmann-mg.com>
date Thu, 24 Jun 2021 19:26:53 +0200
parents 83f76a41cf7c
children dd454e1efea4
comparison
equal deleted inserted replaced
351:efbf7ba40287 352:2b209bdf6995
253 253
254 """ 254 """
255 return v 255 return v
256 256
257 257
258 @filter("Empty")
259 def Empty_filter_impl(config, v):
260 """Identity.
261
262 The `Empty` filter is just a marker to not throw `KeyError` but return
263 the empty string.
264
265 """
266 return v
267
268
258 # Register the default namespaces 269 # Register the default namespaces
259 add_varns("ENV", _envlookup) 270 add_varns("ENV", _envlookup)
260 add_varns("OS", _oslookup) 271 add_varns("OS", _oslookup)
261 add_varns("PY", _pylookup) 272 add_varns("PY", _pylookup)
262 try: 273 try: