Skip to content

Commit

Permalink
Create a short version of the tree property
Browse files Browse the repository at this point in the history
NXobject.short_tree excludes attributes.
  • Loading branch information
rayosborn committed Jul 7, 2015
1 parent 6d17aed commit c172055
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/nexusformat/nexus/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,11 +1064,22 @@ def tree(self):
Returns the directory tree as a string.
The tree contains all child objects of this object and their children.
It invokes the 'dir' method with both 'attrs' and 'recursive' set
to True.
It invokes the 'dir' method with 'attrs' set to False and 'recursive'
set to True.
"""
return self._str_tree(attrs=True, recursive=True)

@property
def short_tree(self):
"""
Returns the directory tree as a string.
The tree contains all child objects of this object and their children.
It invokes the 'dir' method with 'attrs' set to False and 'recursive'
set to True.
"""
return self._str_tree(attrs=False, recursive=True)

def rename(self, name):
if self.nxfilemode == 'r':
raise NeXusError('NeXus file opened as readonly')
Expand Down Expand Up @@ -3263,10 +3274,7 @@ def __unicode__(self):
return unicode(self.nxlink)

def _str_tree(self, indent=0, attrs=False, recursive=False):
if self.nxlink:
return self.nxlink._str_tree(indent, attrs, recursive)
else:
return " "*indent+self.nxname+' -> '+self._target
return " "*indent+self.nxname+' -> '+self._target

def _getlink(self):
return self.nxroot[self._target]
Expand Down

0 comments on commit c172055

Please sign in to comment.