fixed that CachePackage.open works also for filenames as strings
This commit is contained in:
parent
6e12553c5f
commit
fc7e3a1ecf
1 changed files with 5 additions and 2 deletions
7
src/c3nav/mapdata/utils/cache/package.py
vendored
7
src/c3nav/mapdata/utils/cache/package.py
vendored
|
@ -2,8 +2,9 @@ import os
|
|||
import struct
|
||||
from collections import namedtuple
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from tarfile import TarFile, TarInfo
|
||||
from typing import BinaryIO, Self
|
||||
from typing import BinaryIO, Self, Optional
|
||||
|
||||
from pyzstd import CParameter, ZstdError, ZstdFile
|
||||
|
||||
|
@ -107,10 +108,12 @@ class CachePackage:
|
|||
return cls(bounds, levels)
|
||||
|
||||
@classmethod
|
||||
def open(cls, package=None):
|
||||
def open(cls, package:Optional[str | os.PathLike] = None):
|
||||
if package is None:
|
||||
from django.conf import settings
|
||||
package = settings.CACHE_ROOT / 'package.tar'
|
||||
elif not hasattr(package, 'open'):
|
||||
package = Path(package)
|
||||
return cls.read(package.open('rb'))
|
||||
|
||||
cached = LocalContext()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue