Skip to main content

Aio core utils

Project description

aio.core

Core definitions and utilities for the aio asyncio framework

Installation

Install with:

pip install aio.core

aio.core.exceptions usage

MissingConfiguration

>>> from configparser import ConfigParser
>>> from aio.core.exceptions import MissingConfiguration
>>> def get_configuration(conf, section, option):
...     try:
...         conf[section][option]
...     except KeyError:
...         raise MissingConfiguration(
...             "Configuration option is missing: %s:%s" % (
...                 section, option))
>>> try:
...     get_configuration(ConfigParser(), "foo", "bar")
... except MissingConfiguration as e:
...     print(e)
Configuration option is missing: foo:bar

BadConfiguration

>>> from aio.core.exceptions import BadConfiguration
>>> def get_configuration(conf, section, option, option_type):
...     option_value = conf[section][option]
...     try:
...         option_type(option_value)
...     except ValueError:
...         raise BadConfiguration(
...             'Configuration is bad: %s:%s expected type %s, but got "%s"' % (
...                 section, option, option_type.__name__, option_value))
>>> config = ConfigParser()
>>> config.read_dict({"foo": {"bar": "baz"}})
>>> try:
...     get_configuration(config, "foo", "bar", int)
... except BadConfiguration as e:
...     print(e)
Configuration is bad: foo:bar expected type int, but got "baz"

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

aio.core-0.0.5.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file aio.core-0.0.5.tar.gz.

File metadata

  • Download URL: aio.core-0.0.5.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aio.core-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3d07104a4ab03c30f3afa69ce47e4f6a48f4fe536fa227336d6dcff60af584a8
MD5 dcfe24b4a98baa46fbcf3f6250cfc8a1
BLAKE2b-256 77e3cea312278cfb7b309bd2e1565f3cad203415cee7f8cefe3d0ace0f52f8cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page