From cb8477423168a62530a1e9b486aa1c1406cc5cfa Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 30 Apr 2022 07:23:02 -0700 Subject: [PATCH] Rearrange some asserts. --- voussoirkit/pathclass.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/voussoirkit/pathclass.py b/voussoirkit/pathclass.py index bce750a..ad159fd 100644 --- a/voussoirkit/pathclass.py +++ b/voussoirkit/pathclass.py @@ -223,6 +223,8 @@ class Path: raise NotEnoughSpace(path=self, reserve=reserve, free=free) return free + # ASSERTS + def assert_exists(self): if not self.exists: raise NotExists(self) @@ -231,34 +233,42 @@ class Path: if self.exists: 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): if not self.is_file: raise NotFile(self) + def assert_not_file(self): + if self.is_file: + raise IsFile(self) + + # + def assert_is_directory(self): if not self.is_dir: raise NotDirectory(self) 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): if not self.is_link: raise NotLink(self) + def assert_not_link(self): + if self.is_link: + raise IsLink(self) + + # + def add_extension(self, extension): extension = Extension(extension) if extension == '':