Add assert_not_file, assert_not_directory to round it out.

This commit is contained in:
voussoir 2020-12-05 14:55:02 -08:00
parent 44d9bd9913
commit ebe009f2a2

View file

@ -11,6 +11,12 @@ class PathclassException(Exception):
class Exists(PathclassException): class Exists(PathclassException):
pass pass
class IsFile(PathclassException):
pass
class IsDirectory(PathclassException):
pass
class IsLink(PathclassException): class IsLink(PathclassException):
pass pass
@ -125,6 +131,14 @@ class Path:
if self.exists: if self.exists:
raise Exists(self) raise Exists(self)
def assert_not_file(self):
if self.is_file:
raise IsFile(self)
def assert_not_directory(self):
if self.is_dir:
raise IsDirectory(self)
def assert_not_link(self): def assert_not_link(self):
if self.is_link: if self.is_link:
raise IsLink(self) raise IsLink(self)