diff --git a/r2/r2/lib/configparse.py b/r2/r2/lib/configparse.py index cf8e6b876..3b0173a10 100644 --- a/r2/r2/lib/configparse.py +++ b/r2/r2/lib/configparse.py @@ -47,6 +47,14 @@ class ConfigValue(object): def tuple(v, key=None, data=None): return tuple(ConfigValue.to_iter(v)) + @staticmethod + def dict(key_type, value_type): + def parse(v, key=None, data=None): + return {key_type(x): value_type(y) + for x, y in ( + i.split(':', 1) for i in ConfigValue.to_iter(v))} + return parse + @staticmethod def choice(v, key, data): if v not in data: