PK!  figga/__init__.pyimport os from pathlib import Path from inspect import isclass from configparser import ConfigParser, DEFAULTSECT from typing import Sequence, ItemsView, Union class Configuration: def __init__(self, config: dict, default=None): self._config = {key.lower(): value for key, value in config.items()} self._default = default def __getattr__(self, item: str): return self.get(item) def get(self, item: str, **kwargs): """ Retrieves a single configuration value. """ default = kwargs.get('default', self._default) value = self._config.get(item.lower(), default) if isclass(value) and issubclass(value, BaseException): raise value(f'{item} is not defined') if callable(value): return value(item) return value def items(self) -> ItemsView: """ Returns a dict containing all configuration values. """ return self._config.items() @classmethod def from_environ(cls, prefix: str, remove_prefix: bool=False, default=None) -> 'Configuration': """ Constructs a Configuration instance from a set of environment variables sharing the same prefix. Optionally, the prefix can be removed from the configuration values. """ prefix_length = len(prefix) config = { key[prefix_length:] if remove_prefix else key: value for key, value in os.environ.items() if key.startswith(prefix) } return cls(config, default=default) @classmethod def from_files(cls, files: Sequence[Union[str, os.PathLike]], section: str=DEFAULTSECT, default=None) -> 'Configuration': """ Constructs a Configuration instance from one or more INI files. """ config = ConfigParser(default_section=section) for file_path in files: file_path = Path(file_path) if not file_path.is_absolute(): file_path = Path.cwd() / file_path if file_path.exists(): config.read(file_path) config = { key: value for key, value in config[section].items() } return cls(config, default=default) @classmethod def from_file(cls, file: Union[str, os.PathLike], section: str=DEFAULTSECT, default=None) -> 'Configuration': """ Constructs a Configuration instance from a single INI file. """ return cls.from_files([file], section=section, default=default) PK!H$'qTSfigga-0.1.1.dist-info/WHEEL HM K-*ϳR03rOK-J,/R(O-)T0г3 /, (-JLR()*M IL4KM̫PK!H}h$figga-0.1.1.dist-info/METADATAWmo6_leX4 4@1-6WHʎ:9K-Oy=s+xcV;J ^bAz7MUqfl¬R\+X6;+͵aW[j&Jj,gl\mx!ݲ3a-5̅uv%ڵ6] W2idYEqy$*.ˌuN~^R%\ZH#(د'8}C ~iɭs)"bY.ߜI]}hwU%Ղsh@[ӧ|买57: Fm wcC*Iļ','?^Y#}zN2f񩴧vmfʗ'N70H]Lڔ1D0M]k,sK#[2=gĠ[>5Ku\iMVhU[q#Q㮪ڈVJggS s {ƭ;׀R9oJ*/"R'9 q* \mL8&*!b{;ۛkXoMozG>{ǏpmʹB2Ƣ~IŸj=mTwl_!ԯ # u:D[ JĻɫ{ o8 f] )  7ydSAm-rHEiz) V7 1d"]L}ej~׀[pEZJv[(ޢ6R~,VlNRr$LaXqD2karn}x kiCf+4C!)ew]րH. CzBzJ_`4zlGHAN4 (hUI~oKGopV{_&[fѐ 4 Z"&Yo F0 &޷Ճ4x uF"-aoDf&n*IxFHK,@6-yqMC&RD.|.HҙM*mKnpP p;gYR>4uv9vm\QT/^^m3i?}P2/(5o]ۯumF{7:FK#1%_w~tlpC as-ɺ#*n Q70}azwG  ^:exLJ<'.g/Qh_mpYsc> [ .,xVvk.]UF(NKBGY(8L&aŁ֐9`e71~fV^[ I1镫Lv#->uaƘ6mʮ;KFQ'sAlm?PK!H figga-0.1.1.dist-info/RECORDun0RA =x褂!4n`ZeG_|p.i8wuxpnwnI뤃" -3<'lTK=>+6lvDŽl^Z)R#vt0mnfН`5"67d8~|a7~ݣ$ RaS>[R^&M&(  MCFPK!  figga/__init__.pyPK!H$'qTS3 figga-0.1.1.dist-info/WHEELPK!H}h$ figga-0.1.1.dist-info/METADATAPK!H figga-0.1.1.dist-info/RECORDPK