Skip to main content

Read and write .netrc files.

Project description

Latest version Travis-CI

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.

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

tinynetrc-1.3.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

tinynetrc-1.3.0-py2.py3-none-any.whl (3.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tinynetrc-1.3.0.tar.gz.

File metadata

  • Download URL: tinynetrc-1.3.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for tinynetrc-1.3.0.tar.gz
Algorithm Hash digest
SHA256 a659a2ef6dfaae994eb26d803eaff6a9a6599a3dcea53f6bc668a1a3ad4812f2
MD5 b27ef35742e8f2bbc3dc990badfa7d9f
BLAKE2b-256 d662ca5d82a8816d58f2989d2e97a8fd1f2304386d599f59a45af2f3bf1a1b3d

See more details on using hashes here.

File details

Details for the file tinynetrc-1.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: tinynetrc-1.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for tinynetrc-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8dd2d77a24e12ea6d8d03b573f06aaa6ce748115d683f903307f1a4996951584
MD5 54162f89efc21c580c440197d5504774
BLAKE2b-256 b25f0793b8530eee9b07bba5c609da16dd061421c238f8aabcf1a97a5d37656f

See more details on using hashes here.

Supported by

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