]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/blobdiff - wrpylib/lib_sledrun_wikitext_to_json.py
Create "Buttonleiste" with key_value_template.
[philipp/winterrodeln/wrpylib.git] / wrpylib / lib_sledrun_wikitext_to_json.py
index 541551e415cb89ba77351f6f1fe6e41ab06b5021..4fffb55b3252d6c75ac1274b501814fad8994e77 100644 (file)
@@ -5,6 +5,12 @@ from mwparserfromhell.nodes import Template, Text, Tag
 from mwparserfromhell.wikicode import Wikicode
 
 
+def optional_set(haystack: dict, key: str, value: Optional[Any]):
+    """Sets the key to value in haystack only if value is not None"""
+    if value is not None:
+        haystack[key] = value
+
+
 def get_sledrun_description(sledrun: Wikicode) -> Optional[str]:
     """Get description from sledrun"""
     for v in sledrun.get_sections(levels=[2], matches='Allgemeines', include_headings=False):