set destination folder name using name attribute of folder copy api.
This commit is contained in:
parent
8588c6ce70
commit
4641b9304e
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@ -9,6 +9,9 @@
|
|||||||
"[xml]": {
|
"[xml]": {
|
||||||
"editor.defaultFormatter": "redhat.vscode-xml"
|
"editor.defaultFormatter": "redhat.vscode-xml"
|
||||||
},
|
},
|
||||||
|
"[json]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
"[jsonc]": {
|
"[jsonc]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
},
|
||||||
@ -19,8 +22,10 @@
|
|||||||
"isort.args": ["--profile=black"],
|
"isort.args": ["--profile=black"],
|
||||||
// Extensions - Prettier
|
// Extensions - Prettier
|
||||||
"prettier.printWidth": 120,
|
"prettier.printWidth": 120,
|
||||||
|
"prettier.semi": true,
|
||||||
"prettier.singleQuote": true,
|
"prettier.singleQuote": true,
|
||||||
"prettier.tabWidth": 4,
|
"prettier.tabWidth": 2,
|
||||||
|
"prettier.trailingComma": "all",
|
||||||
// Extensions - Pylance
|
// Extensions - Pylance
|
||||||
"python.analysis.typeCheckingMode": "strict",
|
"python.analysis.typeCheckingMode": "strict",
|
||||||
"python.analysis.exclude": ["api/migrations/[0-9]*.py"],
|
"python.analysis.exclude": ["api/migrations/[0-9]*.py"],
|
||||||
|
@ -94,10 +94,10 @@ class FolderApi(BaseApi):
|
|||||||
self._raise_response_error(response)
|
self._raise_response_error(response)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def move(self, folder: FolderSimple, folder_id: str) -> bool:
|
def move(self, folder: FolderSimple, folder_id: str, name: str) -> bool:
|
||||||
# print(self.__class__.__name__ + "::" + sys._getframe().f_code.co_name)
|
# print(self.__class__.__name__ + "::" + sys._getframe().f_code.co_name)
|
||||||
url = self.ENTRYPOINT + folder.id + "/move/"
|
url = self.ENTRYPOINT + folder.id + "/move/"
|
||||||
data: dict[str, str | int] = {"parent": folder_id}
|
data: dict[str, str | int] = {"parent": folder_id, "name": name}
|
||||||
token_check(self.connection)
|
token_check(self.connection)
|
||||||
response = self.connection.post(url, data=data)
|
response = self.connection.post(url, data=data)
|
||||||
self._raise_response_error(response)
|
self._raise_response_error(response)
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
import dataclasses
|
|
||||||
import os
|
import os
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unicodedata import normalize
|
from unicodedata import normalize
|
||||||
|
|
||||||
from pydantic import TypeAdapter
|
|
||||||
|
|
||||||
from mdrsclient.api import FileApi, FolderApi
|
from mdrsclient.api import FileApi, FolderApi
|
||||||
from mdrsclient.commands.base import BaseCommand
|
from mdrsclient.commands.base import BaseCommand
|
||||||
from mdrsclient.exceptions import IllegalArgumentException
|
from mdrsclient.exceptions import IllegalArgumentException
|
||||||
from mdrsclient.models import FolderSimple
|
|
||||||
|
|
||||||
|
|
||||||
class MvCommand(BaseCommand):
|
class MvCommand(BaseCommand):
|
||||||
@ -72,9 +68,5 @@ class MvCommand(BaseCommand):
|
|||||||
raise IllegalArgumentException(f"`{s_path}` and `{s_path}` are the same folder.")
|
raise IllegalArgumentException(f"`{s_path}` and `{s_path}` are the same folder.")
|
||||||
raise IllegalArgumentException(f"Cannot move `{s_path}` to `{d_path}`: Folder not empty.")
|
raise IllegalArgumentException(f"Cannot move `{s_path}` to `{d_path}`: Folder not empty.")
|
||||||
folder_api = FolderApi(connection)
|
folder_api = FolderApi(connection)
|
||||||
if s_parent_folder.id != d_parent_folder.id:
|
if s_parent_folder.id != d_parent_folder.id or d_basename != s_basename:
|
||||||
folder_api.move(s_folder, d_parent_folder.id)
|
folder_api.move(s_folder, d_parent_folder.id, normalize("NFC", d_basename))
|
||||||
if s_basename != d_basename:
|
|
||||||
d_folder_dict = dataclasses.asdict(s_folder) | {"name": normalize("NFC", d_basename)}
|
|
||||||
d_folder = TypeAdapter(FolderSimple).validate_python(d_folder_dict)
|
|
||||||
folder_api.update(d_folder)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user