@@ -120,17 +120,16 @@ class Serdery:
120
120
121
121
"""
122
122
123
- def __init__ (self , * , version = None ):
123
+ def __init__ (self , * pa , ** kwa ):
124
124
"""Init instance
125
125
126
126
Parameters:
127
- version (Versionage | None): instance supported protocol version
128
- None means do not enforce a supported version
127
+
129
128
"""
130
- self . version = version # default version
129
+ pass
131
130
132
131
133
- def reap (self , ims , * , version = None ):
132
+ def reap (self , ims ):
134
133
"""Extract and return Serder subclass based on protocol type reaped from
135
134
version string inside serialized raw of Serder.
136
135
@@ -144,14 +143,14 @@ def reap(self, ims, *, version=None):
144
143
version (Versionage | None): instance supported protocol version
145
144
None means do not enforce a supported version
146
145
"""
147
- version = version if version is not None else self .version
146
+ # version = version if version is not None else self.version
148
147
149
- smellage = smell (ims , version = version )
148
+ smellage = smell (ims )
150
149
151
150
if smellage .protocol == Protos .keri :
152
- return SerderKERI (raw = ims , strip = True , version = version , smellage = smellage )
151
+ return SerderKERI (raw = ims , strip = True , smellage = smellage )
153
152
elif smellage .protocol == Protos .acdc :
154
- return SerderACDC (raw = ims , strip = True , version = version , smellage = smellage )
153
+ return SerderACDC (raw = ims , strip = True , smellage = smellage )
155
154
else :
156
155
raise ProtocolError (f"Unsupported protocol type = { smellage .proto } ." )
157
156
@@ -189,8 +188,8 @@ class Serder:
189
188
Digests (dict): map of digestive codes. Should be same set of codes as
190
189
in coring.DigestCodex coring.DigDex so that .digestive property works.
191
190
Use unit tests to ensure codex sets match
192
- Protocol (str): default protocol version type
193
- Proto (str): default CESR protocol genus type
191
+ Protocol (str): class specific message protocol
192
+ Proto (str): default message protocol
194
193
Vrsn (Versionage): default version
195
194
Kind (str): default serialization kind one of Serials
196
195
Fields (dict): nested dict of field labels keyed by protocol, version,
@@ -270,9 +269,8 @@ class Serder:
270
269
}
271
270
272
271
#override in subclass to enforce specific protocol
273
- Protocol = None # required protocol, None means any in Protos is ok
274
-
275
- Proto = Protos .keri # default CESR protocol type for makify on base Serder
272
+ Protocol = None # class based message protocol, None means any in Protos is ok
273
+ Proto = Protos .keri # default message protocol type for makify on base Serder
276
274
Vrsn = Vrsn_1_0 # default protocol version for protocol type
277
275
Kind = Serials .json # default serialization kind
278
276
@@ -441,7 +439,7 @@ class Serder:
441
439
}
442
440
443
441
444
- def __init__ (self , * , raw = b'' , sad = None , strip = False , version = Version ,
442
+ def __init__ (self , * , raw = b'' , sad = None , strip = False ,
445
443
smellage = None , verify = True , makify = False ,
446
444
proto = None , vrsn = None , kind = None , ilk = None , saids = None ):
447
445
"""Deserialize raw if provided. Update properties from deserialized raw.
@@ -460,8 +458,6 @@ def __init__(self, *, raw=b'', sad=None, strip=False, version=Version,
460
458
strip (bool): True means strip (delete) raw from input stream
461
459
bytearray after parsing. False means do not strip.
462
460
Assumes that raw is bytearray when strip is True.
463
- version (Versionage | None): instance supported protocol version
464
- None means do not enforce a supported version
465
461
smellage (Smellage | None): instance of deconstructed and converted
466
462
version string elements. If none or empty ignore otherwise assume
467
463
that raw already had its version string extracted (reaped) into the
@@ -493,9 +489,7 @@ def __init__(self, *, raw=b'', sad=None, strip=False, version=Version,
493
489
494
490
if raw : # deserialize raw using property setter
495
491
# self._inhale works because it only references class attributes
496
- sad , proto , vrsn , kind , size = self ._inhale (raw = raw ,
497
- version = version ,
498
- smellage = smellage )
492
+ sad , proto , vrsn , kind , size = self ._inhale (raw = raw , smellage = smellage )
499
493
self ._raw = bytes (raw [:size ]) # crypto ops require bytes not bytearray
500
494
self ._sad = sad
501
495
self ._proto = proto
@@ -528,14 +522,13 @@ def __init__(self, *, raw=b'', sad=None, strip=False, version=Version,
528
522
529
523
elif sad or makify : # serialize sad into raw or make sad
530
524
if makify : # recompute properties and said(s) and reset sad
531
- # makify resets sad, raw, proto, version , kind, and size
532
- self .makify (sad = sad , version = version ,
533
- proto = proto , vrsn = vrsn , kind = kind , ilk = ilk , saids = saids )
525
+ # makify resets sad, raw, proto, vrsn , kind, ilk , and size
526
+ self .makify (sad = sad , proto = proto , vrsn = vrsn , kind = kind ,
527
+ ilk = ilk , saids = saids )
534
528
535
529
else :
536
530
# self._exhale works because it only access class attributes
537
- raw , sad , proto , vrsn , kind , size = self ._exhale (sad = sad ,
538
- version = version )
531
+ raw , sad , proto , vrsn , kind , size = self ._exhale (sad = sad )
539
532
self ._raw = raw
540
533
self ._sad = sad
541
534
self ._proto = proto
@@ -680,8 +673,7 @@ def _verify(self):
680
673
# verified successfully since no exception
681
674
682
675
683
- def makify (self , sad , * , version = None ,
684
- proto = None , vrsn = None , kind = None , ilk = None , saids = None ):
676
+ def makify (self , sad , * , proto = None , vrsn = None , kind = None , ilk = None , saids = None ):
685
677
"""Makify given sad dict makes the versions string and computes the said
686
678
field values and sets associated properties:
687
679
raw, sad, proto, version, kind, size
@@ -699,8 +691,6 @@ def makify(self, sad, *, version=None,
699
691
Parameters:
700
692
sad (dict): serializable saidified field map of message.
701
693
Ignored if raw provided
702
- version (Versionage): instance supported protocol version
703
- None means do not enforce version
704
694
proto (str | None): desired protocol type str value of Protos
705
695
If None then its extracted from sad or uses default .Proto
706
696
vrsn (Versionage | None): instance desired protocol version
@@ -721,7 +711,7 @@ def makify(self, sad, *, version=None,
721
711
sproto = svrsn = skind = silk = None
722
712
if sad and 'v' in sad : # attempt to get from vs in sad
723
713
try : # extract version string elements as defaults if provided
724
- sproto , svrsn , skind , _ = deversify (sad ["v" ], version = version )
714
+ sproto , svrsn , skind , _ = deversify (sad ["v" ])
725
715
except ValueError as ex :
726
716
pass
727
717
else :
@@ -750,11 +740,11 @@ def makify(self, sad, *, version=None,
750
740
raise SerializeError (f"Expected protocol = { self .Protocol } , got "
751
741
f"{ proto } instead." )
752
742
753
- if version is not None : # compatible version with vrsn
754
- if (vrsn .major > version .major or
755
- (vrsn .major == version .major and vrsn .minor > version .minor )):
756
- raise SerializeError (f"Incompatible { version = } , with "
757
- f"{ vrsn = } ." )
743
+ # if version is not None: # compatible version with vrsn
744
+ # if (vrsn.major > version.major or
745
+ # (vrsn.major == version.major and vrsn.minor > version.minor)):
746
+ # raise SerializeError(f"Incompatible {version=}, with "
747
+ # f"{vrsn=}.")
758
748
759
749
760
750
if kind not in Serials :
@@ -895,7 +885,7 @@ def makify(self, sad, *, version=None,
895
885
896
886
897
887
@classmethod
898
- def _inhale (clas , raw , version = Version , smellage = None ):
888
+ def _inhale (clas , raw , * , smellage = None ):
899
889
"""Deserializes raw.
900
890
Parses serilized event ser of serialization kind and assigns to
901
891
instance attributes and returns tuple of associated elements.
@@ -914,7 +904,6 @@ def _inhale(clas, raw, version=Version, smellage=None):
914
904
Parameters:
915
905
clas (Serder): class reference
916
906
raw (bytes): serialized sad message
917
- version (Versionage): instance supported protocol version
918
907
smellage (Smellage | None): instance of deconstructed version string
919
908
elements. If none or empty ignore otherwise assume that raw
920
909
already had its version string extracted (reaped) into the
@@ -928,7 +917,7 @@ def _inhale(clas, raw, version=Version, smellage=None):
928
917
if smellage : # passed in so don't need to smell raw again
929
918
proto , vrsn , kind , size = smellage # tuple unpack
930
919
else : # not passed in so smell raw
931
- proto , vrsn , kind , size = smell (raw , version = version )
920
+ proto , vrsn , kind , size = smell (raw )
932
921
933
922
sad = clas .loads (raw = raw , size = size , kind = kind )
934
923
@@ -996,9 +985,8 @@ def _loads(clas, raw, size=None):
996
985
997
986
998
987
@classmethod
999
- def _exhale (clas , sad , version = None ):
1000
- """Serializes sad given kind and version and sets the serialized size
1001
- in the version string.
988
+ def _exhale (clas , sad ):
989
+ """Serializes sad and sets the serialized size in its version string.
1002
990
1003
991
As classmethod enables bootstrap of valid sad dict that has correct size
1004
992
in version string. This obviates sizeify. This can be called on self as
@@ -1014,16 +1002,14 @@ def _exhale(clas, sad, version=None):
1014
1002
Parameters:
1015
1003
clas (Serder): class reference
1016
1004
sad (dict): serializable attribute dict of saidified data
1017
- version (Versionage | None): supported protocol version for message
1018
- None means do not enforce a supported version
1019
1005
1020
1006
1021
1007
"""
1022
1008
if "v" not in sad :
1023
1009
raise SerializeError (f"Missing version string field in { sad } ." )
1024
1010
1025
1011
# extract elements so can replace size element but keep others
1026
- proto , vrsn , kind , size = deversify (sad ["v" ], version = version )
1012
+ proto , vrsn , kind , size = deversify (sad ["v" ])
1027
1013
1028
1014
raw = clas .dumps (sad , kind )
1029
1015
size = len (raw )
0 commit comments