Skip to main content

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

  1. load values to instance attrs from:
    • Environment
    • iniFile
    • JsonFile
  2. attr acess
    • via any lettercase
      see below
    • by instanse 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

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)

Uploaded Source

Built Distribution

private_values-0.4.1-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page