# AutoConfigPy
AutoConfigPy is a lightweight JSON config and data-storage library for Python apps, games, bots, tools, and servers.
It automatically handles creating folders, creating JSON files, reading data, writing data, adding numbers, incrementing values, appending list items, removing list items, backups, defaults, and update checks.
## Installation
```bash
pip install autoconfigpy
Community
Need help, want to report a bug, or have an idea for a new feature?
Join the community Discord for support, updates, bug reports, and suggestions for AutoConfigPy, Easy2D, and other related libraries:
Quick Example
from autoconfigpy import DataFile
data = DataFile("data/players.json")
data.write("players.player1.coins", 100)
data.add("players.player1.coins", 50)
data.increment("players.player1.level")
data.append("players.player1.inventory", "gold_sword")
data.append("players.player1.inventory", "health_potion")
data.remove("players.player1.inventory", "health_potion")
print(data.read("players.player1.coins", 0))
print(data.read("players.player1.level", 1))
print(data.read("players.player1.inventory", []))
Output:
150
1
['gold_sword']
Created JSON:
{
"players": {
"player1": {
"coins": 150,
"level": 1,
"inventory": [
"gold_sword"
]
}
}
}
DataFile Usage
DataFile is the easiest way to work with one JSON file.
from autoconfigpy import DataFile
data = DataFile("data/save.json")
data.write("game.score", 100)
data.add("game.score", 25)
data.subtract("game.score", 10)
score = data.read("game.score", 0)
print(score)
Function-Style Usage
You can also use AutoConfigPy without creating a DataFile object.
from autoconfigpy import write_data, read_data, add_data, append_data
write_data("data/players.json", "players.player1.coins", 100)
add_data("data/players.json", "players.player1.coins", 25)
append_data("data/players.json", "players.player1.inventory", "gold_sword")
coins = read_data("data/players.json", "players.player1.coins", 0)
print(coins)
Output:
125
Config Usage
Use Config when you want defaults, required keys, environment loading, backups, and manual save control.
from autoconfigpy import Config
cfg = Config("settings.json", defaults={
"window.width": 1280,
"window.height": 720,
"theme": "dark",
})
print(cfg.get("window.width"))
cfg.set("theme", "light")
cfg.save()
Created JSON:
{
"window": {
"width": 1280,
"height": 720
},
"theme": "light"
}
Lists
AutoConfigPy can manage lists inside JSON files.
from autoconfigpy import DataFile
data = DataFile("data/save.json")
data.append("player.inventory", "sword")
data.append("player.inventory", "shield")
data.remove("player.inventory", "shield")
print(data.read("player.inventory", []))
Output:
['sword']
Backups
from autoconfigpy import Config
cfg = Config("settings.json")
backup_path = cfg.backup()
print(backup_path)
Required Keys
from autoconfigpy import Config
cfg = Config("settings.json")
api_key = cfg.require("api.key")
If the key is missing, AutoConfigPy raises an error.
Update Check
AutoConfigPy can check PyPI and tell the user if a newer version is available.
from autoconfigpy import check_for_updates
check_for_updates()
Example output when an update exists:
Update available for autoconfigpy: 0.2.1 -> 0.2.2
Run: python -m pip install --upgrade autoconfigpy
Example output when current:
autoconfigpy is up to date. Current version: 0.2.2
This does not install updates automatically. It only tells the user what command to run.
License
AutoConfigPy is released under the MIT License.
Metadata
Release files for autoconfigpy 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| autoconfigpy-0.2.5.tar.gz | 14.2 kB | Without provenance | Details for autoconfigpy-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| autoconfigpy-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for autoconfigpy-0.2.5-py3-none-any.whl |
Total release size: 24.9 kB
Release files / autoconfigpy-0.2.5.tar.gz
| Download URL | autoconfigpy-0.2.5.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
055846d40dfb12e93acc5b1c05d7999761629ab76135b747233a02f5cb63d497
|
|
BLAKE2b-256 checksum How to use checksums |
793ea1fce804a4a7846ccf779d143ec57231be6658acf91e99b9f17b1f173881
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / autoconfigpy-0.2.5-py3-none-any.whl
| Download URL | autoconfigpy-0.2.5-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3c042a6b405640bcfbe2868fbfed5af4edcdc419da669d697f64ffa20218ecd6
|
|
BLAKE2b-256 checksum How to use checksums |
bac570838aebb3355fc6975e611f4c3ff5cd4457b4cb24a2c63f87aaac5d6488
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for autoconfigpy 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.