'Changes the extension of the path to the provided value (the
"." should not be included in the extension as a "." is
provided)'

def set_extension(self, extension):

    pieces = self.path.split('/')
    dirs = pieces[:(-1)]
    base = pieces[(-1)].split('.')
    base = '.'.join((base[:(-1)] if (len(base) > 1) else base))
    if extension:
        base += ('.' + extension)
    dirs.append(base)
    self.path = '/'.join(dirs)
    return self
