diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 588f27f..728c77b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,14 +1,14 @@ { - "recommendations": [ - "ms-python.python", - "ms-python.black-formatter", - "ms-python.isort", - "ms-python.flake8", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "redhat.vscode-xml", - "njpwerner.autodocstring", - "mosapride.zenkaku", - "streetsidesoftware.code-spell-checker" - ] + "recommendations": [ + "ms-python.python", + "ms-python.black-formatter", + "ms-python.isort", + "ms-python.flake8", + "ms-python.vscode-pylance", + "esbenp.prettier-vscode", + "redhat.vscode-xml", + "njpwerner.autodocstring", + "mosapride.zenkaku", + "streetsidesoftware.code-spell-checker" + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 9f23adb..065b2f4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,38 +1,43 @@ { - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.organizeImports": true - }, - "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter" - }, - "[xml]": { - "editor.defaultFormatter": "redhat.vscode-xml" - }, - "[jsonc]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - // Extensions - Code Spell Checker - "cSpell.ignoreWords": ["getframe", "pydantic", "UNLCK"], - "cSpell.words": ["chacl", "mdrs", "mdrsclient", "neurodata", "Neuroinformatics", "RIKEN"], - // Extensions - isort - "isort.args": ["--profile=black"], - // Extensions - Prettier - "prettier.printWidth": 120, - "prettier.singleQuote": true, - "prettier.tabWidth": 4, - // Extensions - Pylance - "python.analysis.typeCheckingMode": "strict", - "python.analysis.exclude": ["api/migrations/[0-9]*.py"], - // Extensions - Python:black - "python.formatting.blackArgs": ["--line-length=120"], - "python.formatting.provider": "black", - // Extensions - Python:Flake8 - "python.linting.enabled": true, - "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" + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "[xml]": { + "editor.defaultFormatter": "redhat.vscode-xml" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + // Extensions - Code Spell Checker + "cSpell.ignoreWords": ["getframe", "pydantic", "UNLCK"], + "cSpell.words": ["chacl", "mdrs", "mdrsclient", "neurodata", "Neuroinformatics", "RIKEN"], + // Extensions - isort + "isort.args": ["--profile=black"], + // Extensions - Prettier + "prettier.printWidth": 120, + "prettier.semi": true, + "prettier.singleQuote": true, + "prettier.tabWidth": 2, + "prettier.trailingComma": "all", + // Extensions - Pylance + "python.analysis.typeCheckingMode": "strict", + "python.analysis.exclude": ["api/migrations/[0-9]*.py"], + // Extensions - Python:black + "python.formatting.blackArgs": ["--line-length=120"], + "python.formatting.provider": "black", + // Extensions - Python:Flake8 + "python.linting.enabled": true, + "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" } diff --git a/mdrsclient/api/folder.py b/mdrsclient/api/folder.py index e124912..0c8f2c8 100644 --- a/mdrsclient/api/folder.py +++ b/mdrsclient/api/folder.py @@ -94,10 +94,10 @@ class FolderApi(BaseApi): self._raise_response_error(response) 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) 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) response = self.connection.post(url, data=data) self._raise_response_error(response) diff --git a/mdrsclient/commands/mv.py b/mdrsclient/commands/mv.py index 168abf4..df9ce09 100644 --- a/mdrsclient/commands/mv.py +++ b/mdrsclient/commands/mv.py @@ -1,15 +1,11 @@ -import dataclasses import os from argparse import Namespace from typing import Any from unicodedata import normalize -from pydantic import TypeAdapter - from mdrsclient.api import FileApi, FolderApi from mdrsclient.commands.base import BaseCommand from mdrsclient.exceptions import IllegalArgumentException -from mdrsclient.models import FolderSimple 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"Cannot move `{s_path}` to `{d_path}`: Folder not empty.") folder_api = FolderApi(connection) - if s_parent_folder.id != d_parent_folder.id: - folder_api.move(s_folder, d_parent_folder.id) - 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) + if s_parent_folder.id != d_parent_folder.id or d_basename != s_basename: + folder_api.move(s_folder, d_parent_folder.id, normalize("NFC", d_basename))