A hosts file manager library written in python
Project description
python-hosts
========
[![Build Status](https://api.travis-ci.org/jonhadfield/python-hosts.svg?branch=devel)](https://travis-ci.org/jonhadfield/python-hosts)
This is a python library for managing a hosts file.
It enables you to add and remove entries, or import them from a file or URL.
Documentation
-------------
The docs are hosted on RTD (Read The Docs) here:
<http://python-hosts.readthedocs.org/en/latest/index.html>.
Installation
------------
pip install python-hosts
Example usage
------------
Adding an entry to a hosts file
from python_hosts import Hosts, HostsEntry
hosts = Hosts(path='hosts_test')
new_entry = HostsEntry(entry_type='ipv4', address='1.2.3.4', names=['www.example.com', 'example'])
hosts.add([new_entry])
hosts.write()
Importing a list of host entries by URL
from python_hosts import Hosts, HostsEntry
hosts = Hosts(path='hosts_test')
hosts.import_url(url='https://dl.dropboxusercontent.com/u/167103/hosts')
hosts.write()
Requirements
------------
Tested on python 2.6, 2.7 and 3.4
License
-------
MIT
========
[![Build Status](https://api.travis-ci.org/jonhadfield/python-hosts.svg?branch=devel)](https://travis-ci.org/jonhadfield/python-hosts)
This is a python library for managing a hosts file.
It enables you to add and remove entries, or import them from a file or URL.
Documentation
-------------
The docs are hosted on RTD (Read The Docs) here:
<http://python-hosts.readthedocs.org/en/latest/index.html>.
Installation
------------
pip install python-hosts
Example usage
------------
Adding an entry to a hosts file
from python_hosts import Hosts, HostsEntry
hosts = Hosts(path='hosts_test')
new_entry = HostsEntry(entry_type='ipv4', address='1.2.3.4', names=['www.example.com', 'example'])
hosts.add([new_entry])
hosts.write()
Importing a list of host entries by URL
from python_hosts import Hosts, HostsEntry
hosts = Hosts(path='hosts_test')
hosts.import_url(url='https://dl.dropboxusercontent.com/u/167103/hosts')
hosts.write()
Requirements
------------
Tested on python 2.6, 2.7 and 3.4
License
-------
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-hosts-0.3.0.tar.gz
(17.7 kB
view hashes)
Built Distribution
Close
Hashes for python_hosts-0.3.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92045223e4691254936d26bea72838771361053c4d4e3454cf95d7a62e51375d |
|
MD5 | d2007d90044b8bba0460523d852b6dd1 |
|
BLAKE2b-256 | bb185d0970fc89a25959c1e548e89debb3146d4d1ac9bcf5feec79491d70d7f7 |