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 = PrivateEnv.get("NameInEnv_ForUser")
pwd = PrivateEnv.get("NameInEnv_ForPwd")
2. IniFile
- Use defaults
from private_values import *
class Cls:
user = PrivateIni.get("NameInIni_ForUser")
pwd = PrivateIni.get("NameInIni_ForPwd")
- Use different sections
from private_values import *
class Cls:
user = PrivateIni.get("NameInIni_ForUser")
pwd = PrivateIni.get("NameInIni_ForPwd", section="CustomSection")
- Change directory or filename or default section
str and pathlib are accepted
from private_values import *
class CustomIniValues(PrivateIni):
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 = PrivateEnv.get("Name_ForUser", _raise_exx=False)
pwd = PrivateIni.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(PrivateEnv):
RAISE_EXX = False
class CustomIniValues(PrivateIni):
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.1.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for private_values-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb5aeadd1330cf12b3daa530bd38909072e73d3a3dce00d88dda4441c644a9d2 |
|
MD5 | 432f0ae371bdce1b0fc87a682601e549 |
|
BLAKE2b-256 | 9906605e720b4638d2ec999e6afda89024533776877f7fefa2ced6830a40bb6d |