# private_values (v0.5.8)
## 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
1. load values to instance attrs from:
- Environment
- IniFile
- JsonFile
- CsvFile
- direct text instead of file
- direct dict instead of file
2. attr access:
- via any lettercase
- by instance attr
- like dict key on instance
3. work with dict:
- apply
- update
- preupdate
4. update_dict as cumulative result - useful in case of settings result
********************************************************************************
## License
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
## Release history
See the [HISTORY.md](HISTORY.md) file for release history.
## Installation
```commandline
pip install private-values
```
## Import
```python
from private_values import *
```
********************************************************************************
## USAGE EXAMPLES
See tests and sourcecode for other examples.
------------------------------
### 1. example1.py
```python
# ===================================================================
# 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
# ===================================================================
```
********************************************************************************
Raw data
{
"_id": null,
"home_page": "https://github.com/centroid457/",
"name": "private-values",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "environs,environment,private,rc,ini,csvjson",
"author": "Andrei Starichenko",
"author_email": "centroid@mail.ru",
"download_url": "https://files.pythonhosted.org/packages/e3/74/15db56e050daf5ba7f4d21a9c919ff1be9e1e58d53d2c343450a275b3be2/private_values-0.5.8.tar.gz",
"platform": null,
"description": "# private_values (v0.5.8)\r\n\r\n## DESCRIPTION_SHORT\r\nUpdate values into class attrs from osenvironment or ini/json file\r\n\r\n## DESCRIPTION_LONG\r\ndesigned to use private data like username/pwd kept secure in osenvironment or ini/json-file for your several home projects at ones. \r\nand not open it in public. \r\n\r\n**caution:** \r\nin requirements for other projects use fixed version! because it might be refactored so you would get exception soon.\r\n\r\n\r\n## Features\r\n1. load values to instance attrs from: \r\n\t- Environment \r\n\t- IniFile \r\n\t- JsonFile \r\n\t- CsvFile \r\n\t- direct text instead of file \r\n\t- direct dict instead of file \r\n2. attr access: \r\n\t- via any lettercase \r\n\t- by instance attr \r\n\t- like dict key on instance \r\n3. work with dict: \r\n\t- apply \r\n\t- update \r\n\t- preupdate \r\n4. update_dict as cumulative result - useful in case of settings result \r\n\r\n\r\n********************************************************************************\r\n## License\r\nSee the [LICENSE](LICENSE) file for license rights and limitations (MIT).\r\n\r\n\r\n## Release history\r\nSee the [HISTORY.md](HISTORY.md) file for release history.\r\n\r\n\r\n## Installation\r\n```commandline\r\npip install private-values\r\n```\r\n\r\n\r\n## Import\r\n```python\r\nfrom private_values import *\r\n```\r\n\r\n\r\n********************************************************************************\r\n## USAGE EXAMPLES\r\nSee tests and sourcecode for other examples.\r\n\r\n------------------------------\r\n### 1. example1.py\r\n```python\r\n# ===================================================================\r\n# by instance attr\r\n# {\"AUTH\": {\"NAME\": \"MyName\", \"PWD\": \"MyPwd\"}}\r\n\r\nfrom private_values import *\r\n\r\nclass Cls:\r\n data = PrivateAuthJson(_section=\"AUTH\")\r\n def connect(self):\r\n name = self.data.NAME\r\n name = self.data.NamE # case insensitive\r\n\r\n# like dict key on instance\r\n# {\"AUTH\": {\"NAME\": \"MyName\", \"PWD\": \"MyPwd\"}}\r\n\r\nfrom private_values import *\r\n\r\nclass Cls:\r\n data = PrivateAuthJson(_section=\"AUTH\")\r\n def connect(self):\r\n name = self.data[\"NAME\"]\r\n name = self.data[\"NamE\"] # case insensitive\r\n\r\n# ===================================================================\r\n### use annotations for your param names (best practice!)\r\n# when instantiating if it will not get loaded these exact params from your private sources - RAISE! \r\n# but you could not use it and however keep access to all existed params in used section!\r\n# {\"AUTH\": {\"NAME\": \"MyName\", \"PWD\": \"MyPwd\"}}\r\n\r\nfrom private_values import *\r\nclass MyPrivateJson(PrivateJson):\r\n NAME: str\r\n PWD: str\r\n\r\nname = MyPrivateJson().NAME\r\n\r\n\r\n# ===================================================================\r\n# in example above you could simply use existed classes\r\nfrom private_values import *\r\nname = PrivateAuthJson().NAME\r\n\r\n\r\n# ===================================================================\r\n### 1. Env\r\n\r\nfrom private_values import *\r\n\r\nclass Cls:\r\n user = PrivateEnv[\"NAME\"]\r\n user = PrivateEnv.NAME\r\n\r\n\r\n# ===================================================================\r\n### 2. IniFile\r\n# Use different sections\r\nfrom private_values import *\r\nclass Cls:\r\n user = PrivateIni(_section=\"CustomSection\").NAME\r\n\r\n\r\n# ===================================================================\r\n# Change full settings\r\nfrom private_values import *\r\n\r\nclass CustomIniValues(PrivateIni):\r\n DIRPATH = \"new/path/\"\r\n DIRPATH = pathlib.Path(\"new/path/\")\r\n FILENAME = \"my.ini\"\r\n SECTION = \"CustomSection\"\r\n\r\nclass Cls:\r\n user = CustomIniValues.NAME\r\n\r\n# ===================================================================\r\n# Without creating new class\r\nfrom private_values import *\r\nclass Cls:\r\n pv1 = PrivateIni(_filename=\"otherFilename\").pv1\r\n\r\n\r\n# ===================================================================\r\n### 3. JsonFile\r\n# {\"AUTH\": {\"NAME\": \"MyName\", \"PWD\": \"MyPwd\"}}\r\n\r\nfrom private_values import *\r\n\r\nclass MyPrivateJson(PrivateJson):\r\n SECTION = \"AUTH\"\r\n NAME: str\r\n PWD: str\r\n\r\nclass Cls:\r\n data = MyPrivateJson()\r\n def connect(self):\r\n name = self.data.NAME\r\n\r\n# ===================================================================\r\n# use already created templates (PrivateAuthJson/PrivateTgBotAddressJson) for standard attributes\r\n# {\"AUTH\": {\"NAME\": \"MyName\", \"PWD\": \"MyPwd\"}}\r\n\r\nfrom private_values import *\r\n\r\nclass Cls:\r\n data = PrivateAuthJson(_section=\"AUTH\")\r\n def connect(self):\r\n name = self.data.NAME\r\n\r\n# ===================================================================\r\n### 4. Auto \r\n# you can use universal class \r\n# it will trying get all your annotated params from one source of Json/Ini/Env (in exact order) \r\n# in this case you cant use FileName and must use annotations!\r\n\r\n# {\"AUTH\": {\"NAME\": \"MyName\", \"PWD\": \"MyPwd\"}}\r\n\r\nfrom private_values import *\r\n\r\nclass MyPrivate(PrivateAuto):\r\n SECTION = \"AUTH\"\r\n NAME: str\r\n PWD: str\r\n\r\nname = MyPrivate().NAME\r\n# ===================================================================\r\n```\r\n\r\n********************************************************************************\r\n",
"bugtrack_url": null,
"license": "",
"summary": "update values into class attrs from OsEnvironment or Ini/Json File",
"version": "0.5.8",
"project_urls": {
"Homepage": "https://github.com/centroid457/",
"Source": "https://github.com/centroid457/private_values"
},
"split_keywords": [
"environs",
"environment",
"private",
"rc",
"ini",
"csvjson"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e628c7473e17bf9f0c7413c369fb35d83ebcf9ebe99f69823919e5f0990b1d99",
"md5": "3c667a9599632b5dc1023548a1cdc9f7",
"sha256": "fbb7cf3cbc54dd89032e5df9bfb55c44019a260a657a9572799594d3cd4255a3"
},
"downloads": -1,
"filename": "private_values-0.5.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3c667a9599632b5dc1023548a1cdc9f7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 9657,
"upload_time": "2024-01-25T08:36:30",
"upload_time_iso_8601": "2024-01-25T08:36:30.462444Z",
"url": "https://files.pythonhosted.org/packages/e6/28/c7473e17bf9f0c7413c369fb35d83ebcf9ebe99f69823919e5f0990b1d99/private_values-0.5.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e37415db56e050daf5ba7f4d21a9c919ff1be9e1e58d53d2c343450a275b3be2",
"md5": "9c155a457fa6b6367fcd8bd79dfea1ee",
"sha256": "da954b30487cfa3490b5c572ac5b85ba396b09326c36d637b77d34a5da748b01"
},
"downloads": -1,
"filename": "private_values-0.5.8.tar.gz",
"has_sig": false,
"md5_digest": "9c155a457fa6b6367fcd8bd79dfea1ee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 9237,
"upload_time": "2024-01-25T08:36:32",
"upload_time_iso_8601": "2024-01-25T08:36:32.251900Z",
"url": "https://files.pythonhosted.org/packages/e3/74/15db56e050daf5ba7f4d21a9c919ff1be9e1e58d53d2c343450a275b3be2/private_values-0.5.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-25 08:36:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "centroid457",
"github_project": "private_values",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "private-values"
}