From 6a34c8eae94227e5a3e4c16dfbcd1d6e93265b02 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 1 Aug 2019 08:47:27 -0700 Subject: [PATCH] Add method Path.add_extension. --- voussoirkit/pathclass.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/voussoirkit/pathclass.py b/voussoirkit/pathclass.py index 2593e0f..b33cc93 100644 --- a/voussoirkit/pathclass.py +++ b/voussoirkit/pathclass.py @@ -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)