Skip to content

Commit

Permalink
Ignore metadata subtrees [fix #43]
Browse files Browse the repository at this point in the history
  • Loading branch information
psss committed Jul 12, 2018
1 parent b537c59 commit a6f2b95
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/child/nobody/.fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
2 changes: 2 additions & 0 deletions examples/child/nobody/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Metadata subtrees are ignored
ignored: yes
6 changes: 5 additions & 1 deletion fmf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ def grow(self, path):
# Handle other *.fmf files as children
else:
self.child(os.path.splitext(filename)[0], data, fullpath)
# Explore every child directory (ignore hidden)
# Explore every child directory (ignore hidden dirs and subtrees)
for dirname in sorted(dirnames):
if dirname.startswith("."):
continue
# Ignore metadata subtrees
if os.path.isdir(os.path.join(path, dirname, SUFFIX)):
log.debug("Ignoring metadata tree '{0}'.".format(dirname))
continue
self.child(dirname, os.path.join(path, dirname))
# Apply inheritance when all scattered data are gathered.
# This is done only once, from the top parent object.
Expand Down
5 changes: 5 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def test_scattered_inheritance(self):
assert(grandson.data['nose'] == 'long')
assert(grandson.data['hair'] == 'fair')

def test_subtrees(self):
""" Subtrees should be ignored """
child = Tree(EXAMPLES + "child")
assert child.find("/nobody") is None

def test_deep_hierarchy(self):
""" Deep hierarchy on one line """
deep = Tree(EXAMPLES + "deep")
Expand Down

0 comments on commit a6f2b95

Please sign in to comment.