Update vendored windows libs

This commit is contained in:
Labrys of Knossos 2022-11-28 05:59:32 -05:00
commit b1cefa94e5
226 changed files with 33472 additions and 11882 deletions

59
libs/win/path/matchers.py Normal file
View file

@ -0,0 +1,59 @@
import ntpath
import fnmatch
def load(param):
"""
If the supplied parameter is a string, assume it's a simple
pattern.
"""
return (
Pattern(param)
if isinstance(param, str)
else param
if param is not None
else Null()
)
class Base:
pass
class Null(Base):
def __call__(self, path):
return True
class Pattern(Base):
def __init__(self, pattern):
self.pattern = pattern
def get_pattern(self, normcase):
try:
return self._pattern
except AttributeError:
pass
self._pattern = normcase(self.pattern)
return self._pattern
def __call__(self, path):
normcase = getattr(self, 'normcase', path.module.normcase)
pattern = self.get_pattern(normcase)
return fnmatch.fnmatchcase(normcase(path.name), pattern)
class CaseInsensitive(Pattern):
"""
A Pattern with a ``'normcase'`` property, suitable for passing to
:meth:`listdir`, :meth:`dirs`, :meth:`files`, :meth:`walk`,
:meth:`walkdirs`, or :meth:`walkfiles` to match case-insensitive.
For example, to get all files ending in .py, .Py, .pY, or .PY in the
current directory::
from path import Path, matchers
Path('.').files(matchers.CaseInsensitive('*.py'))
"""
normcase = staticmethod(ntpath.normcase)