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)
| 165 | # Generic implementation of splitext, to be parametrized with |
| 166 | # the separators |
| 167 | def _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 | |
| 190 | def _check_arg_types(funcname, *args): |
| 191 | hasstr = hasbytes = False |
nothing calls this directly
no test coverage detected
searching dependent graphs…