Skip to content

Commit a6f2b95

Browse files
committed
Ignore metadata subtrees [fix #43]
1 parent b537c59 commit a6f2b95

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

examples/child/nobody/.fmf/version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

examples/child/nobody/main.fmf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Metadata subtrees are ignored
2+
ignored: yes

fmf/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,14 @@ def grow(self, path):
257257
# Handle other *.fmf files as children
258258
else:
259259
self.child(os.path.splitext(filename)[0], data, fullpath)
260-
# Explore every child directory (ignore hidden)
260+
# Explore every child directory (ignore hidden dirs and subtrees)
261261
for dirname in sorted(dirnames):
262262
if dirname.startswith("."):
263263
continue
264+
# Ignore metadata subtrees
265+
if os.path.isdir(os.path.join(path, dirname, SUFFIX)):
266+
log.debug("Ignoring metadata tree '{0}'.".format(dirname))
267+
continue
264268
self.child(dirname, os.path.join(path, dirname))
265269
# Apply inheritance when all scattered data are gathered.
266270
# This is done only once, from the top parent object.

tests/test_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ def test_scattered_inheritance(self):
6868
assert(grandson.data['nose'] == 'long')
6969
assert(grandson.data['hair'] == 'fair')
7070

71+
def test_subtrees(self):
72+
""" Subtrees should be ignored """
73+
child = Tree(EXAMPLES + "child")
74+
assert child.find("/nobody") is None
75+
7176
def test_deep_hierarchy(self):
7277
""" Deep hierarchy on one line """
7378
deep = Tree(EXAMPLES + "deep")

0 commit comments

Comments
 (0)