Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __setitem__(self, key, value):
if not isinstance(value, PseudoNamespace):
tuple_converted = False
if isinstance(value, dict):
value = PseudoNamespace(value)
elif isinstance(value, tuple):
value = list(value)
tuple_converted = True
if isinstance(value, list):
for i, item in enumerate(value):
if isinstance(item, dict) and not isinstance(item, PseudoNamespace):
value[i] = PseudoNamespace(item)
if tuple_converted:
value = tuple(value)
super(PseudoNamespace, self).__setitem__(key, value)
def __setitem__(self, key, value):
if not isinstance(value, PseudoNamespace):
tuple_converted = False
if isinstance(value, dict):
value = PseudoNamespace(value)
elif isinstance(value, tuple):
value = list(value)
tuple_converted = True
if isinstance(value, list):
for i, item in enumerate(value):
if isinstance(item, dict) and not isinstance(item, PseudoNamespace):
value[i] = PseudoNamespace(item)
if tuple_converted:
value = tuple(value)
super(PseudoNamespace, self).__setitem__(key, value)
if not isinstance(value, PseudoNamespace):
tuple_converted = False
if isinstance(value, dict):
value = PseudoNamespace(value)
elif isinstance(value, tuple):
value = list(value)
tuple_converted = True
if isinstance(value, list):
for i, item in enumerate(value):
if isinstance(item, dict) and not isinstance(item, PseudoNamespace):
value[i] = PseudoNamespace(item)
if tuple_converted:
value = tuple(value)
super(PseudoNamespace, self).__setitem__(key, value)
if not isinstance(_d, dict):
_d = {}
_d.update(loaded)
super(PseudoNamespace, self).__init__(_d)
# Convert nested structures into PseudoNamespaces
for k, v in _d.items():
tuple_converted = False
if isinstance(v, tuple):
self[k] = v = list(v)
tuple_converted = True
if isinstance(v, list):
for i, item in enumerate(v):
if isinstance(item, dict):
self[k][i] = PseudoNamespace(item)
if tuple_converted:
self[k] = tuple(self[k])
elif isinstance(v, dict):
self[k] = PseudoNamespace(v)
def __setitem__(self, key, value):
if not isinstance(value, PseudoNamespace):
tuple_converted = False
if isinstance(value, dict):
value = PseudoNamespace(value)
elif isinstance(value, tuple):
value = list(value)
tuple_converted = True
if isinstance(value, list):
for i, item in enumerate(value):
if isinstance(item, dict) and not isinstance(item, PseudoNamespace):
value[i] = PseudoNamespace(item)
if tuple_converted:
value = tuple(value)
super(PseudoNamespace, self).__setitem__(key, value)
# Convert nested structures into PseudoNamespaces
for k, v in _d.items():
tuple_converted = False
if isinstance(v, tuple):
self[k] = v = list(v)
tuple_converted = True
if isinstance(v, list):
for i, item in enumerate(v):
if isinstance(item, dict):
self[k][i] = PseudoNamespace(item)
if tuple_converted:
self[k] = tuple(self[k])
elif isinstance(v, dict):
self[k] = PseudoNamespace(v)