MCPcopy Index your code
hub / github.com/RustPython/RustPython / _splitext

Function _splitext

Lib/genericpath.py:157–178  ·  view source on GitHub ↗

Split the extension from a pathname. Extension is everything from the last dot to the end, ignoring leading dots. Returns "(root, ext)"; ext may be empty.

(p, sep, altsep, extsep)

Source from the content-addressed store, hash-verified

155# Generic implementation of splitext, to be parametrized with
156# the separators
157def _splitext(p, sep, altsep, extsep):
158 """Split the extension from a pathname.
159
160 Extension is everything from the last dot to the end, ignoring
161 leading dots. Returns "(root, ext)"; ext may be empty."""
162 # NOTE: This code must work for text and bytes strings.
163
164 sepIndex = p.rfind(sep)
165 if altsep:
166 altsepIndex = p.rfind(altsep)
167 sepIndex = max(sepIndex, altsepIndex)
168
169 dotIndex = p.rfind(extsep)
170 if dotIndex > sepIndex:
171 # skip all leading dots
172 filenameIndex = sepIndex + 1
173 while filenameIndex < dotIndex:
174 if p[filenameIndex:filenameIndex+1] != extsep:
175 return p[:dotIndex], p[dotIndex:]
176 filenameIndex += 1
177
178 return p, p[:0]
179
180def _check_arg_types(funcname, *args):
181 hasstr = hasbytes = False

Callers

nothing calls this directly

Calls 2

maxFunction · 0.85
rfindMethod · 0.45

Tested by

no test coverage detected