Skip to main content

A simple wrapper for the py-scripts

Project description

swrapper

Description

The module allows you to adjust the frequency of the functions used:

    - logging
    - argparse
    - load config from *.yaml or *.json

Wlog

Wlog.sensitive_filter - regxp. Filter which used to mask logging output.

Wlog.set_logging(self) - if logging level debug, set two handlers to save output to cli and to the file.

Wargs

Wargs.add_defult_arguments - Set defaults arguments:

  -c, --config    `config file`
  -d, --debug     `debug mode`
  -l, --log       `set logfile`

Config

Load config from *.yaml or *.json.

sensetive_attributes - set attributes names which will be masked in output.

# config.json
# {"one": 123, "two": 234, "three": 345}
k = Config('config.json', type='json', sensetive_attributes=['two', ])
print(k)

output will be:

one = 123
two = ***hidden***
three = 345

Install

Still not published.

pip install py-script-wrapper

Usage example:

import swrapper


CONFIG = 'config.yaml'


def get_args():
    """Get arguments from CLI
    Returns:
        class 'argparse.Namespace': args
    """
    args_parser = swrapper.Wargs(description='scrip descriptio')
    args_parser.add_defult_arguments()
    args_parser.add_argument('--compare-state', help='compare state', action='store_true', dest='compare_state')

    return args_parser.parse_args()

args = get_args()
config_file = args.config if args.config else CONFIG
conf = swrapper.Config(config_file, sensetive_attributes=['password', 'secret_key', 'token'])
log_level = 'debug' if args.debug else conf.log_level
swrapper.Wlog(conf.log_file, log_level, sensitive_filter='[regex]+').set_logging()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_script_wrapper-0.2.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

py_script_wrapper-0.2.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file py_script_wrapper-0.2.1.tar.gz.

File metadata

  • Download URL: py_script_wrapper-0.2.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for py_script_wrapper-0.2.1.tar.gz
Algorithm Hash digest
SHA256 813d0eb9d3ee7ea3fa9b3812e24817dedae15ee1d19937b873866945b6ab7691
MD5 de9e59f7d5bc0ce4fd46d49f0b03b6b9
BLAKE2b-256 c902077658251fe9979a86bcae0013665434749fffca83955e0ecbeef8e77a42

See more details on using hashes here.

File details

Details for the file py_script_wrapper-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_script_wrapper-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ce873d904cd8b0d05b7e5af824f84d871a8b69c80054c60b1cdcc65095ca953
MD5 e923b93293248c2628191df71f29458b
BLAKE2b-256 b9f993c17e4be1556770bb43c192fc1acfbe46f6832f8e7da015a63bd3c40c07

See more details on using hashes here.

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