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