MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / with_suffix

Method with_suffix

tools/python-3.11.9-amd64/Lib/pathlib.py:682–701  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 4

create_archiveFunction · 0.80
_top_level_inferredFunction · 0.80
_top_level_inferredFunction · 0.80
mainFunction · 0.80

Calls 2

_from_parsed_partsMethod · 0.95
startswithMethod · 0.80

Tested by

no test coverage detected