Skip to content

Commit

Permalink
reindent python file
Browse files Browse the repository at this point in the history
  • Loading branch information
baszoetekouw committed May 27, 2024
1 parent 5419c69 commit b6314de
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions roles/ldap_monitor/files/ldifparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@


def kcmp(item):
(key, v) = item
parts = key.split(',')[::-1]
new_key = ','.join(parts)
return (new_key, v)
(key, v) = item
parts = key.split(',')[::-1]
new_key = ','.join(parts)
return (new_key, v)


def freeze(o):
if isinstance(o, dict):
return OrderedDict({k: freeze(v) for k, v in sorted(o.items(), key=kcmp)}.items())
if isinstance(o, list):
return sorted([freeze(v) for v in o])
return o.decode('utf-8')
if isinstance(o, dict):
return OrderedDict({k: freeze(v) for k, v in sorted(o.items(), key=kcmp)}.items())
if isinstance(o, list):
return sorted([freeze(v) for v in o])
return o.decode('utf-8')


def my_print(o, depth):
if isinstance(o, OrderedDict):
for k, v in o.items():
my_print(k, depth)
my_print(v, depth + 2)
elif isinstance(o, list):
for v in o:
my_print(v, depth)
else:
print(f"{' '*depth}{o}")
if isinstance(o, OrderedDict):
for k, v in o.items():
my_print(k, depth)
my_print(v, depth + 2)
elif isinstance(o, list):
for v in o:
my_print(v, depth)
else:
print(f"{' ' * depth}{o}")


ldifparser = ldif.LDIFRecordList(sys.stdin)
Expand Down

0 comments on commit b6314de

Please sign in to comment.