Package: private-values
private_values (v0.5.8)DESCRIPTION_SHORTUpdate values into class attrs from osenvironment or ini/json fileDESCRIPTION_LONGdesigned to use private data like username/pwd kept secure in osenvironment or ini/json-file for your several home projects at ones.and not open it in public.caution:in requirements for other projects use fixed version! because it might be refactored so you would get exception soon.Featuresload values to instance attrs from:EnvironmentIniFileJsonFileCsvFiledirect text instead of filedirect dict instead of fileattr access:via any lettercaseby instance attrlike dict key on instancework with dict:applyupdatepreupdateupdate_dict as cumulative result - useful in case of settings resultLicenseSee theLICENSEfile for license rights and limitations (MIT).Release historySee theHISTORY.mdfile for release history.Installationpip install private-valuesImportfromprivate_valuesimport*USAGE EXAMPLESSee tests and sourcecode for other examples.1. example1.py# ===================================================================# by instance attr# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}fromprivate_valuesimport*classCls:data=PrivateAuthJson(_section="AUTH")defconnect(self):name=self.data.NAMEname=self.data.NamE# case insensitive# like dict key on instance# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}fromprivate_valuesimport*classCls:data=PrivateAuthJson(_section="AUTH")defconnect(self):name=self.data["NAME"]name=self.data["NamE"]# case insensitive# ===================================================================### use annotations for your param names (best practice!)# when instantiating if it will not get loaded these exact params from your private sources - RAISE!# but you could not use it and however keep access to all existed params in used section!# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}fromprivate_valuesimport*classMyPrivateJson(PrivateJson):NAME:strPWD:strname=MyPrivateJson().NAME# ===================================================================# in example above you could simply use existed classesfromprivate_valuesimport*name=PrivateAuthJson().NAME# ===================================================================### 1. Envfromprivate_valuesimport*classCls:user=PrivateEnv["NAME"]user=PrivateEnv.NAME# ===================================================================### 2. IniFile# Use different sectionsfromprivate_valuesimport*classCls:user=PrivateIni(_section="CustomSection").NAME# ===================================================================# Change full settingsfromprivate_valuesimport*classCustomIniValues(PrivateIni):DIRPATH="new/path/"DIRPATH=pathlib.Path("new/path/")FILENAME="my.ini"SECTION="CustomSection"classCls:user=CustomIniValues.NAME# ===================================================================# Without creating new classfromprivate_valuesimport*classCls:pv1=PrivateIni(_filename="otherFilename").pv1# ===================================================================### 3. JsonFile# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}fromprivate_valuesimport*classMyPrivateJson(PrivateJson):SECTION="AUTH"NAME:strPWD:strclassCls:data=MyPrivateJson()defconnect(self):name=self.data.NAME# ===================================================================# use already created templates (PrivateAuthJson/PrivateTgBotAddressJson) for standard attributes# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}fromprivate_valuesimport*classCls:data=PrivateAuthJson(_section="AUTH")defconnect(self):name=self.data.NAME# ===================================================================### 4. Auto# you can use universal class# it will trying get all your annotated params from one source of Json/Ini/Env (in exact order)# in this case you cant use FileName and must use annotations!# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}fromprivate_valuesimport*classMyPrivate(PrivateAuto):SECTION="AUTH"NAME:strPWD:strname=MyPrivate().NAME# ===================================================================