Added recursirve search
This commit is contained in:
parent
0849593430
commit
132f4108fd
@ -103,13 +103,19 @@ try:
|
|||||||
with open( plist, 'rb' ) as fp:
|
with open( plist, 'rb' ) as fp:
|
||||||
content = plistlib.load( fp )
|
content = plistlib.load( fp )
|
||||||
except:
|
except:
|
||||||
print( "\nError: plist is not a XML file!\n" )
|
print( "\nError: not able to load plist!\n" )
|
||||||
sys.exit( 1 )
|
sys.exit( 1 )
|
||||||
|
|
||||||
try:
|
# net to be able to get values of keys and subkeys
|
||||||
print( key + ":", content[ key ] )
|
def _finditem(obj, key):
|
||||||
except:
|
if key in obj: return obj[key]
|
||||||
print( "\nError: key not found!\n" )
|
for k, v in obj.items():
|
||||||
sys.exit( 1 )
|
if isinstance(v,dict):
|
||||||
|
item = _finditem(v, key)
|
||||||
|
if item is not None:
|
||||||
|
return item
|
||||||
|
|
||||||
sys.exit( 0 )
|
# find key and print value (recursively)
|
||||||
|
print( key + ":", _finditem( content, key ) )
|
||||||
|
|
||||||
|
sys.exit( 0 )
|
Loading…
x
Reference in New Issue
Block a user