Tools not directly related with CoAP that are needed to provide the API
These are only part of the stable API to the extent they are used by other APIs
– for example, you can use the type constructor of
when creating an
aiocoap.numbers.optionnumbers.OptionNumber, but don’t
expect it to be usable in a stable way for own extensions.
Most functions are available in submodules; some of them may only have components that are exclusively used internally and never part of the public API even in the limited fashion stated above.
- aiocoap.util.asyncio module
- aiocoap.util.asyncio.recvmsg module
- aiocoap.util.asyncio.timeoutdict module
- aiocoap.util.cli module
- aiocoap.util.contenttype module
- aiocoap.util.cryptography_additions module
- aiocoap.util.linkformat module
- aiocoap.util.linkformat_pygments module
- aiocoap.util.prettyprint module
- aiocoap.util.socknumbers module
- aiocoap.util.uri module
ExtensibleEnumMeta(name, bases, dict)¶
Metaclass for ExtensibleIntEnum, see there for detailed explanations
Similar to Python’s enum.IntEnum, this type can be used for named numbers which are not comprehensively known, like CoAP option numbers.
Join a host and optionally port into a hostinfo-style host:port string
>>> hostportjoin('example.com') 'example.com' >>> hostportjoin('example.com', 1234) 'example.com:1234' >>> hostportjoin('127.0.0.1', 1234) '127.0.0.1:1234'
This is lax with respect to whether host is an IPv6 literal in brackets or not, and accepts either form; IP-future literals that do not contain a colon must be already presented in their bracketed form:
>>> hostportjoin('2001:db8::1') '[2001:db8::1]' >>> hostportjoin('2001:db8::1', 1234) '[2001:db8::1]:1234' >>> hostportjoin('[2001:db8::1]', 1234) '[2001:db8::1]:1234'
Like urllib.parse.splitport, but return port as int, and as None if not given. Also, it allows giving IPv6 addresses like a netloc:
>>> hostportsplit('foo') ('foo', None) >>> hostportsplit('foo:5683') ('foo', 5683) >>> hostportsplit('[::1%eth0]:56830') ('::1%eth0', 56830)
Like urllib.parse.quote, but explicitly only escaping non-ascii characters.
This function is deprecated due to it use of the irrelevant “being an ASCII character” property (when instead RFC3986 productions like “unreserved” should be used), and due for removal when aiocoap’s URI processing is overhauled the next time.
Class for sentinel that can only be compared for identity. No efforts are taken to make these singletons; it is up to the users to always refer to the same instance, which is typically defined on module level.