Skip to main content

Awesome `sys-config` is a Python cli/package created with https://github.com/william-cass-wright/cookiecutter-pypackage-slim

Project description

sys-config

Build status Python Version Dependencies Status

Code style: black Security: bandit Pre-commit Semantic Versions License Coverage Report

sys-config is a Python package created with william-cass-wright/cookiecutter-pypackage-slim... kinda

PROJECT DEVELOPMENT NOTES

Summary

how to use

  • command line tool (component of smgmt)
    • transfer AWS Secrets to local (or visversa)
    • crawl ~/.config & ~ directories for credentials/configs
      • systematically extract and transform for command line
  • within CLI project (used to implement mmgmt)
    • init new project after binary install
    • explicitly call config file (endpoint usage pattern)
    • function dectorator (on top of command/endpoint)
    • within context???
  • other types of projects???

value to include in config file?

  • pypi tokens
  • api keys
  • dev and prod split
  • app specific references within file system

components

  • file crawler
  • extractor
  • click interface (class inheritance --> factory design pattern?)

Usage

implementation example within media-mgmt-cli:

from .config import ConfigHandler


class AwsStorageMgmt:
    def __init__(self):
        self.s3_resour = boto3.resource("s3")
        self.s3_client = boto3.client("s3")
        self.config = ConfigHandler(project_name="media_mgmt_cli")
        if self.config.check_config_exists():
            self.configs = self.config.get_configs()
            self.bucket = self.configs.get("aws_bucket", None)
            self.object_prefix = self.configs.get("aws_bucket_path", None)
        else:
            echo("config file does not exist, run `mmgmt configure`")

    def upload_file(self, file_name, object_name=None):
        """
        ...
        """
        echo(
            f"uploading: {file_name} \nto S3 bucket: {self.configs.get('aws_bucket')}/{self.configs.get('aws_bucket_path')}/{file_name}"
        )
        ...

Future Work

  • setup sys-config

Project Examples

Publishing Notes

  1. make install
#* Installation
.PHONY: install
install:
    poetry lock -n && poetry export --without-hashes > requirements.txt
    poetry install -n
    -poetry run mypy --install-types --non-interactive ./
  1. bump version
poetry version [major, minor, bug]

only updates within pyproject.toml

  1. publish

a. trigger pre-commit

git add .
git commit -m "new release"

b. fix issues, commit again, then tag

git tag -a v0.2.0 -m "sys-config rewrite"
git push -u origin publish-branch

c. publish with poetry

poetry publish --dry-run --build
poetry publish --build
  1. test
jupyter lab
python -m pip install sys-config

REPL

import sys_config
parser = sys_config.ConfigHandler()
parser.__dict__
# results
parser.__dir__()
# results
{'project_name': 'tmp',
 'home_path': PosixPath('/Users/willcasswrig'),
 'config_path': PosixPath('/Users/willcasswrig/.config/tmp'),
 'config_file_path': PosixPath('/Users/willcasswrig/.config/tmp/config'),
 'verbose': False,
 'parser': <configparser.ConfigParser at 0x7f8c224ec430>}


['project_name',
 'home_path',
 'config_path',
 'config_file_path',
 'verbose',
 'parser',
 '__module__',
 '__init__',
 'crud_create',
 'create_config_file',
 'crud_update',
 'update_parser',
 'crud_delete_file',
 'crud_read',
 'read_dict',
 'get_config_exists',
 'get_parser_sections',
 'write_config_file',
 'set_config_path',
 'reset_config_path',
 '__dict__',
 '__weakref__',
 '__doc__',
 '__new__',
 '__repr__',
 '__hash__',
 '__str__',
 '__getattribute__',
 '__setattr__',
 '__delattr__',
 '__lt__',
 '__le__',
 '__eq__',
 '__ne__',
 '__gt__',
 '__ge__',
 '__reduce_ex__',
 '__reduce__',
 '__subclasshook__',
 '__init_subclass__',
 '__format__',
 '__sizeof__',
 '__dir__',
 '__class__']

errors

parser.crud_read()

     82 def crud_read(self):
---> 83     self.read_dict(self.__dict__, self.__class__.__name__)

TypeError: Object of type PosixPath is not JSON serializable

parser.crud_create()

Signature: parser.crud_create()
Docstring: <no docstring>
File:      ~/miniconda/envs/jl2/lib/python3.10/site-packages/sys_config/main.py
Type:      method

add docstring

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

sys-config-0.2.1.tar.gz (17.8 kB view hashes)

Uploaded Source

Built Distribution

sys_config-0.2.1-py3-none-any.whl (16.2 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