From ebe009f2a2393926636175fcaefedd6903f5fb93 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 5 Dec 2020 14:55:02 -0800 Subject: [PATCH] Add assert_not_file, assert_not_directory to round it out. --- voussoirkit/pathclass.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/voussoirkit/pathclass.py b/voussoirkit/pathclass.py index f793d10..0bad1e3 100644 --- a/voussoirkit/pathclass.py +++ b/voussoirkit/pathclass.py @@ -11,6 +11,12 @@ class PathclassException(Exception): class Exists(PathclassException): pass +class IsFile(PathclassException): + pass + +class IsDirectory(PathclassException): + pass + class IsLink(PathclassException): pass @@ -125,6 +131,14 @@ 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) + def assert_not_link(self): if self.is_link: raise IsLink(self)