Add method Path.add_extension.

This commit is contained in:
Ethan Dalool 2019-08-01 08:47:27 -07:00
parent b8aaecd15f
commit 6a34c8eae9

View file

@ -64,6 +64,12 @@ class Path:
if not self.is_dir:
raise NotDirectory(self)
def add_extension(self, extension):
extension = extension.strip('.')
if extension == '':
return self
return Path(self.absolute_path + '.' + extension)
@property
def basename(self):
return os.path.basename(self.absolute_path)