Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/withprecedent/bobbie
Flexible, easy configuration for Python projects
https://github.com/withprecedent/bobbie
configuration settings
Last synced: 26 days ago
JSON representation
Flexible, easy configuration for Python projects
- Host: GitHub
- URL: https://github.com/withprecedent/bobbie
- Owner: WithPrecedent
- License: other
- Created: 2021-10-10T22:31:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-23T20:34:25.000Z (9 months ago)
- Last Synced: 2025-01-16T03:20:18.586Z (about 1 month ago)
- Topics: configuration, settings
- Language: Python
- Homepage:
- Size: 935 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# bobbie
| | |
| --- | --- |
| Version | [](https://pypi.org/project/bobbie/) [](https://github.com/WithPrecedent/bobbie/releases)
| Status | [](https://github.com/WithPrecedent/bobbie/actions/workflows/ci.yml?query=branch%3Amain) [](https://www.repostatus.org/#active) [](https://pypi.org/project/bobbie/)
| Documentation | [](https://WithPrecedent.github.io/bobbie)
| Tools | [](https://squidfunk.github.io/mkdocs-material/) [](https://github.com/astral-sh/Ruff) [](https://PDM.fming.dev) [](https://github.com/TezRomacH/python-package-template/blob/master/.pre-commit-config.yaml) [](https://github.com/features/actions) [](https://editorconfig.org/) [](https://www.github.com/WithPrecedent/bobbie) [](https://github.com/dependabot)
| Compatibility | [](https://pypi.python.org/pypi/bobbie/) [](https://www.linux.org/) [](https://www.apple.com/macos/) [](https://www.microsoft.com/en-us/windows?r=1)
| Stats | [](https://pypi.org/project/bobbie) [](https://github.com/WithPrecedent/bobbie/stargazers) [](https://github.com/WithPrecedent/bobbie/graphs/contributors) [](https://github.com/WithPrecedent/bobbie/graphs/contributors) [](https://github.com/WithPrecedent/bobbie/forks)
| | |-----
## What is bobbie?
![]()
There is no better option for leading a mission/project than [former Gunnery
Sergeant and all-aroubd badass Roberta
Draper](https://expanse.fandom.com/wiki/Bobbie_Draper_(TV)), for whom this
package is named. `bobbie` provides
a lightweight, easy-to-use, flexible, and extensible `Settings` class for loading and
storing configuration settings for a Python project.## Why use bobbie?
There are [numerous options](#similar-projects) for storing project configuration settings in Python.
So, what makes `bobbie` different?* **Flexible**: a `Settings` instance is easily built from a `dict`, `.py`
module, or file (`.env`, `.ini`, `.json`, `.toml`, or `.yaml` are supported) file.
* **Lightweight**: no required dependencies (there are optional dependencies for
importing data from certain file types) and an efficient codebase ensure a
very small memory footprint.
* **Intuitive**: a `create` class method constructs `Settings` (from any data source).
* **Convenient**: unlike `configparser`, automatic data and type validation is performed when
`Settings` is created.
* **Extensible**: you can easily add new parsing rules by subclassing `Parser`.
![]()
The [comparison table](#feature-comparison-of-python-configuration-libraries)
below shows how `bobbie` compares to the other major options that store
configuration options for Python projects.## Getting started
### Installation
To install `bobbie`, use `pip`:
```sh
pip install bobbie
```### Create a Settings instance
`bobbie` supports several ways to create a `Settings` instance. However, you can
opt to always use the `create` class method for any data source.#### From `dict`
```python
import bobbieconfiguration = {
'general': {
'verbose': False,
'seed': 43,
'parallelize': False},
'files': {
'source_format': 'csv',
'file_encoding': 'windows-1252',
'float_format': '%.4f',
'export_results': True}}
# You may use the general `create` method.
settings = bobbie.Settings.create(configuration)
# Or, just send a `dict` to `Settings` itself.
settings = bobbie.Settings(configuration)
```#### From file
```python
import bobbie# You may use the general `create` method.
settings = bobbie.Settings.create('settings_file.yaml')
# Or, the `from_file` method.
settings = bobbie.Settings.from_file('settings_file.yaml')
# Or, the `from_yaml` method. They all do the same thing.
settings = bobbie.Settings.from_yaml('settings_file.yaml')
```If the file is a Python module, it must contain a variable named `settings`.
## Contributing
Contributors are always welcome. Feel free to grab an [issue](https://www.github.com/WithPrecedent/bobbie/issues) to work on or make a suggested improvement. If you wish to contribute, please read the [Contribution Guide](https://www.github.com/WithPrecedent/bobbie/contributing.md) and [Code of Conduct](https://www.github.com/WithPrecedent/bobbie/code_of_conduct.md).
## Similar projects
There are a lot of great packages for storing project settings. The table below
shows the features of the leading libraries.### Feature Comparison of Python Configuration Libraries
![]()
| Library | Typing | Secrets | dict | env | ini | json | py | toml | yaml |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `bobbie`| ✅ | | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [`configParser`](https://docs.python.org/3/library/configParser.html) | | | | | ✅ | | | | |
| [`dynaconf`](https://github.com/dynaconf/dynaconf) | ✅ | ✅ | | ✅ | ✅ | ✅ | | ✅ | ✅ |
| [`Parser-it`](https://github.com/naorlivne/Parser_it) | ✅ | | | ✅ | ✅ | ✅ | | ✅ | ✅ |
| [`python-decouple`](https://github.com/HBNetwork/python-decouple) | ✅ | ✅ | | ✅ | ✅ | | | | |
| [`pyconfig`](https://github.com/shakefu/pyconfig) | | ✅ | | | | | | | || |
| [`pydantic-settings`](https://docs.pydantic.dev/latest/usage/pydantic_settings/) | ✅ | ✅ | | | | | | | | |As you can see, `bobiie` lacks a method for storing passwords, encryption keys,
and other secrets. That is largely because it is focused on internal Python
projects and the goal of keeping its resource usage as low as possible. So, if
you need secrets stored in your project settings, there are several good options
that you should explore.## Acknowledgments
I would like to thank the University of Kansas School of Law for tolerating and
supporting this law professor's coding efforts, an endeavor which is well
outside the typical scholarly activities in the discipline.## License
Use of this repository is authorized under the [Apache Software License 2.0](https://www.github.com/WithPrecedent/bobbie/blog/main/LICENSE).