mirror of
https://github.com/arabianq/yndx-disk.git
synced 2026-04-27 22:21:23 +00:00
30 lines
537 B
Python
30 lines
537 B
Python
from pathlib import Path
|
|
|
|
|
|
DEFAULT_HEADERS = {
|
|
"Accept": "application/json",
|
|
"Authorization": "OAuth {token}",
|
|
}
|
|
|
|
|
|
|
|
def generate_headers(token: str) -> dict:
|
|
headers = DEFAULT_HEADERS.copy()
|
|
|
|
headers["Authorization"] = f"OAuth {token}"
|
|
|
|
return headers
|
|
|
|
|
|
def parse_path(path: str) -> str:
|
|
if path.startswith("/"):
|
|
path = "disk:/" + path[1:]
|
|
elif not path.startswith("disk:/"):
|
|
path = "disk:/" + path
|
|
|
|
path = Path(path) # Some kind of check is path valid or not =P
|
|
|
|
return str(path)
|
|
|
|
|