fix commit

This commit is contained in:
2024-12-13 19:52:06 +03:00
parent 00cc47785e
commit 72b1019dca
15 changed files with 1500 additions and 42 deletions
+32
View File
@@ -0,0 +1,32 @@
import httpx
import yndx_disk.api.utils as utils
BASE_URL = "https://cloud-api.yandex.net/v1/disk"
async def get_disk_info(token: str, fields: str = "", timeout: int = 30) -> httpx.Response:
"""
Get information about the disk.
Parameters:
- token (str): The authentication token for the server.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing the disk information.
"""
url = BASE_URL
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"fields": fields,
},
timeout=timeout
)
return response
+35
View File
@@ -0,0 +1,35 @@
import httpx
import yndx_disk.api.utils as utils
BASE_URL = "https://cloud-api.yandex.net/v1/disk/operations"
async def get_operation_status(token: str, operation_id: str, fields: str = "", timeout: int = 30) -> httpx.Response:
"""
Get the status of an operation on the server.
Parameters:
- token (str): The authentication token for the server.
- operation_id (str): The ID of the operation to get the status for.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing the status of the operation.
"""
url = BASE_URL + f"/{operation_id}"
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"operation_id": operation_id,
"fields": fields,
},
timeout=timeout
)
return response
+120
View File
@@ -0,0 +1,120 @@
import httpx
import yndx_disk.api.utils as utils
BASE_URL = "https://cloud-api.yandex.net/v1/disk/public/resources"
async def get_info(token: str, public_key: str, fields: str = "", path: str = "", preview_size: str = "",
sort: str = "", preview_crop: bool = False, limit: int = 100, offset: int = 0, timeout: int = 30) -> httpx.Response:
"""
Get information about a file or directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- public_key (str): The public key of the file or directory to get information about.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- path (str, optional): The path of the file or directory to get information about. Defaults to "".
- preview_size (str, optional): The size of the preview to be included in the response. Defaults to "".
- sort (str, optional): The sorting order of the response. Defaults to "".
- preview_crop (bool, optional): Whether to crop the preview. Defaults to False.
- limit (int, optional): The maximum number of items to return in the response. Defaults to 100.
- offset (int, optional): The number of items to skip before returning the response. Defaults to 0.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing the information about the file or directory.
"""
url = BASE_URL
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"public_key": public_key,
"fields": fields,
"path": utils.parse_path(path),
"preview_size": preview_size,
"sort": sort,
"preview_crop": preview_crop,
"limit": limit,
"offset": offset,
},
timeout=timeout
)
return response
async def get_url(token: str, public_key: str, fields: str = "", path: str = "", timeout: int = 30) -> httpx.Response:
"""
Get the download URL for a file or directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- public_key (str): The public key of the file or directory to get the download URL for.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- path (str, optional): The path of the file or directory to get the download URL for. Defaults to "".
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing the download URL for the file or directory.
"""
url = BASE_URL + "/download"
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"public_key": public_key,
"fields": fields,
"path": utils.parse_path(path),
},
timeout=timeout
)
return response
async def save_to_disk(token: str, public_key: str, fields: str = "", name: str = "", path: str = "", save_path: str = "", force_async: bool = False, timeout: int = 30) -> httpx.Response:
"""
Save a file or directory from the disk to your own disk.
Parameters:
- token (str): The authentication token for the disk.
- public_key (str): The public key of the file or directory to be saved.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- name (str, optional): The name of the file or directory to be saved. Defaults to "".
- path (str, optional): The path of the file or directory to be saved. Defaults to "".
- save_path (str, optional): The path where the file or directory should be saved to. Defaults to "".
- force_async (bool, optional): Whether to force asynchronous saving. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the save operation.
"""
url = BASE_URL + "/save-to-disk"
async with httpx.AsyncClient() as client:
response = await client.post(
url=url,
headers=utils.generate_headers(token=token),
params={
"public_key": public_key,
"fields": fields,
"name": name,
"path": utils.parse_path(path),
"save_path": save_path,
"force_async": force_async,
},
timeout=timeout
)
return response
+426 -33
View File
@@ -1,13 +1,27 @@
import asyncio
import httpx
import yndx_disk.utils as utils
import yndx_disk.exceptions as exceptions
import yndx_disk.api.utils as utils
BASE_URL = "https://cloud-api.yandex.net/v1/disk/resources"
async def delete(token: str, path: str, fields: str = "", md5: str = "", force_async: bool = False,
permanently: bool = False, timeout: int = 30):
permanently: bool = False, timeout: int = 30) -> httpx.Response:
"""
Delete a file or directory from the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path of the file or directory to be deleted.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- md5 (str, optional): The MD5 hash of the file to be deleted. Defaults to "".
- force_async (bool, optional): Whether to force asynchronous deletion. Defaults to False.
- permanently (bool, optional): Whether to delete the file permanently. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the deletion operation.
"""
url = BASE_URL
async with httpx.AsyncClient() as client:
@@ -15,7 +29,7 @@ async def delete(token: str, path: str, fields: str = "", md5: str = "", force_a
url=url,
headers=utils.generate_headers(token=token),
params={
"path": path,
"path": utils.parse_path(path),
"fields": fields,
"md5": md5,
"force_async": force_async,
@@ -24,17 +38,28 @@ async def delete(token: str, path: str, fields: str = "", md5: str = "", force_a
timeout=timeout
)
response_json = response.json()
match response.status_code:
case 200:
return response_json
case _:
raise exceptions.YandexDiskAPIException(response.status_code, response_json.get("description", ""))
return response
async def get_info(token: str, path: str, fields: str = "", preview_size: str = "", sort: str = "",
preview_crop: bool = False, limit: int = 100, offset: int = 0, timeout: int = 30):
preview_crop: bool = False, limit: int = 100, offset: int = 0, timeout: int = 30) -> httpx.Response:
"""
Get information about a file or directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path of the file or directory to get information about.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- preview_size (str, optional): The size of the preview to be included in the response. Defaults to "".
- sort (str, optional): The sorting order of the response. Defaults to "".
- preview_crop (bool, optional): Whether to crop the preview. Defaults to False.
- limit (int, optional): The maximum number of items to return in the response. Defaults to 100.
- offset (int, optional): The number of items to skip before returning the response. Defaults to 0.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing the information about the file or directory.
"""
url = BASE_URL
async with httpx.AsyncClient() as client:
@@ -42,7 +67,7 @@ async def get_info(token: str, path: str, fields: str = "", preview_size: str =
url=url,
headers=utils.generate_headers(token=token),
params={
"path": path,
"path": utils.parse_path(path),
"fields": fields,
"preview_size": preview_size,
"sort": sort,
@@ -53,52 +78,420 @@ async def get_info(token: str, path: str, fields: str = "", preview_size: str =
timeout=timeout
)
response_json = response.json()
return response
match response.status_code:
case 200:
return response_json
case _:
raise exceptions.YandexDiskAPIException(response.status_code, response_json.get("description", ""))
async def update_info(token: str, path: str, body: dict, fields: str = "", timeout: int = 30):
async def update_info(token: str, path: str, body: dict, fields: str = "", timeout: int = 30) -> httpx.Response:
"""
Update information about a file or directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path of the file or directory to update.
- body (dict): The new information to be updated.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the update operation.
"""
url = BASE_URL
async def mkdir(token: str, path: str, fields: str = "", timeout: int = 30):
async with httpx.AsyncClient() as client:
response = await client.patch(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": utils.parse_path(path),
"body": body,
"fields": fields,
},
timeout=timeout
)
return response
async def mkdir(token: str, path: str, fields: str = "", timeout: int = 30) -> httpx.Response:
"""
Create a new directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path of the new directory to be created.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the creation operation.
"""
url = BASE_URL
async with httpx.AsyncClient() as client:
response = await client.put(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": utils.parse_path(path),
"fields": fields,
},
timeout=timeout
)
return response
async def copy(token: str, from_path: str, to_path: str, fields: str = "", force_async: bool = False,
overwrite: bool = False, timeout: int = 30):
overwrite: bool = False, timeout: int = 30) -> httpx.Response:
"""
Copy a file or directory from one location to another on the disk.
Parameters:
- token (str): The authentication token for the disk.
- from_path (str): The path of the file or directory to be copied.
- to_path (str): The path where the file or directory should be copied to.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- force_async (bool, optional): Whether to force asynchronous copying. Defaults to False.
- overwrite (bool, optional): Whether to overwrite the destination file or directory if it already exists. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the copy operation.
"""
url = BASE_URL + "/copy"
async def get_url(token: str, path: str, fields: str = "", timeout: int = 30):
async with httpx.AsyncClient() as client:
response = await client.post(
url=url,
headers=utils.generate_headers(token=token),
params={
"from": utils.parse_path(from_path),
"path": utils.parse_path(to_path),
"fields": fields,
"force_async": force_async,
"overwrite": overwrite,
},
timeout=timeout
)
return response
async def get_url(token: str, path: str, fields: str = "", timeout: int = 30) -> httpx.Response:
"""
Get the download URL for a file or directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path of the file or directory to get the download URL for.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing the download URL for the file or directory.
"""
url = BASE_URL + "/download"
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": utils.parse_path(path),
"fields": fields,
},
timeout=timeout
)
return response
async def get_all_files(token: str, fields: str = "", media_type: str = "", preview_size: str = "", sort: str = "",
preview_crop: bool = False, limit: int = 100, offset: int = 0, timeout: int = 30):
preview_crop: bool = False, limit: int = 100, offset: int = 0, timeout: int = 30) -> httpx.Response:
"""
Get a list of all files and directories on the disk.
Parameters:
- token (str): The authentication token for the disk.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- media_type (str, optional): The media type of the files to be included in the response. Defaults to "".
- preview_size (str, optional): The size of the preview to be included in the response. Defaults to "".
- sort (str, optional): The sorting order of the response. Defaults to "".
- preview_crop (bool, optional): Whether to crop the preview. Defaults to False.
- limit (int, optional): The maximum number of items to return in the response. Defaults to 100.
- offset (int, optional): The number of items to skip before returning the response. Defaults to 0.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing a list of all files and directories.
"""
url = BASE_URL + "/files"
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"fields": fields,
"media_type": media_type,
"preview_size": preview_size,
"sort": sort,
"preview_crop": preview_crop,
"limit": limit,
"offset": offset,
},
timeout=timeout
)
return response
async def get_last_uploads(token: str, fields: str = "", media_type: str = "", preview_size: str = "",
preview_crop: bool = False, limit: int = 100, timeout: int = 30):
preview_crop: bool = False, limit: int = 100, timeout: int = 30) -> httpx.Response:
"""
Get a list of the last uploaded files and directories on the disk.
Parameters:
- token (str): The authentication token for the disk.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- media_type (str, optional): The media type of the files to be included in the response. Defaults to "".
- preview_size (str, optional): The size of the preview to be included in the response. Defaults to "".
- preview_crop (bool, optional): Whether to crop the preview. Defaults to False.
- limit (int, optional): The maximum number of items to return in the response. Defaults to 100.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing a list of the last uploaded files and directories.
"""
url = BASE_URL + "/last-uploaded"
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"fields": fields,
"media_type": media_type,
"preview_size": preview_size,
"preview_crop": preview_crop,
"limit": limit,
},
timeout=timeout
)
return response
async def move(token: str, from_path: str, to_path: str, fields: str = "", force_async: bool = False,
overwrite: bool = False, timeout: int = 30):
overwrite: bool = False, timeout: int = 30) -> httpx.Response:
"""
Move a file or directory from one location to another on the disk.
Parameters:
- token (str): The authentication token for the disk.
- from_path (str): The path of the file or directory to be moved.
- to_path (str): The path where the file or directory should be moved to.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- force_async (bool, optional): Whether to force asynchronous moving. Defaults to False.
- overwrite (bool, optional): Whether to overwrite the destination file or directory if it already exists. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the move operation.
"""
url = BASE_URL + "/move"
async with httpx.AsyncClient() as client:
response = await client.post(
url=url,
headers=utils.generate_headers(token=token),
params={
"from": utils.parse_path(from_path),
"path": utils.parse_path(to_path),
"fields": fields,
"force_async": force_async,
"overwrite": overwrite,
},
timeout=timeout
)
return response
async def get_all_public(token: str, fields: str = "", preview_size: str = "", type_filter: str = "",
preview_crop: bool = False, limit: int = 100, offset: int = 0, timeout: int = 30):
preview_crop: bool = False, limit: int = 100, offset: int = 0, timeout: int = 30) -> httpx.Response:
"""
Get a list of all public files and directories on the disk.
Parameters:
- token (str): The authentication token for the disk.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- preview_size (str, optional): The size of the preview to be included in the response. Defaults to "".
- type_filter (str, optional): The type of files to be included in the response. Defaults to "".
- preview_crop (bool, optional): Whether to crop the preview. Defaults to False.
- limit (int, optional): The maximum number of items to return in the response. Defaults to 100.
- offset (int, optional): The number of items to skip before returning the response. Defaults to 0.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing a list of all public files and directories.
"""
url = BASE_URL + "/public"
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"fields": fields,
"preview_size": preview_size,
"type_filter": type_filter,
"preview_crop": preview_crop,
"limit": limit,
"offset": offset,
},
timeout=timeout
)
return response
async def publish(token: str, path: str, body: dict, fields: str = "", allow_address_access: bool = False,
timeout: int = 30):
timeout: int = 30) -> httpx.Response:
"""
Publish a file or directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path of the file or directory to be published.
- body (dict): The information to be published.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- allow_address_access (bool, optional): Whether to allow address access. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the publish operation.
"""
url = BASE_URL + "/publish"
async def unpublish(token: str, path: str, fields: str = "", timeout: int = 30):
async with httpx.AsyncClient() as client:
response = await client.put(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": utils.parse_path(path),
"body": body,
"fields": fields,
"allow_address_access": allow_address_access,
},
timeout=timeout
)
return response
async def unpublish(token: str, path: str, fields: str = "", timeout: int = 30) -> httpx.Response:
"""
Unpublish a file or directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path of the file or directory to be unpublished.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the unpublish operation.
"""
url = BASE_URL + "/unpublish"
async def get_upload_url(token: str, path: str, fields: str = "", overwrite: bool = False, timeout: int = 30):
async with httpx.AsyncClient() as client:
response = await client.put(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": utils.parse_path(path),
"fields": fields,
},
timeout=timeout
)
return response
async def get_upload_url(token: str, path: str, fields: str = "", overwrite: bool = False, timeout: int = 30) -> httpx.Response:
"""
Get the upload URL for a file or directory on the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path of the file or directory to get the upload URL for.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- overwrite (bool, optional): Whether to overwrite the file or directory if it already exists. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing the upload URL for the file or directory.
"""
url = BASE_URL + "/upload"
async def upload(token: str, upload_url: str, fields: str = "", disable_redirects: bool = False, timeout: int = 30):
url = BASE_URL + "/upload"
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": utils.parse_path(path),
"fields": fields,
"overwrite": overwrite,
},
timeout=timeout
)
return response
async def upload(token: str, path: str, upload_url: str, fields: str = "", disable_redirects: bool = False, timeout: int = 30) -> httpx.Response:
"""
Upload a file or directory to the disk.
Parameters:
- token (str): The authentication token for the disk.
- path (str): The path where the file or directory should be uploaded.
- upload_url (str): The URL to upload the file or directory to.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- disable_redirects (bool, optional): Whether to disable redirects. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the upload operation.
"""
url = BASE_URL + "/upload"
async with httpx.AsyncClient() as client:
response = await client.post(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": utils.parse_path(path),
"url": upload_url,
"fields": fields,
"disable_redirects": disable_redirects,
},
timeout=timeout
)
return response
+114
View File
@@ -0,0 +1,114 @@
import httpx
import yndx_disk.api.utils as utils
BASE_URL = "https://cloud-api.yandex.net/v1/disk/trash/resources"
async def delete(token: str, fields: str = "", path: str = "", force_async: bool = False, timeout: int = 30) -> httpx.Response:
"""
Empty the trash on the server.
Parameters:
- token (str): The authentication token for the server.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- path (str, optional): The path of the trash to be emptied. Defaults to "".
- force_async (bool, optional): Whether to force asynchronous emptying. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the emptying operation.
"""
url = BASE_URL
async with httpx.AsyncClient() as client:
response = await client.delete(
url=url,
headers=utils.generate_headers(token=token),
params={
"fields": fields,
"path": "" if not path else utils.parse_path(path, "trash:/"),
"force_async": force_async,
},
timeout=timeout
)
return response
async def get_info(token: str, path: str, fields: str = "", preview_size: str = "", sort: str = "",
preview_crop: bool = False, limit: int = 100, offset: int = 0, timeout: int = 30) -> httpx.Response:
"""
Get the content of the trash on the server.
Parameters:
- token (str): The authentication token for the server.
- path (str): The path of the trash to get the content from.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- preview_size (str, optional): The size of the preview to be included in the response. Defaults to "".
- sort (str, optional): The sorting order of the response. Defaults to "".
- preview_crop (bool, optional): Whether to crop the preview. Defaults to False.
- limit (int, optional): The maximum number of items to return in the response. Defaults to 100.
- offset (int, optional): The number of items to skip before returning the response. Defaults to 0.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server containing the content of the trash.
"""
url = BASE_URL
async with httpx.AsyncClient() as client:
response = await client.get(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": "" if not path else utils.parse_path(path, "trash:/"),
"fields": fields,
"preview_size": preview_size,
"sort": sort,
"preview_crop": preview_crop,
"limit": limit,
"offset": offset,
},
timeout=timeout
)
return response
async def restore(token: str, path: str, fields: str = "", name: str = "", force_async: bool = False,
overwrite: bool = False, timeout: int = 30) -> httpx.Response:
"""
Restore a file or directory from the trash on the server.
Parameters:
- token (str): The authentication token for the server.
- path (str): The path of the file or directory to be restored.
- fields (str, optional): The fields to be included in the response. Defaults to "".
- name (str, optional): The name of the file or directory to be restored. Defaults to "".
- force_async (bool, optional): Whether to force asynchronous restoring. Defaults to False.
- overwrite (bool, optional): Whether to overwrite the destination file or directory if it already exists. Defaults to False.
- timeout (int, optional): The timeout for the request in seconds. Defaults to 30.
Returns:
- httpx.Response: The response from the server after the restore operation.
"""
url = BASE_URL + "/restore"
async with httpx.AsyncClient() as client:
response = await client.put(
url=url,
headers=utils.generate_headers(token=token),
params={
"path": "" if not path else utils.parse_path(path, "trash:/"),
"fields": fields,
"name": name,
"force_async": force_async,
"overwrite": overwrite,
},
timeout=timeout
)
return response
+7 -7
View File
@@ -16,14 +16,14 @@ def generate_headers(token: str) -> dict:
return headers
def parse_path(path: str) -> str:
def parse_path(path: str, prefix: str = "disk:/") -> str:
path = str(Path(path)) # Some kind of check is path valid or not =P
if path.startswith("/"):
path = "disk:/" + path[1:]
elif not path.startswith("disk:/"):
path = "disk:/" + path
path = prefix + path[1:]
elif not path.startswith(prefix):
path = prefix + path
path = Path(path) # Some kind of check is path valid or not =P
return str(path)
return path