https://github.com/jonhadfield/python-hosts
a hosts file manager library written in python
https://github.com/jonhadfield/python-hosts
hosts hostsfile python
Last synced: 6 months ago
JSON representation
a hosts file manager library written in python
- Host: GitHub
- URL: https://github.com/jonhadfield/python-hosts
- Owner: jonhadfield
- License: mit
- Created: 2015-05-15T18:28:17.000Z (over 10 years ago)
- Default Branch: devel
- Last Pushed: 2024-07-27T20:22:03.000Z (about 1 year ago)
- Last Synced: 2025-03-28T15:09:07.886Z (6 months ago)
- Topics: hosts, hostsfile, python
- Language: Python
- Homepage:
- Size: 529 KB
- Stars: 130
- Watchers: 7
- Forks: 32
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
python-hosts
========
[](https://codecov.io/gh/jonhadfield/python-hosts) [](http://python-hosts.readthedocs.org/en/latest/)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:
.Changelog available [here](CHANGELOG.md).
Installation
------------
pip install python-hostsExample usage
------------
Adding an entry to a hosts filefrom 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
hosts = Hosts(path='hosts_test')
hosts.import_url(url='https://gist.githubusercontent.com/jonhadfield/5b6cdf853ef629f9b187345d89157280/raw/ddfa4a069fb12bf3c1f285249d44922aeb75db3f/hosts')
hosts.write()CLI
---
A command line client using python-hosts can be found here: https://github.com/jonhadfield/hostmanRequirements
------------Tested on python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy and pypy3
License
-------MIT