private_values (current v0.6.1/
)
DESCRIPTION_SHORT
update values into class attrs from OsEnvironment or Ini/Json File
DESCRIPTION_LONG
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.
**CAUTION:**
in requirements for other projects use fixed version! because it might be refactored so you would get exception soon.
Features
- load values to instance attrs from:
- Environment
- IniFile
- JsonFile
- CsvFile
- direct text instead of file
- direct dict instead of file
- attr access:
- via any lettercase
- by instance attr
- like dict key on instance
- work with dict:
- apply
- update
- preupdate
- update_dict as cumulative result - useful in case of settings result
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 *
USAGE EXAMPLES
See tests, sourcecode and docstrings for other examples.
1. example1.py
# ===================================================================
# by instance attr
# {"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
# ===================================================================
### 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"}}
from private_values import *
class MyPrivateJson(PrivateJson):
NAME: str
PWD: str
name = MyPrivateJson().NAME
# ===================================================================
# in example above you could simply use existed classes
from private_values import *
name = PrivateAuthJson().NAME
# ===================================================================
### 1. Env
from private_values import *
class Cls:
user = PrivateEnv["NAME"]
user = PrivateEnv.NAME
# ===================================================================
### 2. IniFile
# 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
# ===================================================================
### 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"}}
from private_values import *
class MyPrivate(PrivateAuto):
SECTION = "AUTH"
NAME: str
PWD: str
name = MyPrivate().NAME
# ===================================================================
Metadata
Release files for private-values 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| private_values-0.6.1.tar.gz | 12.6 kB | Without provenance | Details for private_values-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| private_values-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for private_values-0.6.1-py3-none-any.whl |
Total release size: 23.3 kB
Release files / private_values-0.6.1.tar.gz
| Download URL | private_values-0.6.1.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
966a1d28daba586a2c47fc6a054b7faeced17dc6b291155baf7800d1afdef2e5
|
|
BLAKE2b-256 checksum How to use checksums |
9b0ad0d7b176a2152f8881da0c6d7059ab619a4e304f9d239a068fc90f67248d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / private_values-0.6.1-py3-none-any.whl
| Download URL | private_values-0.6.1-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f78f79fb55cd2aab5b598c199c984305c41b0b47037f8faa8899081ac283884
|
|
BLAKE2b-256 checksum How to use checksums |
282a4daaecdb3ef45710b1c0be067876c8b7ccfc13d969e9b8433e411ed799ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for private-values 0.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.