File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,13 @@ let exists c_ptr path =
179179 let path = split_on_whitespace path in
180180 if (Vytree. exists ct path) then 1 else 0
181181
182+ let value_exists c_ptr path value =
183+ let ct = Root. get c_ptr in
184+ let path = split_on_whitespace path in
185+ try
186+ if (CT. value_exists ct path value) then 1 else 0
187+ with VT. Empty_path -> 0
188+
182189let list_nodes c_ptr path =
183190 let ct = Root. get c_ptr in
184191 let path = split_on_whitespace path in
@@ -325,6 +332,7 @@ struct
325332 let () = I. internal " is_leaf" ((ptr void) @-> string @-> returning bool ) is_leaf
326333 let () = I. internal " get_subtree" ((ptr void) @-> string @-> bool @-> returning (ptr void)) get_subtree
327334 let () = I. internal " exists" ((ptr void) @-> string @-> returning int ) exists
335+ let () = I. internal " value_exists" ((ptr void) @-> string @-> string @-> returning int ) value_exists
328336 let () = I. internal " list_nodes" ((ptr void) @-> string @-> returning string ) list_nodes
329337 let () = I. internal " return_value" ((ptr void) @-> string @-> returning string ) return_value
330338 let () = I. internal " return_values" ((ptr void) @-> string @-> returning string ) return_values
Original file line number Diff line number Diff line change @@ -145,6 +145,10 @@ def __init__(
145145 self .__exists .argtypes = [c_void_p , c_char_p ]
146146 self .__exists .restype = c_int
147147
148+ self .__value_exists = self .__lib .value_exists
149+ self .__value_exists .argtypes = [c_void_p , c_char_p , c_char_p ]
150+ self .__value_exists .restype = c_int
151+
148152 self .__list_nodes = self .__lib .list_nodes
149153 self .__list_nodes .argtypes = [c_void_p , c_char_p ]
150154 self .__list_nodes .restype = c_char_p
@@ -361,6 +365,16 @@ def exists(self, path):
361365 else :
362366 return True
363367
368+ def value_exists (self , path , value ):
369+ check_path (path )
370+ path_str = ' ' .join (map (str , path )).encode ()
371+
372+ res = self .__value_exists (self .__config , path_str , value )
373+ if res == 0 :
374+ return False
375+ else :
376+ return True
377+
364378 def list_nodes (self , path , path_must_exist = True ):
365379 check_path (path )
366380 path_str = ' ' .join (map (str , path )).encode ()
You can’t perform that action at this time.
0 commit comments