mirror of
https://github.com/etesync/server
synced 2024-12-28 02:08:08 +00:00
Update code to adjust to most recent python/fastapi.
This commit is contained in:
parent
0be14a7b0e
commit
138d99dd7f
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
@ -32,9 +33,7 @@ def _convert_file_to_url(path):
|
|||||||
path_obj = PurePath(path)
|
path_obj = PurePath(path)
|
||||||
|
|
||||||
relpath = path_obj.relative_to(path_root)
|
relpath = path_obj.relative_to(path_root)
|
||||||
# Python 3.5: Path.resolve() has no `strict` kwarg, so use pathmod from an
|
url = os.path.normpath(str(url_root / relpath))
|
||||||
# already instantiated Path object
|
|
||||||
url = relpath._flavour.pathmod.normpath(str(url_root / relpath))
|
|
||||||
|
|
||||||
return quote(str(url))
|
return quote(str(url))
|
||||||
|
|
||||||
@ -48,9 +47,7 @@ def _sanitize_path(filepath):
|
|||||||
filepath_obj = Path(filepath)
|
filepath_obj = Path(filepath)
|
||||||
|
|
||||||
# get absolute path
|
# get absolute path
|
||||||
# Python 3.5: Path.resolve() has no `strict` kwarg, so use pathmod from an
|
filepath_abs = Path(os.path.normpath(str(path_root / filepath_obj)))
|
||||||
# already instantiated Path object
|
|
||||||
filepath_abs = Path(filepath_obj._flavour.pathmod.normpath(str(path_root / filepath_obj)))
|
|
||||||
|
|
||||||
# if filepath_abs is not relative to path_root, relative_to throws an error
|
# if filepath_abs is not relative to path_root, relative_to throws an error
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user