Tinynetrc
Read and write .netrc files in Python
Install / Use
/learn @sloria/TinynetrcREADME
tinynetrc
.. image:: https://badgen.net/pypi/v/tinynetrc :alt: pypi badge :target: https://pypi.org/project/tinynetrc/
.. image:: https://badgen.net/travis/sloria/tinynetrc/master :alt: travis-ci status :target: https://travis-ci.org/sloria/tinynetrc
Read and write .netrc files in Python.
tinynetrc uses the netrc <https://docs.python.org/3/library/netrc.html>_
module from the standard library under the hood and adds a few
improvements:
- Adds write functionality.
- Fixes a std lib
bug <https://bugs.python.org/issue30806>_ with formatting a .netrc file.* - Parses .netrc into dictionary values rather than tuples.
*This bug is fixed in newer versions of Python.
Get it now
::
pip install tinynetrc
tinynetrc supports Python >= 2.7 or >= 3.5.
Usage
.. code-block:: python
from tinynetrc import Netrc
netrc = Netrc() # parse ~/.netrc
# Get credentials
netrc['api.heroku.com']['login']
netrc['api.heroku.com']['password']
# Modify an existing entry
netrc['api.heroku.com']['password'] = 'newpassword'
netrc.save() # writes to ~/.netrc
# Add a new entry
netrc['surge.surge.sh'] = {
'login': 'sloria1@gmail.com',
'password': 'secret'
}
netrc.save()
# Removing an new entry
del netrc['surge.surge.sh']
netrc.save()
You can also use Netrc as a context manager, which will automatically save
~/.netrc.
.. code-block:: python
from tinynetrc import Netrc
with Netrc() as netrc:
netrc['api.heroku.com']['password'] = 'newpassword'
assert netrc.is_dirty is True
# saved!
License
MIT licensed. See the bundled LICENSE <https://github.com/sloria/tinynetrc/blob/master/LICENSE>_ file for more details.
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
107.8kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
347.0kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
