Easy Config
py_simple.easy_config
easy_config aims to simplify creating configuration files.
EasyConfigError
Bases: Exception
Raised when a config file could not be written. This wraps the underlying error (missing template, permission denied, no git repository found) so callers only have to catch one exception type instead of several. Args: message (str): Description of what went wrong.
gh_workflow_config(filename, at_root=True)
Creates a starter GitHub Actions workflow file from a template.
The workflow is written to '.github/workflows/<filename>.yml', with
the placeholder '[NAME]' in the template replaced by filename. Any
missing folders are created. If the file already exists it is left
alone.
Args:
filename (str): Name for the workflow, without the '.yml'
extension (e.g. 'issues' -> '.github/workflows/issues.yml').
at_root (bool, optional): When True, the path is relative to the
current working directory. When False, the git repository
root is looked up and the workflow is placed there.
Defaults to True.
Returns:
None
Raises:
EasyConfigError: If the template cannot be read or the workflow
file cannot be written.
Example:
=== "The Py_simple Way"
```python
from py_simple import gh_workflow_config
gh_workflow_config("issues")
```
=== "The Traditional Way"
```python
import os
os.makedirs(".github/workflows", exist_ok=True)
with open(".github/workflows/issues.yml", "w",
encoding="utf-8") as f:
f.write(
"name: issues
" " " "on: " " " "jobs: " " build: " " runs-on: ubuntu-latest " " " " steps: " " - uses: actions/checkout@v7 " " - name: " " run: " ) ```