Return a new path with the file suffix changed. If the path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path.
(self, suffix)
| 680 | return self.with_name(stem + self.suffix) |
| 681 | |
| 682 | def with_suffix(self, suffix): |
| 683 | """Return a new path with the file suffix changed. If the path |
| 684 | has no suffix, add given suffix. If the given suffix is an empty |
| 685 | string, remove the suffix from the path. |
| 686 | """ |
| 687 | f = self._flavour |
| 688 | if f.sep in suffix or f.altsep and f.altsep in suffix: |
| 689 | raise ValueError("Invalid suffix %r" % (suffix,)) |
| 690 | if suffix and not suffix.startswith('.') or suffix == '.': |
| 691 | raise ValueError("Invalid suffix %r" % (suffix)) |
| 692 | name = self.name |
| 693 | if not name: |
| 694 | raise ValueError("%r has an empty name" % (self,)) |
| 695 | old_suffix = self.suffix |
| 696 | if not old_suffix: |
| 697 | name = name + suffix |
| 698 | else: |
| 699 | name = name[:-len(old_suffix)] + suffix |
| 700 | return self._from_parsed_parts(self._drv, self._root, |
| 701 | self._parts[:-1] + [name]) |
| 702 | |
| 703 | def relative_to(self, *other): |
| 704 | """Return the relative path to another path identified by the passed |
no test coverage detected