GH-72904: Add glob.translate()
function by barneygale · Pull Request #106703 · python/cpython (original) (raw)
Right, after some futzing around I'm going to mark this PR as ready again.
In fnmatch.py
, I've split the translate()
method into _translate()
and _join_translated_parts()
. This minimises the diff, risk, and performance impact in that module.
(In #109879 I've re-implemented fnmatch.translate()
, but that PR is an optional side-quest now)
In glob.py
, I've spent some time making the implementation of translate(include_hidden=False)
as clear and performant as I can. There's still a fair whack of regex involved but I think it's followable.
In pathlib.py
, I've made pattern matching use str(path)
directly, rather than a slight variant that represents empty paths as ''
rather than '.'
.