unitelabs.sdk.utils

Packages

Attributes

  • Name
    __all__
    Type
    Value

    = [ "call_async", "cancellable", "select_keys", "to_class_name", "to_method_name", "to_property_name", "Singleton" ]

    Description

Functions

  • select_keys(dct : typing.Mapping[K, typing.Any], keys : typing.Iterable[K]) -> dict[K, typing.Any]

    Parameters

    • Name
      dct
      Type
      typing.Mapping[K, typing.Any]
      Default
      Description

    • Name
      keys
      Type
      typing.Iterable[K]
      Default
      Description

    Response

    Type
    dict[K, typing.Any]
    Description

  • to_class_name(name : str) -> str

    Parameters

    • Name
      name
      Type
      str
      Default
      Description

    Response

    Type
    str
    Description

  • to_property_name(name : str) -> str

    Parameters

    • Name
      name
      Type
      str
      Default
      Description

    Response

    Type
    str
    Description

  • call_async(
      function : typing.Callable[P, typing.Coroutine[typing.Any, typing.Any, R]],
      *args : unitelabs.sdk.utils.asyncio.P.args,
      **kwargs : unitelabs.sdk.utils.asyncio.P.kwargs
    ) -> R

    Calls an async function synchronously and blocks until it finishes.

    Parameters

    • Name
      function
      Type
      typing.Callable[P, typing.Coroutine[typing.Any, typing.Any, R]]
      Default
      Description

    • Name
      *args
      Type
      unitelabs.sdk.utils.asyncio.P.args
      Default
      = ()
      Description

    • Name
      **kwargs
      Type
      unitelabs.sdk.utils.asyncio.P.kwargs
      Default
      = {}
      Description

    Response

    Type
    R
    Description

  • to_method_name(access : typing.Literal['PROPERTY', 'SENSOR', 'CONTROL', 'DIAGNOSTIC'], name : str) -> str

    Parameters

    • Name
      access
      Type
      typing.Literal['PROPERTY', 'SENSOR', 'CONTROL', 'DIAGNOSTIC']
      Default
      Description

    • Name
      name
      Type
      str
      Default
      Description

    Response

    Type
    str
    Description

  • cancellable(aiter : collections.abc.AsyncIterable[Iter], cancel : asyncio.Event) -> collections.abc.AsyncIterable[Iter]

    Wraps async iterators with a cancellable event.

    Parameters

    • Name
      aiter
      Type
      collections.abc.AsyncIterable[Iter]
      Default
      Description

    • Name
      cancel
      Type
      asyncio.Event
      Default
      Description

    Response

    Type
    collections.abc.AsyncIterable[Iter]
    Description

Classes

  • Singleton

    Bases
    type

    Methods

    • __call__(cls, *args : typing.Any, **kwds : typing.Any) -> typing.Any

      Parameters

      • Name
        cls
        Type
        Default
        Description

      • Name
        *args
        Type
        typing.Any
        Default
        = ()
        Description

      • Name
        **kwds
        Type
        typing.Any
        Default
        = {}
        Description

      Response

      Type
      typing.Any
      Description

Copyright © 2024