tinynetrc is a Python library designed to read and write .netrc files. It extends the standard library's `netrc` module by adding crucial write functionality, resolving a known bug with .netrc file formatting, and parsing entries into more accessible dictionary values instead of tuples. The library is currently at version 1.3.1 and is in a maintenance status, with infrequent but stable updates.
pip install tinynetrcVerified import paths — ran on the pinned version, not inferred.
The quickstart demonstrates reading, modifying, and saving a .netrc file using `tinynetrc`. It highlights the use of the context manager for automatic saving and direct dictionary-like access to machine entries. It also includes an example of explicit loading and saving.
Ensure the `.netrc` file has appropriate permissions, e.g., `chmod 600 ~/.netrc`.
When migrating from direct `netrc` usage or expecting specific multi-entry behavior, review `tinynetrc`'s dictionary-based parsing. `tinynetrc` provides the intended fixes for standard library issues.
Upgrade to Python 3.5 or newer for full support and security patches.
Change the permissions of the `.netrc` file to `600` (owner read/write only): `chmod 600 ~/.netrc`.
Verify the machine name is correct and present in your `.netrc` file, or implement logic to handle missing entries (e.g., `if 'machine.example.com' in netrc:`).
Ensure the `.netrc` file exists in the specified path (typically `~/.netrc`) before attempting to read it, or use `tinynetrc`'s write capabilities to create it if it's missing.
No dependency data recorded yet.