set destination folder name using name attribute of folder copy api.

This commit is contained in:
Yoshihiro OKUMURA 2023-07-26 19:59:07 +09:00
parent 8588c6ce70
commit 4641b9304e
Signed by: orrisroot
GPG Key ID: 470AA444C92904B2
4 changed files with 57 additions and 60 deletions

View File

@ -1,14 +1,14 @@
{ {
"recommendations": [ "recommendations": [
"ms-python.python", "ms-python.python",
"ms-python.black-formatter", "ms-python.black-formatter",
"ms-python.isort", "ms-python.isort",
"ms-python.flake8", "ms-python.flake8",
"ms-python.vscode-pylance", "ms-python.vscode-pylance",
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"redhat.vscode-xml", "redhat.vscode-xml",
"njpwerner.autodocstring", "njpwerner.autodocstring",
"mosapride.zenkaku", "mosapride.zenkaku",
"streetsidesoftware.code-spell-checker" "streetsidesoftware.code-spell-checker"
] ]
} }

77
.vscode/settings.json vendored
View File

@ -1,38 +1,43 @@
{ {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.organizeImports": true "source.organizeImports": true
}, },
"[python]": { "[python]": {
"editor.defaultFormatter": "ms-python.black-formatter" "editor.defaultFormatter": "ms-python.black-formatter"
}, },
"[xml]": { "[xml]": {
"editor.defaultFormatter": "redhat.vscode-xml" "editor.defaultFormatter": "redhat.vscode-xml"
}, },
"[jsonc]": { "[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
// Extensions - Code Spell Checker "[jsonc]": {
"cSpell.ignoreWords": ["getframe", "pydantic", "UNLCK"], "editor.defaultFormatter": "esbenp.prettier-vscode"
"cSpell.words": ["chacl", "mdrs", "mdrsclient", "neurodata", "Neuroinformatics", "RIKEN"], },
// Extensions - isort // Extensions - Code Spell Checker
"isort.args": ["--profile=black"], "cSpell.ignoreWords": ["getframe", "pydantic", "UNLCK"],
// Extensions - Prettier "cSpell.words": ["chacl", "mdrs", "mdrsclient", "neurodata", "Neuroinformatics", "RIKEN"],
"prettier.printWidth": 120, // Extensions - isort
"prettier.singleQuote": true, "isort.args": ["--profile=black"],
"prettier.tabWidth": 4, // Extensions - Prettier
// Extensions - Pylance "prettier.printWidth": 120,
"python.analysis.typeCheckingMode": "strict", "prettier.semi": true,
"python.analysis.exclude": ["api/migrations/[0-9]*.py"], "prettier.singleQuote": true,
// Extensions - Python:black "prettier.tabWidth": 2,
"python.formatting.blackArgs": ["--line-length=120"], "prettier.trailingComma": "all",
"python.formatting.provider": "black", // Extensions - Pylance
// Extensions - Python:Flake8 "python.analysis.typeCheckingMode": "strict",
"python.linting.enabled": true, "python.analysis.exclude": ["api/migrations/[0-9]*.py"],
"python.linting.flake8Enabled": true, // Extensions - Python:black
"python.linting.flake8Args": ["--max-line-length=120"], "python.formatting.blackArgs": ["--line-length=120"],
"python.linting.ignorePatterns": ["**/site-packages/**/*.py", ".vscode/*.py"], "python.formatting.provider": "black",
"python.linting.lintOnSave": true, // Extensions - Python:Flake8
// Extensions - Python Docstring Generator configuration "python.linting.enabled": true,
"autoDocstring.docstringFormat": "google" "python.linting.flake8Enabled": true,
"python.linting.flake8Args": ["--max-line-length=120"],
"python.linting.ignorePatterns": ["**/site-packages/**/*.py", ".vscode/*.py"],
"python.linting.lintOnSave": true,
// Extensions - Python Docstring Generator configuration
"autoDocstring.docstringFormat": "google"
} }

View File

@ -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)

View File

@ -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)