From 44d9bd9913721eb1ba45d3a1e60603050dfab96e Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 5 Dec 2020 14:51:51 -0800 Subject: [PATCH] Add assert_is_link, assert_not_link. --- voussoirkit/pathclass.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/voussoirkit/pathclass.py b/voussoirkit/pathclass.py index 6cf285f..f793d10 100644 --- a/voussoirkit/pathclass.py +++ b/voussoirkit/pathclass.py @@ -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 == '':