Add assert_is_link, assert_not_link.
This commit is contained in:
parent
946f329e8c
commit
44d9bd9913
1 changed files with 14 additions and 0 deletions
|
@ -11,6 +11,9 @@ class PathclassException(Exception):
|
||||||
class Exists(PathclassException):
|
class Exists(PathclassException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class IsLink(PathclassException):
|
||||||
|
pass
|
||||||
|
|
||||||
class NotExists(PathclassException):
|
class NotExists(PathclassException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -20,6 +23,9 @@ class NotDirectory(PathclassException):
|
||||||
class NotFile(PathclassException):
|
class NotFile(PathclassException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class NotLink(PathclassException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Extension:
|
class Extension:
|
||||||
def __init__(self, ext):
|
def __init__(self, ext):
|
||||||
|
@ -119,6 +125,10 @@ class Path:
|
||||||
if self.exists:
|
if self.exists:
|
||||||
raise Exists(self)
|
raise Exists(self)
|
||||||
|
|
||||||
|
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)
|
||||||
|
@ -127,6 +137,10 @@ class Path:
|
||||||
if not self.is_dir:
|
if not self.is_dir:
|
||||||
raise NotDirectory(self)
|
raise NotDirectory(self)
|
||||||
|
|
||||||
|
def assert_is_link(self):
|
||||||
|
if not self.is_link:
|
||||||
|
raise NotLink(self)
|
||||||
|
|
||||||
def add_extension(self, extension):
|
def add_extension(self, extension):
|
||||||
extension = Extension(extension)
|
extension = Extension(extension)
|
||||||
if extension == '':
|
if extension == '':
|
||||||
|
|
Loading…
Reference in a new issue