@@ -168,9 +168,9 @@ def unpack_to_nibbles(bindata):
168
168
169
169
170
170
def starts_with (full , part ):
171
- ''' test whether the items in the part is
171
+ """ test whether the items in the part is
172
172
the leading items of the full
173
- '''
173
+ """
174
174
if len (full ) < len (part ):
175
175
return False
176
176
return full [:len (part )] == part
@@ -200,11 +200,11 @@ def transient_trie_exception(*args):
200
200
class Trie (object ):
201
201
202
202
def __init__ (self , db , root_hash = BLANK_ROOT , transient = False ):
203
- ''' it also present a dictionary like interface
203
+ """ it also present a dictionary like interface
204
204
205
205
:param db key value database
206
206
:root: blank or trie node in form of [key, value] or [v0,v1..v15,v]
207
- '''
207
+ """
208
208
self .db = db # Pass in a database object directly
209
209
self .transient = transient
210
210
if self .transient :
@@ -215,11 +215,11 @@ def __init__(self, db, root_hash=BLANK_ROOT, transient=False):
215
215
self .journal = []
216
216
217
217
# def __init__(self, dbfile, root_hash=BLANK_ROOT):
218
- # ''' it also present a dictionary like interface
218
+ # """ it also present a dictionary like interface
219
219
220
220
# :param dbfile: key value database
221
221
# :root: blank or trie node in form of [key, value] or [v0,v1..v15,v]
222
- # '''
222
+ # """
223
223
# if isinstance(dbfile, str):
224
224
# dbfile = os.path.abspath(dbfile)
225
225
# self.db = DB(dbfile)
@@ -251,8 +251,8 @@ def spv_storing(self, node):
251
251
252
252
@property
253
253
def root_hash (self ):
254
- ''' always empty or a 32 bytes string
255
- '''
254
+ """ always empty or a 32 bytes string
255
+ """
256
256
return self .get_root_hash ()
257
257
258
258
def get_root_hash (self ):
@@ -311,8 +311,8 @@ def all_nodes(self, node=None):
311
311
# return o
312
312
313
313
def clear (self ):
314
- ''' clear all tree data
315
- '''
314
+ """ clear all tree data
315
+ """
316
316
self ._delete_child_storage (self .root_node )
317
317
self ._delete_node_storage (self .root_node )
318
318
self .root_node = BLANK_NODE
@@ -349,11 +349,11 @@ def _decode_to_node(self, encoded):
349
349
return o
350
350
351
351
def _get_node_type (self , node ):
352
- ''' get node type and content
352
+ """ get node type and content
353
353
354
354
:param node: node in form of list, or BLANK_NODE
355
355
:return: node type
356
- '''
356
+ """
357
357
if node == BLANK_NODE :
358
358
return NODE_TYPE_BLANK
359
359
@@ -603,9 +603,9 @@ def prev(self, key):
603
603
return nibbles_to_bin (o ) if o else None
604
604
605
605
def _delete_node_storage (self , node , is_root = False ):
606
- ''' delete storage
606
+ """ delete storage
607
607
:param node: node in form of list, or BLANK_NODE
608
- '''
608
+ """
609
609
if node == BLANK_NODE :
610
610
return
611
611
# assert isinstance(node, list)
@@ -645,8 +645,8 @@ def _delete(self, node, key):
645
645
646
646
def _normalize_branch_node (self , node ):
647
647
# sys.stderr.write('nbn\n')
648
- ''' node should have only one item changed
649
- '''
648
+ """ node should have only one item changed
649
+ """
650
650
not_blank_items_count = sum (1 for x in range (17 ) if node [x ])
651
651
assert not_blank_items_count >= 1
652
652
@@ -772,9 +772,9 @@ def _delete_kv_node(self, node, key):
772
772
assert False
773
773
774
774
def delete (self , key ):
775
- '''
775
+ """
776
776
:param key: a string with length of [0, 32]
777
- '''
777
+ """
778
778
if not is_string (key ):
779
779
raise Exception ("Key must be string" )
780
780
@@ -808,10 +808,10 @@ def clear_all(self, node=None):
808
808
self .clear_all (self ._decode_to_node (node [i ]))
809
809
810
810
def _get_size (self , node ):
811
- ''' Get counts of (key, value) stored in this and the descendant nodes
811
+ """ Get counts of (key, value) stored in this and the descendant nodes
812
812
813
813
:param node: node in form of list, or BLANK_NODE
814
- '''
814
+ """
815
815
if node == BLANK_NODE :
816
816
return 0
817
817
@@ -830,15 +830,15 @@ def _get_size(self, node):
830
830
return sum (sizes )
831
831
832
832
def _to_dict (self , node ):
833
- ''' convert (key, value) stored in this and the descendant nodes
833
+ """ convert (key, value) stored in this and the descendant nodes
834
834
to dict items.
835
835
836
836
:param node: node in form of list, or BLANK_NODE
837
837
838
838
.. note::
839
839
840
840
Here key is in full form, rather than key of the individual node
841
- '''
841
+ """
842
842
if node == BLANK_NODE :
843
843
return {}
844
844
@@ -894,12 +894,12 @@ def iter_branch(self):
894
894
yield key , value
895
895
896
896
def _iter_branch (self , node ):
897
- ''' yield (key, value) stored in this and the descendant nodes
897
+ """ yield (key, value) stored in this and the descendant nodes
898
898
:param node: node in form of list, or BLANK_NODE
899
899
900
900
.. note::
901
901
Here key is in full form, rather than key of the individual node
902
- '''
902
+ """
903
903
if node == BLANK_NODE :
904
904
raise StopIteration
905
905
@@ -949,10 +949,10 @@ def __contains__(self, key):
949
949
return self .get (key ) != BLANK_NODE
950
950
951
951
def update (self , key , value ):
952
- '''
952
+ """
953
953
:param key: a string
954
954
:value: a string
955
- '''
955
+ """
956
956
if not is_string (key ):
957
957
raise Exception ("Key must be string" )
958
958
0 commit comments