Rearrange some asserts.

This commit is contained in:
voussoir 2022-04-30 07:23:02 -07:00
parent fa78fa3b9d
commit cb84774231
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -223,6 +223,8 @@ class Path:
raise NotEnoughSpace(path=self, reserve=reserve, free=free) raise NotEnoughSpace(path=self, reserve=reserve, free=free)
return free return free
# ASSERTS
def assert_exists(self): def assert_exists(self):
if not self.exists: if not self.exists:
raise NotExists(self) raise NotExists(self)
@ -231,34 +233,42 @@ 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)
assert_not_dir = assert_not_directory
def assert_not_link(self):
if self.is_link:
raise IsLink(self)
def assert_is_file(self): def assert_is_file(self):
if not self.is_file: if not self.is_file:
raise NotFile(self) raise NotFile(self)
def assert_not_file(self):
if self.is_file:
raise IsFile(self)
#
def assert_is_directory(self): def assert_is_directory(self):
if not self.is_dir: if not self.is_dir:
raise NotDirectory(self) raise NotDirectory(self)
assert_is_dir = assert_is_directory assert_is_dir = assert_is_directory
def assert_not_directory(self):
if self.is_dir:
raise IsDirectory(self)
assert_not_dir = assert_not_directory
#
def assert_is_link(self): def assert_is_link(self):
if not self.is_link: if not self.is_link:
raise NotLink(self) raise NotLink(self)
def assert_not_link(self):
if self.is_link:
raise IsLink(self)
#
def add_extension(self, extension): def add_extension(self, extension):
extension = Extension(extension) extension = Extension(extension)
if extension == '': if extension == '':