Add method Path.add_extension.

master
Ethan Dalool 2019-08-01 08:47:27 -07:00
parent b8aaecd15f
commit 6a34c8eae9
1 changed files with 6 additions and 0 deletions

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)