Skip to main content

Simple host:port parser

Project description

Simple parser strings like as grpchost:50051.


$ pip install hostport


>>> import hostport
>>> hostport.parse('host:30')
HostPort(host='host', port=30)
>>> hostport.parse('host:30').host
>>> hostport.parse('host:30').port
>>> 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.

Source Distribution

hostport-1.1.tar.gz (1.8 kB view hashes)

Uploaded source

Built Distribution

hostport-1.1-py3-none-any.whl (2.1 kB view hashes)

Uploaded 3 7

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page