You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/libs/trakit/config.py

20 lines
802 B

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', {})