Skip to content

Commit d2d2099

Browse files
committed
Fixed minor bug in helpers.path
1 parent a9d0d59 commit d2d2099

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/tinyscript/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.30.17
1+
1.30.18

src/tinyscript/helpers/path.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,14 @@ def is_samepath(self, otherpath):
235235
""" Check if both paths have the same parts. """
236236
return self.absolute().parts == Path(otherpath).absolute().parts
237237

238-
def is_under(self, parentpath):
238+
def is_under(self, parentpath, error=False):
239239
""" Check if the path is under a parent path. """
240240
p = Path(parentpath).absolute()
241+
if not p.exists():
242+
if error:
243+
raise OSError("Path to be compared does not exist")
244+
else:
245+
return False
241246
if not p.is_dir():
242247
p = Path(p.dirname)
243248
return p in self.absolute().parents

0 commit comments

Comments
 (0)