in asfpy/clitools.py [0:0]
def ldapsearch_parse(indata: str):
"""Parses ldapsearch output into structured python data"""
results = []
bunch = {}
for line in indata.splitlines(keepends=False):
if not line: # The end of a bunch always ends with a blank line.
results.append(bunch)
bunch = {}
else:
key, value = line.split(":", maxsplit=1)
if value.startswith(":"): # Base64
value = base64.standard_b64decode(value[2:]).decode("utf-8")
else:
value = value.strip()
if key not in bunch:
bunch[key] = list()
bunch[key].append(value)
return results # Return the list of results