mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-22 14:13:40 -07:00
Update zipp==3.15.0
This commit is contained in:
parent
089edddd73
commit
a6bc75aca2
1 changed files with 31 additions and 10 deletions
|
@ -88,6 +88,11 @@ class CompleteDirs(InitializedState, zipfile.ZipFile):
|
||||||
"""
|
"""
|
||||||
A ZipFile subclass that ensures that implied directories
|
A ZipFile subclass that ensures that implied directories
|
||||||
are always included in the namelist.
|
are always included in the namelist.
|
||||||
|
|
||||||
|
>>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt']))
|
||||||
|
['foo/', 'foo/bar/']
|
||||||
|
>>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt', 'foo/bar/']))
|
||||||
|
['foo/']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -97,7 +102,7 @@ class CompleteDirs(InitializedState, zipfile.ZipFile):
|
||||||
return _dedupe(_difference(as_dirs, names))
|
return _dedupe(_difference(as_dirs, names))
|
||||||
|
|
||||||
def namelist(self):
|
def namelist(self):
|
||||||
names = super(CompleteDirs, self).namelist()
|
names = super().namelist()
|
||||||
return names + list(self._implied_dirs(names))
|
return names + list(self._implied_dirs(names))
|
||||||
|
|
||||||
def _name_set(self):
|
def _name_set(self):
|
||||||
|
@ -113,6 +118,17 @@ class CompleteDirs(InitializedState, zipfile.ZipFile):
|
||||||
dir_match = name not in names and dirname in names
|
dir_match = name not in names and dirname in names
|
||||||
return dirname if dir_match else name
|
return dirname if dir_match else name
|
||||||
|
|
||||||
|
def getinfo(self, name):
|
||||||
|
"""
|
||||||
|
Supplement getinfo for implied dirs.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return super().getinfo(name)
|
||||||
|
except KeyError:
|
||||||
|
if not name.endswith('/') or name not in self._name_set():
|
||||||
|
raise
|
||||||
|
return zipfile.ZipInfo(filename=name)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def make(cls, source):
|
def make(cls, source):
|
||||||
"""
|
"""
|
||||||
|
@ -142,16 +158,21 @@ class FastLookup(CompleteDirs):
|
||||||
def namelist(self):
|
def namelist(self):
|
||||||
with contextlib.suppress(AttributeError):
|
with contextlib.suppress(AttributeError):
|
||||||
return self.__names
|
return self.__names
|
||||||
self.__names = super(FastLookup, self).namelist()
|
self.__names = super().namelist()
|
||||||
return self.__names
|
return self.__names
|
||||||
|
|
||||||
def _name_set(self):
|
def _name_set(self):
|
||||||
with contextlib.suppress(AttributeError):
|
with contextlib.suppress(AttributeError):
|
||||||
return self.__lookup
|
return self.__lookup
|
||||||
self.__lookup = super(FastLookup, self)._name_set()
|
self.__lookup = super()._name_set()
|
||||||
return self.__lookup
|
return self.__lookup
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_text_encoding(encoding=None, *args, **kwargs):
|
||||||
|
# stacklevel=3 so that the caller of the caller see any warning.
|
||||||
|
return text_encoding(encoding, 3), args, kwargs
|
||||||
|
|
||||||
|
|
||||||
class Path:
|
class Path:
|
||||||
"""
|
"""
|
||||||
A pathlib-compatible interface for zip files.
|
A pathlib-compatible interface for zip files.
|
||||||
|
@ -201,7 +222,7 @@ class Path:
|
||||||
|
|
||||||
Read text:
|
Read text:
|
||||||
|
|
||||||
>>> c.read_text()
|
>>> c.read_text(encoding='utf-8')
|
||||||
'content of c'
|
'content of c'
|
||||||
|
|
||||||
existence:
|
existence:
|
||||||
|
@ -273,9 +294,9 @@ class Path:
|
||||||
if args or kwargs:
|
if args or kwargs:
|
||||||
raise ValueError("encoding args invalid for binary operation")
|
raise ValueError("encoding args invalid for binary operation")
|
||||||
return stream
|
return stream
|
||||||
else:
|
# Text mode:
|
||||||
kwargs["encoding"] = text_encoding(kwargs.get("encoding"))
|
encoding, args, kwargs = _extract_text_encoding(*args, **kwargs)
|
||||||
return io.TextIOWrapper(stream, *args, **kwargs)
|
return io.TextIOWrapper(stream, encoding, *args, **kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -298,8 +319,8 @@ class Path:
|
||||||
return pathlib.Path(self.root.filename).joinpath(self.at)
|
return pathlib.Path(self.root.filename).joinpath(self.at)
|
||||||
|
|
||||||
def read_text(self, *args, **kwargs):
|
def read_text(self, *args, **kwargs):
|
||||||
kwargs["encoding"] = text_encoding(kwargs.get("encoding"))
|
encoding, args, kwargs = _extract_text_encoding(*args, **kwargs)
|
||||||
with self.open('r', *args, **kwargs) as strm:
|
with self.open('r', encoding, *args, **kwargs) as strm:
|
||||||
return strm.read()
|
return strm.read()
|
||||||
|
|
||||||
def read_bytes(self):
|
def read_bytes(self):
|
||||||
|
@ -344,7 +365,7 @@ class Path:
|
||||||
|
|
||||||
def glob(self, pattern):
|
def glob(self, pattern):
|
||||||
if not pattern:
|
if not pattern:
|
||||||
raise ValueError("Unacceptable pattern: {!r}".format(pattern))
|
raise ValueError(f"Unacceptable pattern: {pattern!r}")
|
||||||
|
|
||||||
matches = re.compile(fnmatch.translate(pattern)).fullmatch
|
matches = re.compile(fnmatch.translate(pattern)).fullmatch
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue