@@ -3,10 +3,20 @@ python-hosts
33[ ![ codecov] ( https://codecov.io/gh/jonhadfield/python-hosts/branch/devel/graph/badge.svg )] ( https://codecov.io/gh/jonhadfield/python-hosts ) [ ![ Docs] ( https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat )] ( http://python-hosts.readthedocs.org/en/latest/ )
44
55
6- This is a python library for managing a hosts file.
7- It enables you to add and remove entries, or import them from a file or URL.
8- Utility functions have been streamlined for easier maintenance.
9- It remains compatible with Python 2.7 as well as modern Python 3 releases.
6+ ` python-hosts ` is a small Python library for reading and writing hosts files.
7+ It provides a simple API for adding or removing entries as well as importing
8+ records from another file or a remote URL. The package has no heavy
9+ dependencies and works on Linux, macOS and Windows.
10+
11+ It remains compatible with Python 2.7 in addition to modern Python 3 releases.
12+
13+ Features
14+ --------
15+ * Add, remove or merge host entries programmatically.
16+ * Import entries from a plain text file or from a URL.
17+ * Works across platforms by automatically selecting the correct hosts file
18+ location.
19+ * Python 2.7 and Python 3.5+ support.
1020
1121Documentation
1222-------------
@@ -20,7 +30,7 @@ Installation
2030pip install python-hosts
2131
2232Example usage
23- ------------
33+ -------------
2434Adding an entry to a hosts file
2535
2636 from python_hosts import Hosts, HostsEntry
@@ -36,6 +46,13 @@ Importing a list of host entries by URL
3646 hosts.import_url(url='https://gist.githubusercontent.com/jonhadfield/5b6cdf853ef629f9b187345d89157280/raw/ddfa4a069fb12bf3c1f285249d44922aeb75db3f/hosts')
3747 hosts.write()
3848
49+ Importing entries from another file
50+
51+ from python_hosts import Hosts
52+ hosts = Hosts(path='hosts_test')
53+ hosts.import_file(import_file_path='other_hosts')
54+ hosts.write()
55+
3956CLI
4057---
4158A command line client using python-hosts can be found here: https://github.com/jonhadfield/hostman
@@ -46,6 +63,14 @@ Requirements
4663
4764Tested on Python 2.7 and Python 3.5+, including PyPy variants
4865
66+ Running tests
67+ -------------
68+ Install the development requirements and run::
69+
70+ pip install -r test-requirements.txt
71+ pytest
72+
73+
4974
5075License
5176-------
0 commit comments