Skip to content

Commit

Permalink
some refactoring of core and help to expose external api
Browse files Browse the repository at this point in the history
more development of Structor with some unit tests
make consistent exception class for Serdering and Structing
  • Loading branch information
SmithSamuelM committed Apr 8, 2024
1 parent 0f81b0f commit 043d1ce
Show file tree
Hide file tree
Showing 8 changed files with 509 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/keri/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#__all__ = ["coring", "eventing", "parsing", "scheming"]

# Matter class and its subclasses
from .coring import (Matter, MtrDex, Number, NumDex, Dater,Texter,
from .coring import (Matter, MtrDex, Number, NumDex, Dater, Texter,
Bexter, Pather, Verfer, Cigar, Signer, Salter,
Cipher, Encrypter, Decrypter, Diger, DigDex,
Prefixer, PreDex, )
Expand Down
10 changes: 8 additions & 2 deletions src/keri/core/counting.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class MapCodex:
Adds support for dunder methods for map syntax dc[name].
Converts exceptions from attribute syntax to raise map syntax when using
map syntax.
Enables Mapping item syntas for dataclasses
"""

def __getitem__(self, name):
Expand Down Expand Up @@ -107,6 +109,9 @@ class CounterCodex_1_0(MapCodex):
CounterCodex is codex hard (stable) part of all counter derivation codes.
Only provide defined codes.
Undefined are left out so that inclusion(exclusion) via 'in' operator works.
As subclass of MapCodex can get codes with item syntax using tag variables.
Example: codex[tag]
"""
ControllerIdxSigs: str = '-A' # Qualified Base64 Indexed Signature.
WitnessIdxSigs: str = '-B' # Qualified Base64 Indexed Signature.
Expand Down Expand Up @@ -136,6 +141,9 @@ class CounterCodex_2_0(MapCodex):
CounterCodex is codex hard (stable) part of all counter derivation codes.
Only provide defined codes.
Undefined are left out so that inclusion(exclusion) via 'in' operator works.
As subclass of MapCodex can get codes with item syntax using tag variables.
Example: codex[tag]
"""
GenericGroup: str = '-A' # Generic Group (Universal with Override).
BigGenericGroup: str = '-0A' # Big Generic Group (Universal with Override).
Expand Down Expand Up @@ -189,8 +197,6 @@ class CounterCodex_2_0(MapCodex):
BigESSRPayloadGroup: str = '-0Z' # Big ESSR Payload Group.
KERIACDCGenusVersion: str = '--AAA' # KERI ACDC Stack CESR Protocol Genus Version (Universal)



def __iter__(self):
return iter(astuple(self)) # enables value not key inclusion test with "in"

Expand Down
7 changes: 4 additions & 3 deletions src/keri/core/serdering.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from .. import kering
from ..kering import (ValidationError, MissingFieldError, ExtraFieldError,
AlternateFieldError,
AlternateFieldError, InvalidValueError,
ShortageError, VersionError, ProtocolError, KindError,
DeserializeError, FieldError, SerializeError)
from ..kering import (Versionage, Version, Vrsn_1_0, Vrsn_2_0,
Expand Down Expand Up @@ -642,7 +642,8 @@ def __init__(self, *, raw=b'', sad=None, strip=False, smellage=None,
f"{self._sad}.") from ex

else:
raise ValueError("Improper initialization need raw or sad or makify.")
raise InvalidValueError("Improper initialization need raw or sad "
f"or makify.")



Expand Down Expand Up @@ -840,7 +841,7 @@ def makify(self, sad, *, proto=None, vrsn=None, kind=None,
if sad and 'v' in sad: # attempt to get from vs in sad
try: # extract version string elements as defaults if provided
sproto, svrsn, skind, _, _ = deversify(sad["v"])
except ValueError as ex:
except VersionError as ex:
pass
else:
silk = sad.get('t') # if 't' not in sad .get returns None which may be valid
Expand Down
Loading

0 comments on commit 043d1ce

Please sign in to comment.