Skip to main content

Tiny .ini → dict reader (~1KB): key=value and [section], zero deps

Project description

nano-ini

PyPI License Size CI

Tiny .ini → dict reader — ~1 KB, zero deps. Supports key=value and [section]; outputs JSON (dict). Perfect for code-golf, minimal containers, or just for fun.


✨ Features

  • ✅ Sections: [database], [app]
  • ✅ Keys: key=value (whitespace trimmed)
  • ✅ Full-line comments: ; or #
  • ✅ Root keys (before any section) stored under empty section ""
  • ✅ Zero dependencies • single tiny file • CLI included

🚀 Usage

; sample.ini
name = nano
[database]
host = localhost
port = 5432
# Local (from repo)
python app_min.py sample.ini
# {"":"","database":{"host":"localhost","port":"5432"}}
python app_min.py sample.ini database
# {"host":"localhost","port":"5432"}

# stdin
cat sample.ini | python app_min.py

After installing:

# CLI
pip install nano-ini
nano-ini sample.ini                 # full JSON
nano-ini sample.ini database        # one section

🤓 Why so small?

  • Pure stdlib, hand-rolled parser (no configparser dependency)
  • Minimal rules: key=value, [section], full-line comments only
  • Dumps compact JSON with separators=(',',':')

Notes:

  • Values are kept as strings (no auto-casting or interpolation).
  • Inline comments (key=val ; note) aren’t parsed specially (keep them out of value lines).

🎉 Fun Ideas

  • Grab a single value (host)
nano-ini config.ini database | jq -r .host
(nano-ini config.ini database | ConvertFrom-Json).host
  • Export a section as environment variables
export $(nano-ini config.ini database | jq -r 'to_entries|.[]|"\(.key)=\(.value)"')
nano-ini config.ini database | jq -r 'to_entries|.[]|"\(.key)=\(.value)"' > .env
  • Validate required keys
nano-ini config.ini database | jq -e 'has("host") and has("port")' >/dev/null && echo OK || echo MISSING
  • Overlay/merge INIs (last wins)
cat base.ini override.ini | nano-ini - | jq .
  • Use root (no section) keys
nano-ini config.ini "" | jq .
  • GitHub Actions: output a field
echo "db_host=$(nano-ini config.ini database | jq -r .host)" >> "$GITHUB_OUTPUT"
  • First N records
nano-csv2json data.csv | head -100 > sample.jsonl

Tip: Output is compact JSON. Combine with jq for querying, filtering, or formatting.


📜 License

MIT © 2025

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nano_ini-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nano_ini-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file nano_ini-0.1.0.tar.gz.

File metadata

  • Download URL: nano_ini-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for nano_ini-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8edf269ed3ad4fce80f75a1451e914e624cdab644f9d07b3d9355d60c7b0bf32
MD5 7be68aefbe299af3e4fa35cfed4080b8
BLAKE2b-256 d578b3e754f0ca0834b0859a77fbc43259c675f2193c0a807fe61acc87410674

See more details on using hashes here.

File details

Details for the file nano_ini-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nano_ini-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for nano_ini-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e93c2b111f245d2f7d07e33f2102b0508153c24b64a2a495c3e1411d63472ac7
MD5 64fa064f63973964984fa21d854ff481
BLAKE2b-256 0d7ae6182450cedd4dc55e7a3aa875f2f7f56117779753b07e3c57a57ac3552a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page