KERI Help API

keri.help.helping

keri.help.helping module

keri.help.helping.datify(cls, d)[source]

Returns instance of dataclass cls converted from dict d. If the dataclass cls or any nested dataclasses contains a _der method, the use it instead of default fieldtypes conversion.

Parameters: cls is dataclass class d is dict

keri.help.helping.dictify(val: dataclass)[source]

Returns a serializable dict represention of a dataclass. If the dataclass contains a _ser method, use it instead of asdict

Parameters:

dict. (val the dataclass instance to turn into a)

keri.help.helping.extractElementValues(element, values)[source]

Recusive depth first search that recursively extracts value(s) from element and appends to values list

Assumes that extracted values are str

Parameters:
  • from (element is some element to extract values)

  • nonStringIterables (values is list of values from elements that are not)

IF element is mapping or sequence (nonStringIterable) then

recusively extractValues from the items of that element

Else

append element to values list

return

keri.help.helping.extractValues(ked, labels)[source]

Returns list of depth first recursively extracted values from elements of key event dict ked whose flabels are in lables list

Parameters:
  • dict (ked is key event)

  • values (labels is list of element labels in ked from which to extract)

keri.help.helping.fromIso8601(dts)[source]

Returns datetime object from RFC-3339 profile of ISO 8601 format str or bytes. Converts dts from ISO 8601 format to datetime object

YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]] .strftime(‘%Y-%m-%dT%H:%M:%S.%f%z’) ‘2020-08-22T17:50:09.988921+00:00’ Assumes TZ aware For nanosecond use instead attotime or datatime64 in pandas or numpy

keri.help.helping.isign(i)[source]

Integer sign function :returns: 1 if i > 0, -1 if i < 0, 0 otherwise :rtype: (int)

keri.help.helping.key64uToKey(key64u)[source]

Returns bytes Convert and return unicode base64 url-file safe key64u to bytes key

keri.help.helping.keyToKey64u(key)[source]

Returns 64u Convert and return bytes key to unicode base64 url-file safe version

keri.help.helping.klasify(sers: Iterable, klases: Iterable, args: Iterable | None = None)[source]

Convert each qb64 serialization ser in sers to instance of corresponding klas in klases modified by corresponding arg in args. Useful for converting iterable of CESR serializations to associated iterable of CESR subclass instances. When klas in klases is None then return corresponding ser without conversion

Parameters:
  • sers (Iterable) – of serialized CESR subclass, str .qb64 or bytes .qb64b

  • klases (Iterable) – of class reference of CESR subclass

keri.help.helping.nonStringIterable(obj)[source]
Returns:

True if obj is non-string iterable, False otherwise

Return type:

(bool)

Future proof way that is compatible with both Python3 and Python2 to check for non string iterables.

Faster way that is less future proof return (hasattr(x, ‘__iter__’) and not isinstance(x, (str, bytes)))

keri.help.helping.nonStringSequence(obj)[source]

Returns: True if obj is non-string sequence, False otherwise

Future proof way that is compatible with both Python3 and Python2 to check for non string sequences.

keri.help.helping.nowIso8601()[source]

Returns time now in RFC-3339 profile of ISO 8601 format. use now(timezone.utc)

YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]] .strftime(‘%Y-%m-%dT%H:%M:%S.%f%z’) ‘2020-08-22T17:50:09.988921+00:00’ Assumes TZ aware For nanosecond use instead attotime or datatime64 in pandas or numpy

keri.help.helping.nowUTC()[source]

Returns timezone aware datetime of current UTC time Convenience function that allows monkeypatching in tests to mock time

keri.help.helping.sceil(r)[source]

Symmetric ceiling function :returns: value that is symmetric ceiling of r away from zero :rtype: sc (int)

Because int() provides a symmetric floor towards zero, just inc int(r) by:

1 when r - int(r) > 0 (r positive)

-1 when r - int(r) < 0 (r negative)

0 when r - int(r) == 0 (r integral already)

abs(r) > abs(int(r) or 0 when abs(r)

keri.help.helping.toIso8601(dt=None)[source]

Returns str datetime dt in RFC-3339 profile of ISO 8601 format. Converts datetime object dt to ISO 8601 formt If dt is missing use now(timezone.utc)

YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]] .strftime(‘%Y-%m-%dT%H:%M:%S.%f%z’) ‘2020-08-22T17:50:09.988921+00:00’ Assumes TZ aware For nanosecond use instead attotime or datatime64 in pandas or numpy

keri.help.helping.verify64uEd25519(signature, message, verkey)[source]

Returns True if signature is valid for message with respect to verification key verkey

signature and verkey are encoded as unicode base64 url-file strings and message is unicode string as would be the case for a json object

keri.help.helping.verifyEd25519(sig, msg, vk)[source]

Returns True if signature sig of message msg is verified with verification key vk Otherwise False All of sig, msg, vk are bytes