Metadata-Version: 2.2
Name: tinynetrc
Version: 1.3.0
Summary: Read and write .netrc files.
Home-page: https://github.com/sloria/tinynetrc
Author: Steven Loria
Author-email: sloria1@gmail.com
License: MIT
Keywords: netrc posix
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Provides-Extra: lint
Requires-Dist: flake8==3.6.0; extra == "lint"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: flake8==3.6.0; extra == "dev"
Requires-Dist: tox; extra == "dev"
Requires-Dist: konch; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: provides-extra
Dynamic: summary

*********
tinynetrc
*********

.. image:: https://badge.fury.io/py/tinynetrc.svg
    :target: http://badge.fury.io/py/tinynetrc
    :alt: Latest version

.. image:: https://travis-ci.org/sloria/tinynetrc.svg?branch=master
    :target: https://travis-ci.org/sloria/tinynetrc
    :alt: Travis-CI

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.
