Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zzzsochi/hostport
Simple parser strings like as "grpchost:50051".
https://github.com/zzzsochi/hostport
hostport network python
Last synced: about 2 months ago
JSON representation
Simple parser strings like as "grpchost:50051".
- Host: GitHub
- URL: https://github.com/zzzsochi/hostport
- Owner: zzzsochi
- Created: 2018-10-16T17:13:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-04T07:54:08.000Z (about 6 years ago)
- Last Synced: 2024-04-25T10:03:20.996Z (9 months ago)
- Topics: hostport, network, python
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
========
hostport
========.. image:: https://travis-ci.org/zzzsochi/hostport.svg?branch=master
:target: https://travis-ci.org/zzzsochi/hostport.. image:: https://coveralls.io/repos/github/zzzsochi/hostport/badge.svg?branch=master
:target: https://coveralls.io/github/zzzsochi/hostport?branch=masterSimple parser strings like as ``grpchost:50051``.
Installation
============.. code:: bash
$ pip install hostport
Usage
=====.. code:: python
>>> import hostport
>>> hostport.parse('host:30')
HostPort(host='host', port=30)
>>> hostport.parse('host:30').host
'host'
>>> hostport.parse('host:30').port
30
>>> hostport.parse('[fe80::95f3]:50051')
HostPort(host='[fe80::95f3]', port=50051)
>>> hostport.parse('[fe80::95f3]')
HostPort(host='[fe80::95f3]', port=None)
>>> hostport.parse('host', default_port=30)
HostPort(host='host', port=30)
>>> hostport.parse('30', default_host='host')
HostPort(host='host', port=30)
>>> hostport.parse('host.production:50051', default_host='host', default_port=30)
HostPort(host='host.production', port=50051)
>>> hostport.parse('host.production')
HostPort(host='host.production', port=None)
>>> hostport.parse('50051')
HostPort(host=None, port=50051)It's all.