private-values


Nameprivate-values JSON
Version 0.6.1 PyPI version JSON
download
home_pagehttps://github.com/centroid457/
Summaryupdate values into class attrs from OsEnvironment or Ini/Json File
upload_time2024-10-16 13:58:28
maintainerNone
docs_urlNone
authorAndrei Starichenko
requires_python>=3.6
licenseNone
keywords environs environment private rc ini csvjson
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Ver/TestedPython](https://img.shields.io/pypi/pyversions/private_values)
![Ver/Os](https://img.shields.io/badge/os_development-Windows-blue)  
![repo/Created](https://img.shields.io/github/created-at/centroid457/private_values)
![Commit/Last](https://img.shields.io/github/last-commit/centroid457/private_values)
![Tests/GitHubWorkflowStatus](https://github.com/centroid457/private_values/actions/workflows/test_linux.yml/badge.svg)
![Tests/GitHubWorkflowStatus](https://github.com/centroid457/private_values/actions/workflows/test_windows.yml/badge.svg)  
![repo/Size](https://img.shields.io/github/repo-size/centroid457/private_values)
![Commit/Count/t](https://img.shields.io/github/commit-activity/t/centroid457/private_values)
![Commit/Count/y](https://img.shields.io/github/commit-activity/y/centroid457/private_values)
![Commit/Count/m](https://img.shields.io/github/commit-activity/m/centroid457/private_values)

# private_values (current v0.6.1/![Ver/Pypi Latest](https://img.shields.io/pypi/v/private_values?label=pypi%20latest))

## 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, sourcecode and docstrings 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": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "environs, environment, private, rc, ini, csvjson",
    "author": "Andrei Starichenko",
    "author_email": "centroid@mail.ru",
    "download_url": "https://files.pythonhosted.org/packages/9b/0a/d0d7b176a2152f8881da0c6d7059ab619a4e304f9d239a068fc90f67248d/private_values-0.6.1.tar.gz",
    "platform": null,
    "description": "![Ver/TestedPython](https://img.shields.io/pypi/pyversions/private_values)\r\n![Ver/Os](https://img.shields.io/badge/os_development-Windows-blue)  \r\n![repo/Created](https://img.shields.io/github/created-at/centroid457/private_values)\r\n![Commit/Last](https://img.shields.io/github/last-commit/centroid457/private_values)\r\n![Tests/GitHubWorkflowStatus](https://github.com/centroid457/private_values/actions/workflows/test_linux.yml/badge.svg)\r\n![Tests/GitHubWorkflowStatus](https://github.com/centroid457/private_values/actions/workflows/test_windows.yml/badge.svg)  \r\n![repo/Size](https://img.shields.io/github/repo-size/centroid457/private_values)\r\n![Commit/Count/t](https://img.shields.io/github/commit-activity/t/centroid457/private_values)\r\n![Commit/Count/y](https://img.shields.io/github/commit-activity/y/centroid457/private_values)\r\n![Commit/Count/m](https://img.shields.io/github/commit-activity/m/centroid457/private_values)\r\n\r\n# private_values (current v0.6.1/![Ver/Pypi Latest](https://img.shields.io/pypi/v/private_values?label=pypi%20latest))\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\n    And not open it in public.  \r\n\r\n    **CAUTION:**  \r\n    in 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, sourcecode and docstrings 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": null,
    "summary": "update values into class attrs from OsEnvironment or Ini/Json File",
    "version": "0.6.1",
    "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": "282a4daaecdb3ef45710b1c0be067876c8b7ccfc13d969e9b8433e411ed799ba",
                "md5": "4f73ba4443195fe83de8183c9fc766b0",
                "sha256": "9f78f79fb55cd2aab5b598c199c984305c41b0b47037f8faa8899081ac283884"
            },
            "downloads": -1,
            "filename": "private_values-0.6.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4f73ba4443195fe83de8183c9fc766b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10739,
            "upload_time": "2024-10-16T13:58:27",
            "upload_time_iso_8601": "2024-10-16T13:58:27.382823Z",
            "url": "https://files.pythonhosted.org/packages/28/2a/4daaecdb3ef45710b1c0be067876c8b7ccfc13d969e9b8433e411ed799ba/private_values-0.6.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9b0ad0d7b176a2152f8881da0c6d7059ab619a4e304f9d239a068fc90f67248d",
                "md5": "effe9cfeca9b3fc56b9bc1b7d8bb5880",
                "sha256": "966a1d28daba586a2c47fc6a054b7faeced17dc6b291155baf7800d1afdef2e5"
            },
            "downloads": -1,
            "filename": "private_values-0.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "effe9cfeca9b3fc56b9bc1b7d8bb5880",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12564,
            "upload_time": "2024-10-16T13:58:28",
            "upload_time_iso_8601": "2024-10-16T13:58:28.520533Z",
            "url": "https://files.pythonhosted.org/packages/9b/0a/d0d7b176a2152f8881da0c6d7059ab619a4e304f9d239a068fc90f67248d/private_values-0.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-16 13:58:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "centroid457",
    "github_project": "private_values",
    "github_not_found": true,
    "lcname": "private-values"
}
        
Elapsed time: 0.44024s