diff options
Diffstat (limited to 'libs/trakit/config.py')
-rw-r--r-- | libs/trakit/config.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libs/trakit/config.py b/libs/trakit/config.py new file mode 100644 index 000000000..6458b4bbd --- /dev/null +++ b/libs/trakit/config.py @@ -0,0 +1,19 @@ +import json +import typing + +from pkg_resources import resource_stream + + +class Config: + def __init__(self, config: typing.Optional[typing.Mapping[str, typing.Any]]): + with resource_stream('trakit', 'data/config.json') as f: + cfg: typing.Dict[str, typing.Any] = json.load(f) + if config: + cfg.update(config) + + self.ignored: typing.Set[str] = set(cfg.get('ignored', [])) + self.countries: typing.Mapping[str, str] = cfg.get('countries', {}) + self.languages: typing.Mapping[str, str] = cfg.get('languages', {}) + self.scripts: typing.Mapping[str, str] = cfg.get('scripts', {}) + self.regions: typing.Mapping[str, str] = cfg.get('regions', {}) + self.implicit_languages: typing.Mapping[str, str] = cfg.get('implicit-languages', {}) |