aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/parse.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/utils/parse.py b/src/utils/parse.py
index 03a585c2..4fa3bb79 100644
--- a/src/utils/parse.py
+++ b/src/utils/parse.py
@@ -55,3 +55,13 @@ def docstring(s: str) -> Docstring:
description += line
return Docstring(description, items, var_items)
+def keyvalue(s, delimiter: str=" ") -> typing.Dict[str, str]:
+ items = {}
+ pairs = s.split(delimiter)
+ for pair in pairs:
+ key, sep, value = pair.partition("=")
+ if sep:
+ items[key] = value
+ else:
+ items[key] = None
+ return items