MCPcopy Index your code
hub / github.com/python/cpython / _splitext

Function _splitext

Lib/genericpath.py:167–188  ·  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

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

Callers

nothing calls this directly

Calls 1

rfindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…