Add assert_is_link, assert_not_link.

This commit is contained in:
voussoir 2020-12-05 14:51:51 -08:00
parent 946f329e8c
commit 44d9bd9913

View file

@ -11,6 +11,9 @@ class PathclassException(Exception):
class Exists(PathclassException):
pass
class IsLink(PathclassException):
pass
class NotExists(PathclassException):
pass
@ -20,6 +23,9 @@ class NotDirectory(PathclassException):
class NotFile(PathclassException):
pass
class NotLink(PathclassException):
pass
class Extension:
def __init__(self, ext):
@ -119,6 +125,10 @@ class Path:
if self.exists:
raise Exists(self)
def assert_not_link(self):
if self.is_link:
raise IsLink(self)
def assert_is_file(self):
if not self.is_file:
raise NotFile(self)
@ -127,6 +137,10 @@ class Path:
if not self.is_dir:
raise NotDirectory(self)
def assert_is_link(self):
if not self.is_link:
raise NotLink(self)
def add_extension(self, extension):
extension = Extension(extension)
if extension == '':