diff configmix/variables.py @ 349:83f76a41cf7c

Implement a special filter named "None" that suppresses "KeyErrors" from interpolation lookups and returns a Python "None" instead
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 24 Jun 2021 09:33:22 +0200
parents d7daec119383
children 2b209bdf6995
line wrap: on
line diff
--- a/configmix/variables.py	Wed Jun 23 15:00:37 2021 +0200
+++ b/configmix/variables.py	Thu Jun 24 09:33:22 2021 +0200
@@ -244,6 +244,17 @@
     return v.upper()
 
 
+@filter("None")
+def None_filter_impl(config, v):
+    """Identity.
+
+    The `None` filter is just a marker to not throw `KeyError` but return
+    `None`.
+
+    """
+    return v
+
+
 # Register the default namespaces
 add_varns("ENV", _envlookup)
 add_varns("OS", _oslookup)