Read and write .netrc files in Python.
tinynetrc uses the netrc module from the standard library under the hood and adds a few improvements:
Adds write functionality.
Fixes a std lib bug 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
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.
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 file for more details.
Release files for tinynetrc 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tinynetrc-1.3.1.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tinynetrc-1.3.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 9.4 kB
Release files / tinynetrc-1.3.1.tar.gz
| Download URL | tinynetrc-1.3.1.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b9a256d2e630643b8f0985f5e826ccf0bf3716e07e596a4f67feab363d254df
|
|
BLAKE2b-256 checksum How to use checksums |
878f6df2414a8f38b08836726986437f7612983f25c6dc3c55c66f4850a3d795
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.0
|
Release files / tinynetrc-1.3.1-py2.py3-none-any.whl
| Download URL | tinynetrc-1.3.1-py2.py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
46c7820e5f49c9434d2c4cd74de8a06edbbd45e63a8a2980a90b8a43db8facf7
|
|
BLAKE2b-256 checksum How to use checksums |
eb0b633691d7cea5129afa622869485d1985b038df1d3597a35848731d106762
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.0
|