I'm trying to create two for statements,but only one of them runs >.< it's supposed to obfuscate username AND passwords..
Also is there any way to simplify it rather than have two for statements..? The only difference in the second for statement is "Username" and "username" changed to "Password" and "password" ..
for key1, value1 in self.entrydict.items():
if not isinstance(value1, dict): # shouldn't happen
if key1.find('Username') == -1:
self.settings[key1] = value1.getvalue()
else:
self.settings[key1] = myutils.username_obfuscate(value1.getvalue())
else:
for key2, value2 in value1.items():
if not isinstance(value2, dict):
if key2.find('Username') == -1:
self.settings[key1][key2] = value2.getvalue()
else:
self.settings[key1][key2] = myutils.username_obfuscate(value2.getvalue())
else:
for key3, value3 in value2.items():
if not isinstance(value3, dict):
if key3.find('Username') == -1:
self.settings[key1][key2][key3] = value3.getvalue()
else:
self.settings[key1][key2][key3] = myutils.username_obfuscate(value3.getvalue())
else:
pass # shouldn't happen
######### Here is where the second for statement starts .. redundant and doesn't even work
###############
for key1, value1 in self.entrydict.items():
if not isinstance(value1, dict): # shouldn't happen
if key1.find('Password') == -1:
self.settings[key1] = value1.getvalue()
else:
self.settings[key1] = myutils.password_obfuscate(value1.getvalue())
else:
for key2, value2 in value1.items():
if not isinstance(value2, dict):
if key2.find('Password') == -1:
self.settings[key1][key2] = value2.getvalue()
else:
self.settings[key1][key2] = myutils.password_obfuscate(value2.getvalue())
else:
for key3, value3 in value2.items():
if not isinstance(value3, dict):
if key3.find('Password') == -1:
self.settings[key1][key2][key3] = value3.getvalue()
else:
self.settings[key1][key2][key3] = myutils.password_obfuscate(value3.getvalue())
else:
pass # shouldn't happen