From 7535d97e99f797cb77baf8e7279442e55383bc37 Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Thu, 16 Nov 2023 09:41:18 +0100 Subject: [PATCH] Use standard textwrap.indent (#43) --- picireny/hdd_tree.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/picireny/hdd_tree.py b/picireny/hdd_tree.py index 4f6caed..e3a7f23 100644 --- a/picireny/hdd_tree.py +++ b/picireny/hdd_tree.py @@ -8,6 +8,7 @@ from itertools import count from os import linesep +from textwrap import indent class Position: @@ -168,9 +169,6 @@ def remove_child(self, child): self.children.remove(child) def __repr__(self): - def _indent(text, prefix): - return ''.join(prefix + line for line in text.splitlines(True)) - parts = [ f'name={self.name!r}', ] @@ -184,6 +182,6 @@ def _indent(text, prefix): if self.state != self.KEEP: parts.append(f'state={self.state!r}') if self.state == self.KEEP and self.children: - parts.append('children=[\n%s\n]' % _indent(',\n'.join(repr(child) for child in self.children), ' ')) + parts.append('children=[\n%s\n]' % indent(',\n'.join(repr(child) for child in self.children), ' ')) return f'{self.__class__.__name__}({", ".join(parts)})'