Improve Bakefile detection logic

If Bakefile is not found, None would be returned as a result of
Bakefile.find().
This commit is contained in:
Jongwook Choi
2019-09-22 14:50:31 -04:00
parent 5113911faa
commit 0f62910a56
+4 -2
View File
@@ -131,18 +131,20 @@ class Bakefile:
@classmethod
def find(
Class, *, filename="Bashfile", root=os.getcwd(), max_depth=4, topdown=False
Class, *, filename="Bakefile", root=os.getcwd(), max_depth=4, topdown=False
):
"""Returns the path of a Pipfile in parent directories."""
i = 0
for c, d, f in utils.walk_up(root):
if i > max_depth:
raise NoBakefileFound(f"No {filename} found!")
break
elif filename in f:
return Class(path=os.path.join(c, filename))
i += 1
raise NoBakefileFound(f"No {filename} found!")
@property
def source(self):
with open(self.path, "r") as f: