From e8a23e0ede1b1b7433545328c6d66e571c2a2d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Fri, 12 May 2023 11:16:45 +0200 Subject: [PATCH] fix table outputs (join multiple values with separator again), use separate method for (simple) json --- src/ldaptool/decode/_decoder.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ldaptool/decode/_decoder.py b/src/ldaptool/decode/_decoder.py index 3027f44..43e4212 100644 --- a/src/ldaptool/decode/_decoder.py +++ b/src/ldaptool/decode/_decoder.py @@ -199,13 +199,19 @@ class Decoder: return decoded_entry def human(self, *, dn: str, obj: TDecoded) -> dict[str, str]: + emit: dict[str, typing.Any] = dict(dn=dn) + for name, attrs in obj.items(): + emit[name] = self.arguments.human_separator.join(attr.human() for attr in attrs) + return emit + + def simple_json(self, *, dn: str, obj: TDecoded) -> dict[str, str]: emit: dict[str, typing.Any] = dict(dn=dn) for name, attrs in obj.items(): emit[name] = [attr.human() for attr in attrs] return emit def emit_simple_json(self, *, dn: str, obj: TDecoded, file: typing.IO[str] = sys.stdout) -> None: - emit = self.human(dn=dn, obj=obj) + emit = self.simple_json(dn=dn, obj=obj) json.dump(emit, file, ensure_ascii=False) print(file=file) # terminate output dicts by newline