Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.5%) to scientific vocabulary
Keywords
Repository
Read and write TOML config files with dataclasses
Basic Info
Statistics
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 1
Topics
Metadata Files
README.md
Tosholi
Tosholi is a simple library for reading and writing TOML configuration files using Python dataclasses. Tosholi means to interpret or translate and comes from the Chickasaw and Choctaw languages.
Installation
bash
$ pip install tosholi
Get Started
Create your configuration as a Python dataclass. Configuration dataclasses can be nested, but can only be made of TOML support types.
Consider the following config.toml that we want to read into a dataclass.
(This example is based on toml.io).
```toml title = "TOML Example"
[owner] name = "Tom Preston-Werner" dob = 1979-05-27T07:32:00-08:00
[database] enabled = true ports = [ 8000, 8001, 8002 ] temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha] ip = "10.0.0.1" role = "frontend"
[servers.beta] ip = "10.0.0.2" role = "backend" ```
We can describe the configuration format with dataclasses.
```python from future import annotations
import dataclasses from datetime import datetime
@dataclasses.dataclass class Owner: name: str dob: datetime.datetime
@dataclasses.dataclass class Database: enabled: bool ports: list[int] temp_targets: dict[str, float]
@dataclasses.dataclass class Server: ip: str role: str
@dataclasses.dataclass class Config: title: str owner: Owner database: Database servers: dict[str, Server] ```
Then the configuration file can be read using the Config dataclass as a
the template for parsing.
python
with open('config.toml', 'rb') as f:
config = tosholi.load(Config, f)
Similarly, we can convert in the opposite direction. A Config instance
can be converted to a str with tosholi.dumps() or written it to a file
with tosholi.dump().
```python import tosholi from datetime import tzinfo
config = Config( title='TOML Example', owner=Owner( name='Tom Preston-Werner', dob=datetime(1979, 5, 27, 7, 32, 0), ), database=Database( enabled=True, ports=[8000, 8001, 8002], temp_targets={'cpu': 79.5, 'case': 72.0}, ), servers={ 'alpha': Server(ip='10.0.0.1', role='frontend'), 'beta': Server(ip='10.0.0.2', role='backend'), } )
with open('config.toml', 'wb') as f: tosholi.dump(config, f) ```
Developing
We use tox for testing and
pre-commit for linting. Get started for local
development with:
bash
$ tox --devenv venv -e py311
$ . venv/bin/activate
$ pre-commit install
or
bash
$ python -m venv venv
$ . venv/bin/activate
$ pip install -e .[dev]
$ pre-commit install
Owner
- Name: Greg Pauloski
- Login: gpauloski
- Kind: user
- Company: University of Chicago
- Website: gregpauloski.com
- Repositories: 8
- Profile: https://github.com/gpauloski
Computer Science Ph.D. Student at UChicago. Interested in systems for ML and HPC.
Citation (CITATION.cff)
cff-version: 1.2.0
message: If you use this software, please cite it as below.
authors:
- family-names: Pauloski
given-names: Greg
orcid: https://orcid.org/0000-0002-6547-6902
license: MIT
repository-code: https://github.com/gpauloski/tosholi
title: Tosholi
GitHub Events
Total
- Watch event: 3
- Delete event: 32
- Push event: 32
- Pull request event: 72
- Create event: 36
Last Year
- Watch event: 3
- Delete event: 32
- Push event: 32
- Pull request event: 72
- Create event: 36
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 74
- Average time to close issues: about 16 hours
- Average time to close pull requests: about 16 hours
- Total issue authors: 1
- Total pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 58
- Bot issues: 1
- Bot pull requests: 72
Past Year
- Issues: 1
- Pull requests: 42
- Average time to close issues: about 16 hours
- Average time to close pull requests: about 14 hours
- Issue authors: 1
- Pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 31
- Bot issues: 1
- Bot pull requests: 41
Top Authors
Issue Authors
- pre-commit-ci[bot] (1)
Pull Request Authors
- pre-commit-ci[bot] (70)
- gpauloski (2)
- dependabot[bot] (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 211 last-month
- Total dependent packages: 1
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
pypi.org: tosholi
Read and write TOML config files with dataclasses.
- Documentation: https://tosholi.readthedocs.io/
- License: MIT
-
Latest release: 0.1.0
published over 2 years ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v4 composite
- actions/checkout v4 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish release/v1 composite
- actions/cache v3 composite
- actions/checkout v4 composite
- actions/setup-python v4 composite
- dacite *
- tomli python_version<'3.11'
- tomli-w *