From ce513bc1cad4baca99ccfd201cc2ce7e9c0a0af0 Mon Sep 17 00:00:00 2001 From: dormant-user Date: Tue, 25 Jun 2024 21:57:57 -0500 Subject: [PATCH] Remove backup directory and replace with owner name Fix base API url for user profile vs organization Make field description optional Update README.md, runbook and add more OOP --- .gitignore | 2 - README.md | 40 ++++++- doc_gen/conf.py | 3 +- doc_gen/index.rst | 21 +++- docs/README.html | 40 ++++++- docs/README.md | 40 ++++++- docs/_sources/README.md.txt | 40 ++++++- docs/_sources/index.rst.txt | 21 +++- docs/genindex.html | 86 ++++++++++++-- docs/index.html | 229 ++++++++++++++++++++++++++++-------- docs/objects.inv | Bin 527 -> 671 bytes docs/py-modindex.html | 5 + docs/searchindex.js | 2 +- git2s3/config.py | 57 ++------- git2s3/main.py | 98 ++++++++++----- git2s3/squire.py | 2 +- 16 files changed, 543 insertions(+), 143 deletions(-) diff --git a/.gitignore b/.gitignore index a567562..c906af6 100644 --- a/.gitignore +++ b/.gitignore @@ -161,8 +161,6 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ -backup/ - # Sphinx !doc_gen/conf.py !doc_gen/index.rst diff --git a/README.md b/README.md index 5b0c1c0..92c9cbc 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,44 @@ git2s3 start > Use `git2s3 --help` for usage instructions. +## Environment Variables + +
+Sourcing environment variables from an env file + +Environment variables can be sourced using any `plaintext` / `JSON` / `YAML` file. +The filepath should be provided as an argument during object instantiation. + +> _By default, `Git2S3` will look for a `.env` file in the current working directory._ + +**Examples** + +- **CLI** +```shell +git2s3 start --env-file "/path/to/env/file" +``` + +- **IDE** +```python +import git2s3 +backup = git2s3.Git2S3(env_file='/path/to/env/file') +backup.start() +``` + +
+ +- **GIT_API_URL** - GitHub API endpoint. Defaults to `https://api.github.com/` +- **GIT_OWNER** - GitHub profile owner or organization name. +- **GIT_TOKEN** - GitHub token to get ALL repos (including private). +- **FIELDS** - Fields options to restore. Defaults to all. +- **LOG** - Log options to log to a ``file`` or ``stdout``. _Does not apply when custom logger is used_ +- **DEBUG** - Boolean flag to enable debug level logging. _Does not apply when custom logger is used_ +- **AWS_PROFILE_NAME** - AWS profile name. Uses the CLI config value ``AWS_DEFAULT_PROFILE`` by default. +- **AWS_ACCESS_KEY_ID** - AWS access key ID. Uses the CLI config value ``AWS_ACCESS_KEY_ID`` by default. +- **AWS_SECRET_ACCESS_KEY** - AWS secret key. Uses the CLI config value ``AWS_SECRET_ACCESS_KEY`` by default. +- **AWS_REGION_NAME** - S3 bucket's region. Uses the CLI config value ``AWS_DEFAULT_REGION`` by default. +- **AWS_BUCKET_NAME** - AWS bucket name to store the backups. + ## Coding Standards Docstring format: [`Google`][google-docs]
Styling conventions: [`PEP 8`][pep8] and [`isort`][isort] @@ -96,7 +134,7 @@ Licensed under the [MIT License][license] [label-actions-markdown]: https://github.com/thevickypedia/git2s3/actions/workflows/markdown.yaml/badge.svg [label-pypi-package]: https://img.shields.io/badge/Pypi%20Package-git2s3-blue?style=for-the-badge&logo=Python [label-sphinx-doc]: https://img.shields.io/badge/Made%20with-Sphinx-blue?style=for-the-badge&logo=Sphinx -[label-pyversion]: https://img.shields.io/badge/python-3.10%20%7C%203.11-orange +[label-pyversion]: https://img.shields.io/badge/python-3.10%20%7C%203.11-blue [label-platform]: https://img.shields.io/badge/Platform-Linux|macOS|Windows-1f425f.svg [label-actions-pages]: https://github.com/thevickypedia/git2s3/actions/workflows/pages/pages-build-deployment/badge.svg [label-actions-pypi]: https://github.com/thevickypedia/git2s3/actions/workflows/python-publish.yaml/badge.svg diff --git a/doc_gen/conf.py b/doc_gen/conf.py index 2e698a7..6b7be8e 100644 --- a/doc_gen/conf.py +++ b/doc_gen/conf.py @@ -56,8 +56,9 @@ html_static_path = ["_static"] # Add docstrings from __init__ method +# This will also include __init__ docs from 'pydantic.BaseModel' and 'pydantic.BaseSettings' # Reference: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autoclass_content -autoclass_content = "both" +# autoclass_content = "both" # Include private methods/functions # Reference: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_default_options diff --git a/doc_gen/index.rst b/doc_gen/index.rst index be97df2..62b352e 100644 --- a/doc_gen/index.rst +++ b/doc_gen/index.rst @@ -16,12 +16,31 @@ Git2S3 - Main ============= .. automodule:: git2s3.main +Squire +====== +.. automodule:: git2s3.squire + Configuration ============= -.. autoclass:: git2s3.config.EnvConfig(BaseSettings) + +.. autoclass:: git2s3.config.Field(BaseModel) :members: EnvConfig :exclude-members: _abc_impl, model_config, model_fields +==== + +.. autoclass:: git2s3.config.EnvConfig(BaseSettings) + :members: EnvConfig + :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields + +==== + +.. autoclass:: git2s3.config.LogOptions(StrEnum) + +==== + +.. autoclass:: git2s3.config.Fields(StrEnum) + Indices and tables ================== diff --git a/docs/README.html b/docs/README.html index fe140a5..c28c983 100644 --- a/docs/README.html +++ b/docs/README.html @@ -46,7 +46,7 @@

Navigation

Git2S3

Backup GitHub projects to AWS S3

-

Python

+

Python

Platform Supported

Platform

Deployments

@@ -84,6 +84,43 @@

Kick offgit2s3 --help for usage instructions.

+
+

Environment Variables

+
+Sourcing environment variables from an env file

Environment variables can be sourced using any plaintext / JSON / YAML file. +The filepath should be provided as an argument during object instantiation.

+
+

By default, Git2S3 will look for a .env file in the current working directory.

+
+

Examples

+
    +
  • CLI

  • +
+
git2s3 start --env-file "/path/to/env/file"
+
+
+
    +
  • IDE

  • +
+
import git2s3
+backup = git2s3.Git2S3(env_file='/path/to/env/file')
+backup.start()
+
+
+
+

Coding Standards

Docstring format: Google
@@ -142,6 +179,7 @@

Table of Contents