Update class attributes from OsEnvironment or IniFile
Reason this release was yanked:
while not used anywhere use new vertion!
Project description
private_values
Designed to use private data like username/pwd kept secure in OsEnvironment or IniFile for your several home projects at ones.
And not open it in public.
Main goals: short implementation and OOP usage.
Features
-
get values from:
- Environment
- iniFile
-
raise if no name in destination
License
See the LICENSE file for license rights and limitations (MIT).
Release history
See the HISTORY.md file for release history.
Installation
pip install private-values
Import
from private_values import *
GUIDE
1. Env
- what a simple usage
from private_values import *
class Cls:
user = EnvValues.get("NameInEnv_ForUser")
pwd = EnvValues.get("NameInEnv_ForPwd")
2. IniFile
- Use defaults
from private_values import *
class Cls:
user = IniValues.get("NameInIni_ForUser")
pwd = IniValues.get("NameInIni_ForPwd")
- Use different sections
from private_values import *
class Cls:
user = IniValues.get("NameInIni_ForUser")
pwd = IniValues.get("NameInIni_ForPwd", section="CustomSection")
- Change directory or filename or default section
str and pathlib are accepted
from private_values import *
class CustomIniValues(IniValues):
DIRPATH = "new/path/"
FILENAME = "my.ini"
SECTION = "CustomSection"
class Cls:
user = CustomIniValues.get("NameInIni_ForUser")
pwd = CustomIniValues.get("NameInIni_ForPwd")
3. disable Exceptions
- in method
_raise_exx
is useful in all *.get methods for both classes
from private_values import *
class Cls:
user = EnvValues.get("Name_ForUser", _raise_exx=False)
pwd = IniValues.get("Name_ForPwd", _raise_exx=False)
def connect(self):
if None in [self.user, self.pwd]:
return
pass
- in whole class
_raise_exx
is useful in all *.get methods for both classes
from private_values import *
class CustomEnvValues(EnvValues):
RAISE_EXX = False
class CustomIniValues(IniValues):
RAISE_EXX = False
class Cls:
user = CustomEnvValues.get("Name_ForUser")
pwd = CustomIniValues.get("Name_ForPwd")
def connect(self):
if None in [self.user, self.pwd]:
return
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
private_values-0.2.0.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for private_values-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39cc3fc7fc45d9aa395f125c4abace456d6b444c3a03487788e66b24a52afe7b |
|
MD5 | 6057b5020270647ff36d40c65693dd8a |
|
BLAKE2b-256 | e2c33177a7444c5a6118674af6e6a29e479b7f6ea213327b0590befca52cb527 |