Skip to content

Commit

Permalink
[doc] Add Pretty Print
Browse files Browse the repository at this point in the history
Add pprint method showing document information and section/
property tree.

Related to issue G-Node#319.
  • Loading branch information
fschrader1992 committed Jun 18, 2019
1 parent b0170a8 commit 9915a72
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions odml/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,21 @@ def get_terminology_equivalent(self):
return None
term = terminology.load(self.repository)
return term
def pprint(self, indent=2, max_depth=1, max_length=80, current_depth=0):
"""
Pretty print method to visualize Document-Section trees.
:param indent: number of leading spaces for every child Section or Property.
:param max_depth: maximum number of hierarchical levels printed from the
starting Section.
:param max_length: maximum number of characters printed in one line.
:param current_depth: number of hierarchical levels printed from the
starting Section.
"""
doc_str = "[{} [{}] {}, sections: {}, repository: {}]".format(self.author, self.version,
self.date, len(self._sections), self.repository)
print(doc_str)

for s in self._sections:
s.pprint(current_depth=current_depth+1, max_depth=max_depth,
indent=indent, max_length=max_length)

0 comments on commit 9915a72

Please # to comment.