Skip to main content

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.


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


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.2.7.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file python-hosts-0.2.7.tar.gz.

File metadata

  • Download URL: python-hosts-0.2.7.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python-hosts-0.2.7.tar.gz
Algorithm Hash digest
SHA256 9fce5273e6b8cca41af8451ec7eed4df7eb28c5611fab686655a4fae9a4c3759
MD5 093c912220206d9df4ef3d7251410f15
BLAKE2b-256 b14cc56435d4f82f96b230c27c718a7f0875e3453f95843477e0d2b29187aec3

See more details on using hashes here.

Supported by

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