Awesome `sys-config` is a Python cli/package created with https://github.com/william-cass-wright/cookiecutter-pypackage-slim
Project description
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
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 ./
- bump version
poetry version [major, minor, bug]
only updates within pyproject.toml
- 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
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sys-config-0.2.1.tar.gz.
File metadata
- Download URL: sys-config-0.2.1.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.10.8 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af063cb33082c1223d8208e289766319b0a0297094b3bc82e738beb9ecebe4ba
|
|
| MD5 |
357bed524429e6bbbf71e8f3d21cc51f
|
|
| BLAKE2b-256 |
02bc802a6461172bd333fe112024779d14e6f94121ad55aec33026634ee0a64c
|
File details
Details for the file sys_config-0.2.1-py3-none-any.whl.
File metadata
- Download URL: sys_config-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.10.8 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0422b5e0df78736a0307556bef8253865efe8644dc97cd0c42160ae564d1dc5
|
|
| MD5 |
1fc998d62c7da97c36647fdf4174b783
|
|
| BLAKE2b-256 |
c572232fc8d450dbd6a731374d230a4802067535f5f904c9b5ae5becebc1f2c5
|