fix table outputs (join multiple values with separator again), use separate method for (simple) json
This commit is contained in:
parent
125eea5afc
commit
e8a23e0ede
@ -199,13 +199,19 @@ class Decoder:
|
|||||||
return decoded_entry
|
return decoded_entry
|
||||||
|
|
||||||
def human(self, *, dn: str, obj: TDecoded) -> dict[str, str]:
|
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)
|
emit: dict[str, typing.Any] = dict(dn=dn)
|
||||||
for name, attrs in obj.items():
|
for name, attrs in obj.items():
|
||||||
emit[name] = [attr.human() for attr in attrs]
|
emit[name] = [attr.human() for attr in attrs]
|
||||||
return emit
|
return emit
|
||||||
|
|
||||||
def emit_simple_json(self, *, dn: str, obj: TDecoded, file: typing.IO[str] = sys.stdout) -> None:
|
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)
|
json.dump(emit, file, ensure_ascii=False)
|
||||||
print(file=file) # terminate output dicts by newline
|
print(file=file) # terminate output dicts by newline
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user