Skip to content

Commit

Permalink
Use standard textwrap.indent (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
akosthekiss committed Nov 16, 2023
1 parent e80f620 commit 7535d97
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions picireny/hdd_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from itertools import count
from os import linesep
from textwrap import indent


class Position:
Expand Down Expand Up @@ -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}',
]
Expand All @@ -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)})'

0 comments on commit 7535d97

Please sign in to comment.