Skip to main content

Simple host:port parser

Project description

https://travis-ci.org/zzzsochi/hostport.svg?branch=master https://coveralls.io/repos/github/zzzsochi/hostport/badge.svg?branch=master

Simple parser strings like as grpchost:50051.

Installation

$ pip install hostport

Usage

>>> 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for hostport, version 1.1
Filename, size File type Python version Upload date Hashes
Filename, size hostport-1.1-py3-none-any.whl (2.1 kB) File type Wheel Python version 3.7 Upload date Hashes View hashes
Filename, size hostport-1.1.tar.gz (1.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page