@@ -145,10 +145,10 @@ def mutate(self, p_delete=0.05, p_replace=0.1):
145
145
self .store [child_key ].mutate ()
146
146
147
147
def update (self , value ):
148
- if value is None :
149
- self .store = None
150
148
if isinstance (value , enum .Enum ):
151
149
value = value .value
150
+ if value is None :
151
+ self .store = None
152
152
if isinstance (value , dict ):
153
153
self .store = {}
154
154
for k , v in value .items ():
@@ -270,10 +270,10 @@ def mutate(self, p_delete=0.05, p_replace=0.1):
270
270
self .store [index ].mutate ()
271
271
272
272
def update (self , value ):
273
- if value is None :
274
- self .store = None
275
273
if isinstance (value , enum .Enum ):
276
274
value = value .value
275
+ if value is None :
276
+ self .store = None
277
277
elif isinstance (value , list ):
278
278
self .store = []
279
279
for i in value :
@@ -428,6 +428,8 @@ def get_value_by_path(self, path: list):
428
428
429
429
def create_path (self , path : list ):
430
430
"""Ensures the path exists"""
431
+ if len (path ) == 0 :
432
+ return
431
433
432
434
# XXX: Complicated, no use case yet, let's implement later
433
435
raise NotImplementedError
@@ -438,6 +440,9 @@ def set_value_by_path(self, value, path):
438
440
else :
439
441
self .store .set_value_by_path (value , path )
440
442
443
+ def value (self ):
444
+ return self .store
445
+
441
446
442
447
class ValueWithBasicSchema (ValueWithSchema ):
443
448
"""Value with schema attached for Number/Integer, Bool, String"""
@@ -475,11 +480,11 @@ def mutate(self, p_delete=0.05, p_replace=0.1):
475
480
self .update (self .schema .gen ())
476
481
477
482
def update (self , value ):
483
+ if isinstance (value , enum .Enum ):
484
+ value = value .value
478
485
if value is None :
479
486
self .store = None
480
487
else :
481
- if isinstance (value , enum .Enum ):
482
- value = value .value
483
488
self .store = value
484
489
485
490
def get_value_by_path (self , path : list ):
0 commit comments