Get values from OsEnvironment or Ini/Json File
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 Ini/Json-File for your several home projects at ones.
And not open it in public.
Features
- load values to instance attrs from:
- Environment
- iniFile
- JsonFile
- attr acess
- via any lettercase
see below - by instanse attr
- via any lettercase
# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}
from private_values import *
class Cls:
data = PrivateAuthJson(_section="AUTH")
def connect(self):
name = self.data.NAME
name = self.data.NamE # case insensitive
- like dict key on instance
# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}
from private_values import *
class Cls:
data = PrivateAuthJson(_section="AUTH")
def connect(self):
name = self.data["NAME"]
name = self.data["NamE"] # case insensitive
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
from private_values import *
class Cls:
user = PrivateEnv["NAME"]
user = PrivateEnv.NAME
2. IniFile
- Use defaults (common usage)
from private_values import *
class Cls:
user = PrivateIni().NAME
- Use different sections
from private_values import *
class Cls:
user = PrivateIni(_section="CustomSection").NAME
- Change full settings
from private_values import *
class CustomIniValues(PrivateIni):
DIRPATH = "new/path/"
DIRPATH = pathlib.Path("new/path/")
FILENAME = "my.ini"
SECTION = "CustomSection"
class Cls:
user = CustomIniValues.NAME
- Without creating new class
from private_values import *
class Cls:
pv1 = PrivateIni(_filename="otherFilename").pv1
3. JsonFile
# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}
from private_values import *
class MyPrivateJson(PrivateJson):
SECTION = "AUTH"
NAME: str
PWD: str
class Cls:
data = MyPrivateJson()
def connect(self):
name = self.data.NAME
- use already created templates (PrivateAuthJson/PrivateTgBotAddressJson) for standard attributes
# {"AUTH": {"NAME": "MyName", "PWD": "MyPwd"}}
from private_values import *
class Cls:
data = PrivateAuthJson(_section="AUTH")
def connect(self):
name = self.data.NAME
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.4.1.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for private_values-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5330f3794433914a543e08f81ec57417fac7fc922e9328fa15082d631d55357a |
|
MD5 | d142e8c483e7e53fec38a58050d0520f |
|
BLAKE2b-256 | 8439d1ae274d45f5dd5bebed8dfdde154b74c48e3d314a477135f4298034e8bb |