Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tybruno/hosts_parser
https://github.com/tybruno/hosts_parser
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/tybruno/hosts_parser
- Owner: tybruno
- License: mit
- Created: 2021-08-06T17:44:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-06T21:21:14.000Z (over 3 years ago)
- Last Synced: 2024-10-18T14:29:39.541Z (3 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hosts_parser
Made the ability to parse a string of hosts easier.
#### Key Features:
* **Easy**: Designed with simplicity in mind. Uses modern design principle making the code DRY and Extensible.
* **Great Developer Experience**: Being fully typed makes it great for editor support.
* **There is More!!!**:
* [host_reader](https://github.com/tybruno/hosts_reader): retreive a list of host from a file or string.
* [commands_reader](https://github.com/tybruno/commands_reader): retreive a list of commands from a file or string.
* [parser](https://github.com/tybruno/parsers): Generic Parsers and Abstract classes. This project extends parsers.
## Installation
`pip install "git+https://github.com/tybruno/hosts_parser.git#egg=hosts_parser`
## Usage
### Example 1
```python
from hosts_parser import HostsParserhosts_str = "host1, host2, host3"
parse_hosts = HostsParser()
hosts = parse_hosts(hosts_str)
print(list(hosts)) # ['host1', 'host2', 'host3']
```
### Example 2```python
from hosts_parser import HostsParserhosts_str = """hosts1
host2
host3
"""parse_hosts = HostsParser()
hosts = parse_hosts(hosts_str)
print(tuple(hosts)) # ('host1', 'host2', 'host3')
```