diff --git a/pyproject.toml b/pyproject.toml index a92ff6a89..96b2f1d73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,6 +77,8 @@ check-links = """ darglint = """ find . -name "*.py" \ -not -path "./src/dsp_tools/models/*" \ + -not -path "./src/dsp_tools/commands/xmlupload/models/*" \ + -not -path "./src/dsp_tools/commands/project/models/*" \ -not -path "./.git/*" \ | xargs poetry run darglint -v 2\ """ @@ -104,25 +106,24 @@ pythonpath = [".", "src", "test"] [tool.mypy] -ignore_missing_imports = true # TODO: deactivate this +ignore_missing_imports = true # TODO: deactivate this show_column_numbers = true strict = true exclude = [ - "src/dsp_tools/import_scripts", # TODO: activate this - "src/dsp_tools/models/group.py", # TODO: activate this - "src/dsp_tools/models/helpers.py ", # TODO: activate this - "src/dsp_tools/models/langstring.py", # TODO: activate this - "src/dsp_tools/models/listnode.py", # TODO: activate this - "src/dsp_tools/models/ontology.py", # TODO: activate this - "src/dsp_tools/models/permission.py", # TODO: activate this - "src/dsp_tools/models/project.py", # TODO: activate this - "src/dsp_tools/models/projectContext.py", # TODO: activate this - "src/dsp_tools/models/propertyclass.py", # TODO: activate this - "src/dsp_tools/models/resource.py", # TODO: activate this - "src/dsp_tools/models/resourceclass.py", # TODO: activate this - "src/dsp_tools/models/user.py", # TODO: activate this - "src/dsp_tools/models/value.py", # TODO: activate this - "src/dsp_tools/models/xmlresource.py", # TODO: activate this + "src/dsp_tools/commands/xmlupload/models/value.py", # TODO: activate this + "src/dsp_tools/commands/xmlupload/models/permission.py", # TODO: activate this + "src/dsp_tools/commands/xmlupload/models/xmlresource.py", # TODO: activate this + "src/dsp_tools/models/helpers.py", # TODO: activate this + "src/dsp_tools/models/langstring.py", # TODO: activate this + "src/dsp_tools/commands/project/models/group.py", # TODO: activate this + "src/dsp_tools/commands/project/models/listnode.py", # TODO: activate this + "src/dsp_tools/commands/project/models/ontology.py", # TODO: activate this + "src/dsp_tools/commands/project/models/project.py", # TODO: activate this + "src/dsp_tools/models/projectContext.py", # TODO: activate this + "src/dsp_tools/commands/project/models/propertyclass.py", # TODO: activate this + "src/dsp_tools/commands/project/models/resourceclass.py", # TODO: activate this + "src/dsp_tools/commands/project/models/user.py", # TODO: activate this + "src/dsp_tools/import_scripts", # TODO: activate this ] diff --git a/src/dsp_tools/__init__.py b/src/dsp_tools/__init__.py index e69de29bb..e63e9ad71 100644 --- a/src/dsp_tools/__init__.py +++ b/src/dsp_tools/__init__.py @@ -0,0 +1 @@ +from dsp_tools.commands import excel2xml diff --git a/src/dsp_tools/cli.py b/src/dsp_tools/cli.py index 06c99620f..dcead66a1 100644 --- a/src/dsp_tools/cli.py +++ b/src/dsp_tools/cli.py @@ -9,27 +9,27 @@ import regex -from dsp_tools.excel2xml import excel2xml -from dsp_tools.fast_xmlupload.process_files import process_files -from dsp_tools.fast_xmlupload.upload_files import upload_files -from dsp_tools.fast_xmlupload.upload_xml import fast_xmlupload +from dsp_tools.commands.excel2json.lists import excel2lists, validate_lists_section_with_schema +from dsp_tools.commands.excel2json.project import excel2json +from dsp_tools.commands.excel2json.properties import excel2properties +from dsp_tools.commands.excel2json.resources import excel2resources +from dsp_tools.commands.excel2xml import excel2xml +from dsp_tools.commands.fast_xmlupload.process_files import process_files +from dsp_tools.commands.fast_xmlupload.upload_files import upload_files +from dsp_tools.commands.fast_xmlupload.upload_xml import fast_xmlupload +from dsp_tools.commands.id2iri import id2iri +from dsp_tools.commands.project.create.project_create import create_project +from dsp_tools.commands.project.create.project_create_lists import create_lists +from dsp_tools.commands.project.create.project_validate import validate_project +from dsp_tools.commands.project.get import get_project +from dsp_tools.commands.rosetta import upload_rosetta +from dsp_tools.commands.start_stack import StackConfiguration, StackHandler +from dsp_tools.commands.template import generate_template_repo +from dsp_tools.commands.xmlupload.upload_config import DiagnosticsConfig, UploadConfig +from dsp_tools.commands.xmlupload.xmlupload import xmlupload from dsp_tools.models.exceptions import UserError from dsp_tools.utils.create_logger import get_logger -from dsp_tools.utils.excel2json.lists import excel2lists, validate_lists_section_with_schema -from dsp_tools.utils.excel2json.project import excel2json -from dsp_tools.utils.excel2json.properties import excel2properties -from dsp_tools.utils.excel2json.resources import excel2resources -from dsp_tools.utils.generate_templates import generate_template_repo -from dsp_tools.utils.id2iri import id2iri -from dsp_tools.utils.project_create import create_project -from dsp_tools.utils.project_create_lists import create_lists -from dsp_tools.utils.project_get import get_project -from dsp_tools.utils.project_validate import validate_project -from dsp_tools.utils.rosetta import upload_rosetta from dsp_tools.utils.shared import validate_xml_against_schema -from dsp_tools.utils.stack_handling import StackConfiguration, StackHandler -from dsp_tools.utils.xmlupload.upload_config import DiagnosticsConfig, UploadConfig -from dsp_tools.utils.xmlupload.xmlupload import xmlupload logger = get_logger(__name__) diff --git a/src/dsp_tools/commands/__init__.py b/src/dsp_tools/commands/__init__.py new file mode 100644 index 000000000..f71f9e255 --- /dev/null +++ b/src/dsp_tools/commands/__init__.py @@ -0,0 +1 @@ +from . import excel2xml diff --git a/src/dsp_tools/analyse_xml_data/__init__.py b/src/dsp_tools/commands/excel2json/__init__.py similarity index 100% rename from src/dsp_tools/analyse_xml_data/__init__.py rename to src/dsp_tools/commands/excel2json/__init__.py diff --git a/src/dsp_tools/utils/excel2json/lists.py b/src/dsp_tools/commands/excel2json/lists.py similarity index 100% rename from src/dsp_tools/utils/excel2json/lists.py rename to src/dsp_tools/commands/excel2json/lists.py diff --git a/src/dsp_tools/utils/excel2json/project.py b/src/dsp_tools/commands/excel2json/project.py similarity index 96% rename from src/dsp_tools/utils/excel2json/project.py rename to src/dsp_tools/commands/excel2json/project.py index 845ceb247..c31e1a13d 100644 --- a/src/dsp_tools/utils/excel2json/project.py +++ b/src/dsp_tools/commands/excel2json/project.py @@ -3,10 +3,10 @@ import regex +from dsp_tools.commands.excel2json.lists import excel2lists +from dsp_tools.commands.excel2json.properties import excel2properties +from dsp_tools.commands.excel2json.resources import excel2resources from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.excel2json.lists import excel2lists -from dsp_tools.utils.excel2json.properties import excel2properties -from dsp_tools.utils.excel2json.resources import excel2resources def excel2json( diff --git a/src/dsp_tools/utils/excel2json/properties.py b/src/dsp_tools/commands/excel2json/properties.py similarity index 99% rename from src/dsp_tools/utils/excel2json/properties.py rename to src/dsp_tools/commands/excel2json/properties.py index 40a335164..81aec19db 100644 --- a/src/dsp_tools/utils/excel2json/properties.py +++ b/src/dsp_tools/commands/excel2json/properties.py @@ -9,7 +9,7 @@ import pandas as pd import regex -import dsp_tools.utils.excel2json.utils as utl +import dsp_tools.commands.excel2json.utils as utl from dsp_tools.models.exceptions import UserError languages = ["en", "de", "fr", "it", "rm"] diff --git a/src/dsp_tools/utils/excel2json/resources.py b/src/dsp_tools/commands/excel2json/resources.py similarity index 99% rename from src/dsp_tools/utils/excel2json/resources.py rename to src/dsp_tools/commands/excel2json/resources.py index 8a6707e56..79622a951 100644 --- a/src/dsp_tools/utils/excel2json/resources.py +++ b/src/dsp_tools/commands/excel2json/resources.py @@ -8,7 +8,7 @@ import pandas as pd import regex -import dsp_tools.utils.excel2json.utils as utl +import dsp_tools.commands.excel2json.utils as utl from dsp_tools.models.exceptions import UserError from dsp_tools.utils.shared import check_notna, prepare_dataframe diff --git a/src/dsp_tools/utils/excel2json/utils.py b/src/dsp_tools/commands/excel2json/utils.py similarity index 100% rename from src/dsp_tools/utils/excel2json/utils.py rename to src/dsp_tools/commands/excel2json/utils.py diff --git a/src/dsp_tools/excel2xml.py b/src/dsp_tools/commands/excel2xml.py similarity index 99% rename from src/dsp_tools/excel2xml.py rename to src/dsp_tools/commands/excel2xml.py index aafab35f8..2d0de44e9 100644 --- a/src/dsp_tools/excel2xml.py +++ b/src/dsp_tools/commands/excel2xml.py @@ -17,6 +17,7 @@ from lxml import etree from lxml.builder import E # pylint: disable=no-name-in-module +from dsp_tools.commands.xmlupload.models.value import UriValue from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import DateTimeStamp @@ -25,7 +26,6 @@ # doing this requires silencing the corresponding pylint warning # (see https://pylint.readthedocs.io/en/latest/user_guide/messages/convention/useless-import-alias.html) from dsp_tools.models.propertyelement import PropertyElement as PropertyElement # pylint: disable=useless-import-alias -from dsp_tools.models.value import UriValue from dsp_tools.utils.shared import check_notna as check_notna # pylint: disable=useless-import-alias from dsp_tools.utils.shared import simplify_name as simplify_name # pylint: disable=useless-import-alias from dsp_tools.utils.shared import validate_xml_against_schema diff --git a/src/dsp_tools/connection/__init__.py b/src/dsp_tools/commands/fast_xmlupload/__init__.py similarity index 100% rename from src/dsp_tools/connection/__init__.py rename to src/dsp_tools/commands/fast_xmlupload/__init__.py diff --git a/src/dsp_tools/fast_xmlupload/process_files.py b/src/dsp_tools/commands/fast_xmlupload/process_files.py similarity index 100% rename from src/dsp_tools/fast_xmlupload/process_files.py rename to src/dsp_tools/commands/fast_xmlupload/process_files.py diff --git a/src/dsp_tools/fast_xmlupload/upload_files.py b/src/dsp_tools/commands/fast_xmlupload/upload_files.py similarity index 99% rename from src/dsp_tools/fast_xmlupload/upload_files.py rename to src/dsp_tools/commands/fast_xmlupload/upload_files.py index 4fea98e04..40e2cb459 100644 --- a/src/dsp_tools/fast_xmlupload/upload_files.py +++ b/src/dsp_tools/commands/fast_xmlupload/upload_files.py @@ -10,8 +10,8 @@ from regex import regex from requests import JSONDecodeError -from dsp_tools.connection.connection import Connection from dsp_tools.models.exceptions import UserError +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.shared import login diff --git a/src/dsp_tools/fast_xmlupload/upload_xml.py b/src/dsp_tools/commands/fast_xmlupload/upload_xml.py similarity index 95% rename from src/dsp_tools/fast_xmlupload/upload_xml.py rename to src/dsp_tools/commands/fast_xmlupload/upload_xml.py index 2d950982d..d182fba1a 100644 --- a/src/dsp_tools/fast_xmlupload/upload_xml.py +++ b/src/dsp_tools/commands/fast_xmlupload/upload_xml.py @@ -5,11 +5,11 @@ from lxml import etree -from dsp_tools.fast_xmlupload.upload_files import get_pkl_files +from dsp_tools.commands.fast_xmlupload.upload_files import get_pkl_files +from dsp_tools.commands.xmlupload.upload_config import UploadConfig +from dsp_tools.commands.xmlupload.xmlupload import xmlupload from dsp_tools.models.exceptions import UserError from dsp_tools.utils.create_logger import get_logger -from dsp_tools.utils.xmlupload.upload_config import UploadConfig -from dsp_tools.utils.xmlupload.xmlupload import xmlupload logger = get_logger(__name__) diff --git a/src/dsp_tools/utils/id2iri.py b/src/dsp_tools/commands/id2iri.py similarity index 100% rename from src/dsp_tools/utils/id2iri.py rename to src/dsp_tools/commands/id2iri.py diff --git a/src/dsp_tools/fast_xmlupload/__init__.py b/src/dsp_tools/commands/project/__init__.py similarity index 100% rename from src/dsp_tools/fast_xmlupload/__init__.py rename to src/dsp_tools/commands/project/__init__.py diff --git a/src/dsp_tools/utils/excel2json/__init__.py b/src/dsp_tools/commands/project/create/__init__.py similarity index 100% rename from src/dsp_tools/utils/excel2json/__init__.py rename to src/dsp_tools/commands/project/create/__init__.py diff --git a/src/dsp_tools/utils/project_create.py b/src/dsp_tools/commands/project/create/project_create.py similarity index 98% rename from src/dsp_tools/utils/project_create.py rename to src/dsp_tools/commands/project/create/project_create.py index b43b641ff..bdd8e93ce 100644 --- a/src/dsp_tools/utils/project_create.py +++ b/src/dsp_tools/commands/project/create/project_create.py @@ -5,20 +5,20 @@ import regex -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.excel2json.lists import expand_lists_from_excel +from dsp_tools.commands.project.create.project_create_lists import create_lists_on_server +from dsp_tools.commands.project.create.project_validate import validate_project +from dsp_tools.commands.project.models.group import Group +from dsp_tools.commands.project.models.ontology import Ontology +from dsp_tools.commands.project.models.project import Project +from dsp_tools.commands.project.models.propertyclass import PropertyClass +from dsp_tools.commands.project.models.resourceclass import ResourceClass +from dsp_tools.commands.project.models.user import User from dsp_tools.models.exceptions import BaseError, UserError -from dsp_tools.models.group import Group from dsp_tools.models.helpers import Cardinality, Context, DateTimeStamp from dsp_tools.models.langstring import LangString -from dsp_tools.models.ontology import Ontology -from dsp_tools.models.project import Project -from dsp_tools.models.propertyclass import PropertyClass -from dsp_tools.models.resourceclass import ResourceClass -from dsp_tools.models.user import User +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger -from dsp_tools.utils.excel2json.lists import expand_lists_from_excel -from dsp_tools.utils.project_create_lists import create_lists_on_server -from dsp_tools.utils.project_validate import validate_project from dsp_tools.utils.shared import login, parse_json_input, try_network_action logger = get_logger(__name__) diff --git a/src/dsp_tools/utils/project_create_lists.py b/src/dsp_tools/commands/project/create/project_create_lists.py similarity index 96% rename from src/dsp_tools/utils/project_create_lists.py rename to src/dsp_tools/commands/project/create/project_create_lists.py index 59d4bf5a9..330cd6045 100644 --- a/src/dsp_tools/utils/project_create_lists.py +++ b/src/dsp_tools/commands/project/create/project_create_lists.py @@ -1,12 +1,12 @@ from typing import Any, Optional, Union -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.excel2json.lists import expand_lists_from_excel +from dsp_tools.commands.project.create.project_validate import validate_project +from dsp_tools.commands.project.models.listnode import ListNode +from dsp_tools.commands.project.models.project import Project from dsp_tools.models.exceptions import BaseError, UserError -from dsp_tools.models.listnode import ListNode -from dsp_tools.models.project import Project +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger -from dsp_tools.utils.excel2json.lists import expand_lists_from_excel -from dsp_tools.utils.project_validate import validate_project from dsp_tools.utils.shared import login, parse_json_input, try_network_action logger = get_logger(__name__) diff --git a/src/dsp_tools/utils/project_validate.py b/src/dsp_tools/commands/project/create/project_validate.py similarity index 99% rename from src/dsp_tools/utils/project_validate.py rename to src/dsp_tools/commands/project/create/project_validate.py index e3bde8871..6232641f2 100644 --- a/src/dsp_tools/utils/project_validate.py +++ b/src/dsp_tools/commands/project/create/project_validate.py @@ -9,8 +9,8 @@ import networkx as nx import regex +from dsp_tools.commands.excel2json.lists import expand_lists_from_excel from dsp_tools.models.exceptions import BaseError -from dsp_tools.utils.excel2json.lists import expand_lists_from_excel def _check_for_duplicate_names(project_definition: dict[str, Any]) -> bool: diff --git a/src/dsp_tools/utils/project_get.py b/src/dsp_tools/commands/project/get.py similarity index 92% rename from src/dsp_tools/utils/project_get.py rename to src/dsp_tools/commands/project/get.py index e785bb54f..01f166071 100644 --- a/src/dsp_tools/utils/project_get.py +++ b/src/dsp_tools/commands/project/get.py @@ -4,13 +4,13 @@ import regex -from dsp_tools.connection.connection_live import ConnectionLive +from dsp_tools.commands.project.models.group import Group +from dsp_tools.commands.project.models.listnode import ListNode +from dsp_tools.commands.project.models.ontology import Ontology +from dsp_tools.commands.project.models.project import Project +from dsp_tools.commands.project.models.user import User from dsp_tools.models.exceptions import BaseError -from dsp_tools.models.group import Group -from dsp_tools.models.listnode import ListNode -from dsp_tools.models.ontology import Ontology -from dsp_tools.models.project import Project -from dsp_tools.models.user import User +from dsp_tools.utils.connection_live import ConnectionLive def get_project( diff --git a/src/dsp_tools/utils/xmlupload/__init__.py b/src/dsp_tools/commands/project/models/__init__.py similarity index 100% rename from src/dsp_tools/utils/xmlupload/__init__.py rename to src/dsp_tools/commands/project/models/__init__.py diff --git a/src/dsp_tools/models/group.py b/src/dsp_tools/commands/project/models/group.py similarity index 98% rename from src/dsp_tools/models/group.py rename to src/dsp_tools/commands/project/models/group.py index 7f24c2607..dda83f3a1 100644 --- a/src/dsp_tools/models/group.py +++ b/src/dsp_tools/commands/project/models/group.py @@ -29,12 +29,12 @@ from typing import Any, Optional, Union from urllib.parse import quote_plus -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.project.models.model import Model +from dsp_tools.commands.project.models.project import Project from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import Actions from dsp_tools.models.langstring import LangString -from dsp_tools.models.model import Model -from dsp_tools.models.project import Project +from dsp_tools.utils.connection import Connection class Group(Model): # pylint: disable=too-many-instance-attributes diff --git a/src/dsp_tools/models/listnode.py b/src/dsp_tools/commands/project/models/listnode.py similarity index 98% rename from src/dsp_tools/models/listnode.py rename to src/dsp_tools/commands/project/models/listnode.py index d0a64bf82..94217942a 100644 --- a/src/dsp_tools/models/listnode.py +++ b/src/dsp_tools/commands/project/models/listnode.py @@ -28,13 +28,13 @@ from typing import Any, Optional, Union from urllib.parse import quote_plus -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.project.models.model import Model +from dsp_tools.commands.project.models.project import Project +from dsp_tools.commands.project.models.set_encoder import SetEncoder from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import Actions from dsp_tools.models.langstring import LangString, Languages -from dsp_tools.models.model import Model -from dsp_tools.models.project import Project -from dsp_tools.models.set_encoder import SetEncoder +from dsp_tools.utils.connection import Connection def list_creator(con: Connection, project: Project, parent_node: "ListNode", nodes: list[dict]) -> list["ListNode"]: diff --git a/src/dsp_tools/models/model.py b/src/dsp_tools/commands/project/models/model.py similarity index 81% rename from src/dsp_tools/models/model.py rename to src/dsp_tools/commands/project/models/model.py index 2938354a6..5cc20f8e0 100644 --- a/src/dsp_tools/models/model.py +++ b/src/dsp_tools/commands/project/models/model.py @@ -1,4 +1,4 @@ -from dsp_tools.connection.connection import Connection +from dsp_tools.utils.connection import Connection class Model: # pylint: disable=too-few-public-methods diff --git a/src/dsp_tools/models/ontology.py b/src/dsp_tools/commands/project/models/ontology.py similarity index 97% rename from src/dsp_tools/models/ontology.py rename to src/dsp_tools/commands/project/models/ontology.py index bd416e06a..de5e08ddd 100644 --- a/src/dsp_tools/models/ontology.py +++ b/src/dsp_tools/commands/project/models/ontology.py @@ -35,14 +35,14 @@ import regex -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.project.models.model import Model +from dsp_tools.commands.project.models.project import Project +from dsp_tools.commands.project.models.propertyclass import PropertyClass +from dsp_tools.commands.project.models.resourceclass import ResourceClass +from dsp_tools.commands.project.models.set_encoder import SetEncoder from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import Actions, Context, DateTimeStamp, WithId -from dsp_tools.models.model import Model -from dsp_tools.models.project import Project -from dsp_tools.models.propertyclass import PropertyClass -from dsp_tools.models.resourceclass import ResourceClass -from dsp_tools.models.set_encoder import SetEncoder +from dsp_tools.utils.connection import Connection class Ontology(Model): # pylint: disable=too-many-instance-attributes diff --git a/src/dsp_tools/models/project.py b/src/dsp_tools/commands/project/models/project.py similarity index 98% rename from src/dsp_tools/models/project.py rename to src/dsp_tools/commands/project/models/project.py index f9f83d008..8e73d5728 100644 --- a/src/dsp_tools/models/project.py +++ b/src/dsp_tools/commands/project/models/project.py @@ -30,12 +30,12 @@ from typing import Any, Optional, Union from urllib.parse import quote_plus -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.project.models.model import Model +from dsp_tools.commands.project.models.set_encoder import SetEncoder from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import Actions from dsp_tools.models.langstring import LangString, Languages -from dsp_tools.models.model import Model -from dsp_tools.models.set_encoder import SetEncoder +from dsp_tools.utils.connection import Connection class Project(Model): # pylint: disable=too-many-instance-attributes,too-many-public-methods diff --git a/src/dsp_tools/models/propertyclass.py b/src/dsp_tools/commands/project/models/propertyclass.py similarity index 98% rename from src/dsp_tools/models/propertyclass.py rename to src/dsp_tools/commands/project/models/propertyclass.py index ed4d7463e..7f4fca76d 100644 --- a/src/dsp_tools/models/propertyclass.py +++ b/src/dsp_tools/commands/project/models/propertyclass.py @@ -6,13 +6,13 @@ import regex -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.project.models.listnode import ListNode +from dsp_tools.commands.project.models.model import Model +from dsp_tools.commands.project.models.set_encoder import SetEncoder from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import Actions, Context, DateTimeStamp, WithId from dsp_tools.models.langstring import LangString, Languages -from dsp_tools.models.listnode import ListNode -from dsp_tools.models.model import Model -from dsp_tools.models.set_encoder import SetEncoder +from dsp_tools.utils.connection import Connection class PropertyClass(Model): # pylint: disable=too-many-instance-attributes,too-many-public-methods diff --git a/src/dsp_tools/models/resourceclass.py b/src/dsp_tools/commands/project/models/resourceclass.py similarity index 99% rename from src/dsp_tools/models/resourceclass.py rename to src/dsp_tools/commands/project/models/resourceclass.py index 2ff9e882e..ae96d8035 100644 --- a/src/dsp_tools/models/resourceclass.py +++ b/src/dsp_tools/commands/project/models/resourceclass.py @@ -16,12 +16,12 @@ import regex -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.project.models.model import Model +from dsp_tools.commands.project.models.set_encoder import SetEncoder from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import Actions, Cardinality, Context, DateTimeStamp from dsp_tools.models.langstring import LangString, Languages -from dsp_tools.models.model import Model -from dsp_tools.models.set_encoder import SetEncoder +from dsp_tools.utils.connection import Connection class HasProperty(Model): diff --git a/src/dsp_tools/models/set_encoder.py b/src/dsp_tools/commands/project/models/set_encoder.py similarity index 100% rename from src/dsp_tools/models/set_encoder.py rename to src/dsp_tools/commands/project/models/set_encoder.py diff --git a/src/dsp_tools/models/user.py b/src/dsp_tools/commands/project/models/user.py similarity index 99% rename from src/dsp_tools/models/user.py rename to src/dsp_tools/commands/project/models/user.py index 34b82f05a..2b7ed4009 100644 --- a/src/dsp_tools/models/user.py +++ b/src/dsp_tools/commands/project/models/user.py @@ -29,13 +29,13 @@ from typing import Any, Optional, Union from urllib.parse import quote_plus -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.project.models.group import Group +from dsp_tools.commands.project.models.model import Model +from dsp_tools.commands.project.models.project import Project from dsp_tools.models.exceptions import BaseError -from dsp_tools.models.group import Group from dsp_tools.models.helpers import Actions from dsp_tools.models.langstring import Languages -from dsp_tools.models.model import Model -from dsp_tools.models.project import Project +from dsp_tools.utils.connection import Connection class User(Model): # pylint: disable=too-many-instance-attributes,too-many-public-methods diff --git a/src/dsp_tools/utils/rosetta.py b/src/dsp_tools/commands/rosetta.py similarity index 95% rename from src/dsp_tools/utils/rosetta.py rename to src/dsp_tools/commands/rosetta.py index b28086a06..9effbf617 100644 --- a/src/dsp_tools/utils/rosetta.py +++ b/src/dsp_tools/commands/rosetta.py @@ -2,10 +2,10 @@ import subprocess from pathlib import Path +from dsp_tools.commands.project.create.project_create import create_project +from dsp_tools.commands.xmlupload.upload_config import UploadConfig +from dsp_tools.commands.xmlupload.xmlupload import xmlupload from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.project_create import create_project -from dsp_tools.utils.xmlupload.upload_config import UploadConfig -from dsp_tools.utils.xmlupload.xmlupload import xmlupload def _update_possibly_existing_repo(rosetta_folder: Path) -> bool: diff --git a/src/dsp_tools/utils/stack_handling.py b/src/dsp_tools/commands/start_stack.py similarity index 100% rename from src/dsp_tools/utils/stack_handling.py rename to src/dsp_tools/commands/start_stack.py diff --git a/src/dsp_tools/utils/generate_templates.py b/src/dsp_tools/commands/template.py similarity index 100% rename from src/dsp_tools/utils/generate_templates.py rename to src/dsp_tools/commands/template.py diff --git a/src/dsp_tools/utils/xmlupload/stash/__init__.py b/src/dsp_tools/commands/xmlupload/__init__.py similarity index 100% rename from src/dsp_tools/utils/xmlupload/stash/__init__.py rename to src/dsp_tools/commands/xmlupload/__init__.py diff --git a/test/e2e/xmlupload/__init__.py b/src/dsp_tools/commands/xmlupload/analyse_xml_data/__init__.py similarity index 100% rename from test/e2e/xmlupload/__init__.py rename to src/dsp_tools/commands/xmlupload/analyse_xml_data/__init__.py diff --git a/src/dsp_tools/analyse_xml_data/construct_and_analyze_graph.py b/src/dsp_tools/commands/xmlupload/analyse_xml_data/construct_and_analyze_graph.py similarity index 99% rename from src/dsp_tools/analyse_xml_data/construct_and_analyze_graph.py rename to src/dsp_tools/commands/xmlupload/analyse_xml_data/construct_and_analyze_graph.py index 2c4aabe2f..9a01547a4 100644 --- a/src/dsp_tools/analyse_xml_data/construct_and_analyze_graph.py +++ b/src/dsp_tools/commands/xmlupload/analyse_xml_data/construct_and_analyze_graph.py @@ -6,7 +6,7 @@ import rustworkx as rx from lxml import etree -from dsp_tools.analyse_xml_data.models import Cost, Edge, ResptrLink, XMLLink +from dsp_tools.commands.xmlupload.analyse_xml_data.models import Cost, Edge, ResptrLink, XMLLink def create_info_from_xml_for_graph( diff --git a/src/dsp_tools/analyse_xml_data/models.py b/src/dsp_tools/commands/xmlupload/analyse_xml_data/models.py similarity index 100% rename from src/dsp_tools/analyse_xml_data/models.py rename to src/dsp_tools/commands/xmlupload/analyse_xml_data/models.py diff --git a/src/dsp_tools/utils/xmlupload/ark2iri.py b/src/dsp_tools/commands/xmlupload/ark2iri.py similarity index 100% rename from src/dsp_tools/utils/xmlupload/ark2iri.py rename to src/dsp_tools/commands/xmlupload/ark2iri.py diff --git a/src/dsp_tools/utils/xmlupload/iri_resolver.py b/src/dsp_tools/commands/xmlupload/iri_resolver.py similarity index 100% rename from src/dsp_tools/utils/xmlupload/iri_resolver.py rename to src/dsp_tools/commands/xmlupload/iri_resolver.py diff --git a/src/dsp_tools/utils/xmlupload/list_client.py b/src/dsp_tools/commands/xmlupload/list_client.py similarity index 98% rename from src/dsp_tools/utils/xmlupload/list_client.py rename to src/dsp_tools/commands/xmlupload/list_client.py index d65e19fed..f5b197207 100644 --- a/src/dsp_tools/utils/xmlupload/list_client.py +++ b/src/dsp_tools/commands/xmlupload/list_client.py @@ -4,7 +4,7 @@ from typing import Any, Iterable, Protocol from urllib.parse import quote_plus -from dsp_tools.connection.connection import Connection +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.shared import try_network_action diff --git a/test/unittests/helpers/__init__.py b/src/dsp_tools/commands/xmlupload/models/__init__.py similarity index 100% rename from test/unittests/helpers/__init__.py rename to src/dsp_tools/commands/xmlupload/models/__init__.py diff --git a/src/dsp_tools/models/permission.py b/src/dsp_tools/commands/xmlupload/models/permission.py similarity index 100% rename from src/dsp_tools/models/permission.py rename to src/dsp_tools/commands/xmlupload/models/permission.py diff --git a/src/dsp_tools/models/sipi.py b/src/dsp_tools/commands/xmlupload/models/sipi.py similarity index 98% rename from src/dsp_tools/models/sipi.py rename to src/dsp_tools/commands/xmlupload/models/sipi.py index 0f8e4e69b..f4487a234 100644 --- a/src/dsp_tools/models/sipi.py +++ b/src/dsp_tools/commands/xmlupload/models/sipi.py @@ -7,7 +7,7 @@ import requests -from dsp_tools.connection.connection_live import check_for_api_error +from dsp_tools.utils.connection_live import check_for_api_error @dataclass(frozen=True) diff --git a/src/dsp_tools/models/value.py b/src/dsp_tools/commands/xmlupload/models/value.py similarity index 99% rename from src/dsp_tools/models/value.py rename to src/dsp_tools/commands/xmlupload/models/value.py index e07ff246f..1d0afbc65 100644 --- a/src/dsp_tools/models/value.py +++ b/src/dsp_tools/commands/xmlupload/models/value.py @@ -6,12 +6,12 @@ import regex +from dsp_tools.commands.project.models.listnode import ListNode +from dsp_tools.commands.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.models.permission import Permissions, PermissionValue from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import Actions, IriTest from dsp_tools.models.langstring import LangString -from dsp_tools.models.listnode import ListNode -from dsp_tools.models.permission import Permissions, PermissionValue -from dsp_tools.utils.xmlupload.iri_resolver import IriResolver @dataclass diff --git a/src/dsp_tools/models/xmlallow.py b/src/dsp_tools/commands/xmlupload/models/xmlallow.py similarity index 96% rename from src/dsp_tools/models/xmlallow.py rename to src/dsp_tools/commands/xmlupload/models/xmlallow.py index fdc2a1f49..c13a395ab 100644 --- a/src/dsp_tools/models/xmlallow.py +++ b/src/dsp_tools/commands/xmlupload/models/xmlallow.py @@ -1,7 +1,7 @@ from lxml import etree +from dsp_tools.commands.xmlupload.models.permission import PermissionValue from dsp_tools.models.exceptions import XmlError -from dsp_tools.models.permission import PermissionValue from dsp_tools.models.projectContext import ProjectContext diff --git a/src/dsp_tools/models/xmlbitstream.py b/src/dsp_tools/commands/xmlupload/models/xmlbitstream.py similarity index 100% rename from src/dsp_tools/models/xmlbitstream.py rename to src/dsp_tools/commands/xmlupload/models/xmlbitstream.py diff --git a/src/dsp_tools/models/xmlpermission.py b/src/dsp_tools/commands/xmlupload/models/xmlpermission.py similarity index 91% rename from src/dsp_tools/models/xmlpermission.py rename to src/dsp_tools/commands/xmlupload/models/xmlpermission.py index 5649e5f2b..0d498e5bc 100644 --- a/src/dsp_tools/models/xmlpermission.py +++ b/src/dsp_tools/commands/xmlupload/models/xmlpermission.py @@ -1,8 +1,8 @@ from lxml import etree -from dsp_tools.models.permission import Permissions +from dsp_tools.commands.xmlupload.models.permission import Permissions +from dsp_tools.commands.xmlupload.models.xmlallow import XmlAllow from dsp_tools.models.projectContext import ProjectContext -from dsp_tools.models.xmlallow import XmlAllow class XmlPermission: diff --git a/src/dsp_tools/models/xmlproperty.py b/src/dsp_tools/commands/xmlupload/models/xmlproperty.py similarity index 96% rename from src/dsp_tools/models/xmlproperty.py rename to src/dsp_tools/commands/xmlupload/models/xmlproperty.py index 51fa7089d..b38ba6050 100644 --- a/src/dsp_tools/models/xmlproperty.py +++ b/src/dsp_tools/commands/xmlupload/models/xmlproperty.py @@ -1,7 +1,7 @@ from lxml import etree +from dsp_tools.commands.xmlupload.models.xmlvalue import XMLValue from dsp_tools.models.exceptions import XmlError -from dsp_tools.models.xmlvalue import XMLValue class XMLProperty: # pylint: disable=too-few-public-methods diff --git a/src/dsp_tools/models/xmlresource.py b/src/dsp_tools/commands/xmlupload/models/xmlresource.py similarity index 96% rename from src/dsp_tools/models/xmlresource.py rename to src/dsp_tools/commands/xmlupload/models/xmlresource.py index b80390607..e7e680100 100644 --- a/src/dsp_tools/models/xmlresource.py +++ b/src/dsp_tools/commands/xmlupload/models/xmlresource.py @@ -4,12 +4,12 @@ import regex from lxml import etree +from dsp_tools.commands.xmlupload.models.permission import Permissions +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml +from dsp_tools.commands.xmlupload.models.xmlbitstream import XMLBitstream +from dsp_tools.commands.xmlupload.models.xmlproperty import XMLProperty from dsp_tools.models.exceptions import BaseError from dsp_tools.models.helpers import DateTimeStamp -from dsp_tools.models.permission import Permissions -from dsp_tools.models.value import KnoraStandoffXml -from dsp_tools.models.xmlbitstream import XMLBitstream -from dsp_tools.models.xmlproperty import XMLProperty @dataclass(frozen=True) diff --git a/src/dsp_tools/models/xmlvalue.py b/src/dsp_tools/commands/xmlupload/models/xmlvalue.py similarity index 98% rename from src/dsp_tools/models/xmlvalue.py rename to src/dsp_tools/commands/xmlupload/models/xmlvalue.py index abea5bcb7..d9202beb4 100644 --- a/src/dsp_tools/models/xmlvalue.py +++ b/src/dsp_tools/commands/xmlupload/models/xmlvalue.py @@ -3,7 +3,7 @@ import regex from lxml import etree -from dsp_tools.models.value import KnoraStandoffXml +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml class XMLValue: # pylint: disable=too-few-public-methods diff --git a/src/dsp_tools/utils/xmlupload/project_client.py b/src/dsp_tools/commands/xmlupload/project_client.py similarity index 98% rename from src/dsp_tools/utils/xmlupload/project_client.py rename to src/dsp_tools/commands/xmlupload/project_client.py index 63f09c90a..55d82c732 100644 --- a/src/dsp_tools/utils/xmlupload/project_client.py +++ b/src/dsp_tools/commands/xmlupload/project_client.py @@ -2,8 +2,8 @@ from typing import Any, Protocol from urllib.parse import quote_plus -from dsp_tools.connection.connection import Connection from dsp_tools.models.exceptions import BaseError, UserError +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.shared import try_network_action diff --git a/src/dsp_tools/utils/xmlupload/read_validate_xml_file.py b/src/dsp_tools/commands/xmlupload/read_validate_xml_file.py similarity index 100% rename from src/dsp_tools/utils/xmlupload/read_validate_xml_file.py rename to src/dsp_tools/commands/xmlupload/read_validate_xml_file.py diff --git a/src/dsp_tools/utils/xmlupload/resource_create_client.py b/src/dsp_tools/commands/xmlupload/resource_create_client.py similarity index 95% rename from src/dsp_tools/utils/xmlupload/resource_create_client.py rename to src/dsp_tools/commands/xmlupload/resource_create_client.py index e3d2c312c..d1f0d9ea0 100644 --- a/src/dsp_tools/utils/xmlupload/resource_create_client.py +++ b/src/dsp_tools/commands/xmlupload/resource_create_client.py @@ -3,19 +3,19 @@ from pathlib import Path from typing import Any, assert_never -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.xmlupload.ark2iri import convert_ark_v0_to_resource_iri +from dsp_tools.commands.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.models.permission import Permissions +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml +from dsp_tools.commands.xmlupload.models.xmlproperty import XMLProperty +from dsp_tools.commands.xmlupload.models.xmlresource import BitstreamInfo, XMLResource +from dsp_tools.commands.xmlupload.models.xmlvalue import XMLValue from dsp_tools.models.exceptions import BaseError, UserError -from dsp_tools.models.permission import Permissions -from dsp_tools.models.value import KnoraStandoffXml -from dsp_tools.models.xmlproperty import XMLProperty -from dsp_tools.models.xmlresource import BitstreamInfo, XMLResource -from dsp_tools.models.xmlvalue import XMLValue +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.date_util import parse_date_string from dsp_tools.utils.iri_util import is_resource_iri from dsp_tools.utils.shared import try_network_action -from dsp_tools.utils.xmlupload.ark2iri import convert_ark_v0_to_resource_iri -from dsp_tools.utils.xmlupload.iri_resolver import IriResolver logger = get_logger(__name__) diff --git a/src/dsp_tools/utils/xmlupload/resource_multimedia.py b/src/dsp_tools/commands/xmlupload/resource_multimedia.py similarity index 91% rename from src/dsp_tools/utils/xmlupload/resource_multimedia.py rename to src/dsp_tools/commands/xmlupload/resource_multimedia.py index 5ad0f8618..1bf41450c 100644 --- a/src/dsp_tools/utils/xmlupload/resource_multimedia.py +++ b/src/dsp_tools/commands/xmlupload/resource_multimedia.py @@ -4,11 +4,11 @@ from pathlib import Path from typing import Any, Optional +from dsp_tools.commands.xmlupload.models.permission import Permissions +from dsp_tools.commands.xmlupload.models.sipi import Sipi +from dsp_tools.commands.xmlupload.models.xmlbitstream import XMLBitstream +from dsp_tools.commands.xmlupload.models.xmlresource import BitstreamInfo, XMLResource from dsp_tools.models.exceptions import BaseError -from dsp_tools.models.permission import Permissions -from dsp_tools.models.sipi import Sipi -from dsp_tools.models.xmlbitstream import XMLBitstream -from dsp_tools.models.xmlresource import BitstreamInfo, XMLResource from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.shared import try_network_action diff --git a/test/unittests/test_analyse_xml_data/__init__.py b/src/dsp_tools/commands/xmlupload/stash/__init__.py similarity index 100% rename from test/unittests/test_analyse_xml_data/__init__.py rename to src/dsp_tools/commands/xmlupload/stash/__init__.py diff --git a/src/dsp_tools/utils/xmlupload/stash/stash_models.py b/src/dsp_tools/commands/xmlupload/stash/stash_models.py similarity index 97% rename from src/dsp_tools/utils/xmlupload/stash/stash_models.py rename to src/dsp_tools/commands/xmlupload/stash/stash_models.py index 5165295b8..9ef698a66 100644 --- a/src/dsp_tools/utils/xmlupload/stash/stash_models.py +++ b/src/dsp_tools/commands/xmlupload/stash/stash_models.py @@ -3,7 +3,7 @@ from dataclasses import dataclass from itertools import groupby -from dsp_tools.models.value import KnoraStandoffXml +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml @dataclass(frozen=True) diff --git a/src/dsp_tools/utils/xmlupload/stash_circular_references.py b/src/dsp_tools/commands/xmlupload/stash_circular_references.py similarity index 91% rename from src/dsp_tools/utils/xmlupload/stash_circular_references.py rename to src/dsp_tools/commands/xmlupload/stash_circular_references.py index df04a35d4..404a7eac7 100644 --- a/src/dsp_tools/utils/xmlupload/stash_circular_references.py +++ b/src/dsp_tools/commands/xmlupload/stash_circular_references.py @@ -5,23 +5,23 @@ from lxml import etree -from dsp_tools.analyse_xml_data.construct_and_analyze_graph import ( +from dsp_tools.commands.xmlupload.analyse_xml_data.construct_and_analyze_graph import ( create_info_from_xml_for_graph, generate_upload_order, make_graph, ) -from dsp_tools.models.permission import Permissions -from dsp_tools.models.value import KnoraStandoffXml -from dsp_tools.models.xmlproperty import XMLProperty -from dsp_tools.models.xmlresource import XMLResource -from dsp_tools.utils.create_logger import get_logger -from dsp_tools.utils.xmlupload.stash.stash_models import ( +from dsp_tools.commands.xmlupload.models.permission import Permissions +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml +from dsp_tools.commands.xmlupload.models.xmlproperty import XMLProperty +from dsp_tools.commands.xmlupload.models.xmlresource import XMLResource +from dsp_tools.commands.xmlupload.stash.stash_models import ( LinkValueStash, LinkValueStashItem, StandoffStash, StandoffStashItem, Stash, ) +from dsp_tools.utils.create_logger import get_logger logger = get_logger(__name__) diff --git a/src/dsp_tools/utils/xmlupload/upload_config.py b/src/dsp_tools/commands/xmlupload/upload_config.py similarity index 100% rename from src/dsp_tools/utils/xmlupload/upload_config.py rename to src/dsp_tools/commands/xmlupload/upload_config.py diff --git a/src/dsp_tools/utils/xmlupload/upload_stashed_resptr_props.py b/src/dsp_tools/commands/xmlupload/upload_stashed_resptr_props.py similarity index 95% rename from src/dsp_tools/utils/xmlupload/upload_stashed_resptr_props.py rename to src/dsp_tools/commands/xmlupload/upload_stashed_resptr_props.py index 221f250ae..23ce5b7f9 100644 --- a/src/dsp_tools/utils/xmlupload/upload_stashed_resptr_props.py +++ b/src/dsp_tools/commands/xmlupload/upload_stashed_resptr_props.py @@ -3,12 +3,12 @@ import json from datetime import datetime -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.stash.stash_models import LinkValueStash, LinkValueStashItem from dsp_tools.models.exceptions import BaseError +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.shared import try_network_action -from dsp_tools.utils.xmlupload.iri_resolver import IriResolver -from dsp_tools.utils.xmlupload.stash.stash_models import LinkValueStash, LinkValueStashItem logger = get_logger(__name__) diff --git a/src/dsp_tools/utils/xmlupload/upload_stashed_xml_texts.py b/src/dsp_tools/commands/xmlupload/upload_stashed_xml_texts.py similarity index 96% rename from src/dsp_tools/utils/xmlupload/upload_stashed_xml_texts.py rename to src/dsp_tools/commands/xmlupload/upload_stashed_xml_texts.py index 06735687a..08ea55abd 100644 --- a/src/dsp_tools/utils/xmlupload/upload_stashed_xml_texts.py +++ b/src/dsp_tools/commands/xmlupload/upload_stashed_xml_texts.py @@ -5,13 +5,13 @@ from typing import Any from urllib.parse import quote_plus -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml +from dsp_tools.commands.xmlupload.stash.stash_models import StandoffStash, StandoffStashItem from dsp_tools.models.exceptions import BaseError -from dsp_tools.models.value import KnoraStandoffXml +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.shared import try_network_action -from dsp_tools.utils.xmlupload.iri_resolver import IriResolver -from dsp_tools.utils.xmlupload.stash.stash_models import StandoffStash, StandoffStashItem logger = get_logger(__name__) diff --git a/src/dsp_tools/utils/xmlupload/write_diagnostic_info.py b/src/dsp_tools/commands/xmlupload/write_diagnostic_info.py similarity index 93% rename from src/dsp_tools/utils/xmlupload/write_diagnostic_info.py rename to src/dsp_tools/commands/xmlupload/write_diagnostic_info.py index e5b96cddc..db2be449e 100644 --- a/src/dsp_tools/utils/xmlupload/write_diagnostic_info.py +++ b/src/dsp_tools/commands/xmlupload/write_diagnostic_info.py @@ -7,8 +7,8 @@ from lxml import etree +from dsp_tools.commands.xmlupload.upload_config import DiagnosticsConfig from dsp_tools.utils.create_logger import get_logger -from dsp_tools.utils.xmlupload.upload_config import DiagnosticsConfig logger = get_logger(__name__) diff --git a/src/dsp_tools/utils/xmlupload/xmlupload.py b/src/dsp_tools/commands/xmlupload/xmlupload.py similarity index 92% rename from src/dsp_tools/utils/xmlupload/xmlupload.py rename to src/dsp_tools/commands/xmlupload/xmlupload.py index 7138dadce..592555d44 100644 --- a/src/dsp_tools/utils/xmlupload/xmlupload.py +++ b/src/dsp_tools/commands/xmlupload/xmlupload.py @@ -10,28 +10,31 @@ from lxml import etree -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.list_client import ListClient, ListClientLive +from dsp_tools.commands.xmlupload.models.permission import Permissions +from dsp_tools.commands.xmlupload.models.sipi import Sipi +from dsp_tools.commands.xmlupload.models.xmlpermission import XmlPermission +from dsp_tools.commands.xmlupload.models.xmlresource import BitstreamInfo, XMLResource +from dsp_tools.commands.xmlupload.project_client import ProjectClient, ProjectClientLive +from dsp_tools.commands.xmlupload.read_validate_xml_file import validate_and_parse_xml_file +from dsp_tools.commands.xmlupload.resource_create_client import ResourceCreateClient +from dsp_tools.commands.xmlupload.resource_multimedia import handle_bitstream +from dsp_tools.commands.xmlupload.stash.stash_models import Stash +from dsp_tools.commands.xmlupload.stash_circular_references import ( + identify_circular_references, + stash_circular_references, +) +from dsp_tools.commands.xmlupload.upload_config import DiagnosticsConfig, UploadConfig +from dsp_tools.commands.xmlupload.upload_stashed_resptr_props import upload_stashed_resptr_props +from dsp_tools.commands.xmlupload.upload_stashed_xml_texts import upload_stashed_xml_texts +from dsp_tools.commands.xmlupload.write_diagnostic_info import write_id2iri_mapping from dsp_tools.models.exceptions import BaseError, UserError -from dsp_tools.models.permission import Permissions from dsp_tools.models.projectContext import ProjectContext -from dsp_tools.models.sipi import Sipi -from dsp_tools.models.xmlpermission import XmlPermission -from dsp_tools.models.xmlresource import BitstreamInfo, XMLResource +from dsp_tools.utils.connection import Connection from dsp_tools.utils.create_logger import get_logger from dsp_tools.utils.json_ld_util import get_json_ld_context_for_project from dsp_tools.utils.shared import login, try_network_action -from dsp_tools.utils.xmlupload.iri_resolver import IriResolver -from dsp_tools.utils.xmlupload.list_client import ListClient, ListClientLive -from dsp_tools.utils.xmlupload.project_client import ProjectClient, ProjectClientLive -from dsp_tools.utils.xmlupload.read_validate_xml_file import validate_and_parse_xml_file -from dsp_tools.utils.xmlupload.resource_create_client import ResourceCreateClient -from dsp_tools.utils.xmlupload.resource_multimedia import handle_bitstream -from dsp_tools.utils.xmlupload.stash.stash_models import Stash -from dsp_tools.utils.xmlupload.stash_circular_references import identify_circular_references, stash_circular_references -from dsp_tools.utils.xmlupload.upload_config import DiagnosticsConfig, UploadConfig -from dsp_tools.utils.xmlupload.upload_stashed_resptr_props import upload_stashed_resptr_props -from dsp_tools.utils.xmlupload.upload_stashed_xml_texts import upload_stashed_xml_texts -from dsp_tools.utils.xmlupload.write_diagnostic_info import write_id2iri_mapping logger = get_logger(__name__) diff --git a/src/dsp_tools/models/bitstream.py b/src/dsp_tools/models/bitstream.py deleted file mode 100644 index 9b8419262..000000000 --- a/src/dsp_tools/models/bitstream.py +++ /dev/null @@ -1,36 +0,0 @@ -from dataclasses import dataclass -from typing import Optional - -from dsp_tools.models.helpers import Actions -from dsp_tools.models.permission import Permissions - - -@dataclass(frozen=True) -class Bitstream: - """ - Represents a bitstream object (file) which is attached to a resource. - - Attributes: - value: File path of the bitstream - permissions: Permissions of the bitstream - """ - - value: str - permissions: Optional[Permissions] = None - - def toJsonLdObj(self, action: Actions) -> dict[str, str]: - """ - Create a JSON-LD object from this python object. - - Args: - action: action for which this JSON-LD is used for: create, read, update, or delete - - Returns: - JSON-LD object - """ - tmp = {} - if action == Actions.Create: - tmp["knora-api:fileValueHasFilename"] = self.value - if self.permissions: - tmp["knora-api:hasPermissions"] = self.permissions.toJsonLdObj() - return tmp diff --git a/src/dsp_tools/models/projectContext.py b/src/dsp_tools/models/projectContext.py index 2a5afb560..6ca175ef1 100644 --- a/src/dsp_tools/models/projectContext.py +++ b/src/dsp_tools/models/projectContext.py @@ -1,9 +1,9 @@ from typing import Optional -from dsp_tools.connection.connection import Connection +from dsp_tools.commands.project.models.group import Group +from dsp_tools.commands.project.models.project import Project from dsp_tools.models.exceptions import BaseError -from dsp_tools.models.group import Group -from dsp_tools.models.project import Project +from dsp_tools.utils.connection import Connection class ProjectContext: diff --git a/src/dsp_tools/connection/connection.py b/src/dsp_tools/utils/connection.py similarity index 100% rename from src/dsp_tools/connection/connection.py rename to src/dsp_tools/utils/connection.py diff --git a/src/dsp_tools/connection/connection_live.py b/src/dsp_tools/utils/connection_live.py similarity index 100% rename from src/dsp_tools/connection/connection_live.py rename to src/dsp_tools/utils/connection_live.py diff --git a/src/dsp_tools/utils/shared.py b/src/dsp_tools/utils/shared.py index 8682f7674..a438577da 100644 --- a/src/dsp_tools/utils/shared.py +++ b/src/dsp_tools/utils/shared.py @@ -17,10 +17,10 @@ from requests import ReadTimeout, RequestException from urllib3.exceptions import ReadTimeoutError -from dsp_tools.connection.connection import Connection -from dsp_tools.connection.connection_live import ConnectionLive from dsp_tools.models.exceptions import BaseError, UserError from dsp_tools.models.propertyelement import PropertyElement +from dsp_tools.utils.connection import Connection +from dsp_tools.utils.connection_live import ConnectionLive from dsp_tools.utils.create_logger import get_logger logger = get_logger(__name__) diff --git a/test/benchmarking/test_stash_circular_references.py b/test/benchmarking/test_stash_circular_references.py index 7571c0e5b..9ca7aa186 100644 --- a/test/benchmarking/test_stash_circular_references.py +++ b/test/benchmarking/test_stash_circular_references.py @@ -3,10 +3,13 @@ import pytest from termcolor import cprint -from dsp_tools.models.permission import Permissions +from dsp_tools.commands.xmlupload.models.permission import Permissions +from dsp_tools.commands.xmlupload.stash_circular_references import ( + identify_circular_references, + stash_circular_references, +) +from dsp_tools.commands.xmlupload.xmlupload import _extract_resources_from_xml from dsp_tools.utils.xml_utils import parse_and_clean_xml_file -from dsp_tools.utils.xmlupload.stash_circular_references import identify_circular_references, stash_circular_references -from dsp_tools.utils.xmlupload.xmlupload import _extract_resources_from_xml def test_get_length_ok_resources() -> None: diff --git a/test/unittests/test_excel2json/__init__.py b/test/e2e/commands/__init__.py similarity index 100% rename from test/unittests/test_excel2json/__init__.py rename to test/e2e/commands/__init__.py diff --git a/test/unittests/test_xmlupload/__init__.py b/test/e2e/commands/project/__init__.py similarity index 100% rename from test/unittests/test_xmlupload/__init__.py rename to test/e2e/commands/project/__init__.py diff --git a/test/e2e/test_create_lists.py b/test/e2e/commands/project/test_create_lists.py similarity index 93% rename from test/e2e/test_create_lists.py rename to test/e2e/commands/project/test_create_lists.py index 96014ff53..4cbf17278 100644 --- a/test/e2e/test_create_lists.py +++ b/test/e2e/commands/project/test_create_lists.py @@ -6,8 +6,8 @@ import jsonpath_ng.ext -from dsp_tools.utils.project_create import create_project -from dsp_tools.utils.project_create_lists import create_lists +from dsp_tools.commands.project.create.project_create import create_project +from dsp_tools.commands.project.create.project_create_lists import create_lists class TestCreateLists(unittest.TestCase): diff --git a/test/e2e/test_group.py b/test/e2e/commands/project/test_group.py similarity index 96% rename from test/e2e/test_group.py rename to test/e2e/commands/project/test_group.py index 02137a8e1..925d20303 100644 --- a/test/e2e/test_group.py +++ b/test/e2e/commands/project/test_group.py @@ -4,10 +4,10 @@ import pytest -from dsp_tools.connection.connection import Connection -from dsp_tools.connection.connection_live import ConnectionLive -from dsp_tools.models.group import Group +from dsp_tools.commands.project.models.group import Group from dsp_tools.models.langstring import LangString, Languages +from dsp_tools.utils.connection import Connection +from dsp_tools.utils.connection_live import ConnectionLive class TestGroup(unittest.TestCase): # pylint: disable=missing-class-docstring diff --git a/test/e2e/test_listnode.py b/test/e2e/commands/project/test_listnode.py similarity index 97% rename from test/e2e/test_listnode.py rename to test/e2e/commands/project/test_listnode.py index 8f77c418a..51addbc18 100644 --- a/test/e2e/test_listnode.py +++ b/test/e2e/commands/project/test_listnode.py @@ -3,10 +3,10 @@ import pytest -from dsp_tools.connection.connection import Connection -from dsp_tools.connection.connection_live import ConnectionLive +from dsp_tools.commands.project.models.listnode import ListNode from dsp_tools.models.langstring import LangString, Languages -from dsp_tools.models.listnode import ListNode +from dsp_tools.utils.connection import Connection +from dsp_tools.utils.connection_live import ConnectionLive class TestListNode(unittest.TestCase): # pylint: disable=missing-class-docstring diff --git a/test/e2e/test_ontology.py b/test/e2e/commands/project/test_ontology.py similarity index 95% rename from test/e2e/test_ontology.py rename to test/e2e/commands/project/test_ontology.py index ca0002fc0..4614f0b07 100644 --- a/test/e2e/test_ontology.py +++ b/test/e2e/commands/project/test_ontology.py @@ -6,10 +6,10 @@ import pytest -from dsp_tools.connection.connection import Connection -from dsp_tools.connection.connection_live import ConnectionLive +from dsp_tools.commands.project.models.ontology import Ontology from dsp_tools.models.helpers import DateTimeStamp -from dsp_tools.models.ontology import Ontology +from dsp_tools.utils.connection import Connection +from dsp_tools.utils.connection_live import ConnectionLive class TestOntology(unittest.TestCase): diff --git a/test/e2e/test_project.py b/test/e2e/commands/project/test_project.py similarity index 97% rename from test/e2e/test_project.py rename to test/e2e/commands/project/test_project.py index e8fef99bf..19dec74d9 100644 --- a/test/e2e/test_project.py +++ b/test/e2e/commands/project/test_project.py @@ -6,10 +6,10 @@ import pytest -from dsp_tools.connection.connection import Connection -from dsp_tools.connection.connection_live import ConnectionLive +from dsp_tools.commands.project.models.project import Project from dsp_tools.models.langstring import LangString, Languages -from dsp_tools.models.project import Project +from dsp_tools.utils.connection import Connection +from dsp_tools.utils.connection_live import ConnectionLive class TestProject(unittest.TestCase): diff --git a/test/e2e/test_propertyclass.py b/test/e2e/commands/project/test_propertyclass.py similarity index 94% rename from test/e2e/test_propertyclass.py rename to test/e2e/commands/project/test_propertyclass.py index 0d1ba082b..e91a986f8 100644 --- a/test/e2e/test_propertyclass.py +++ b/test/e2e/commands/project/test_propertyclass.py @@ -6,12 +6,12 @@ import pytest -from dsp_tools.connection.connection import Connection -from dsp_tools.connection.connection_live import ConnectionLive +from dsp_tools.commands.project.models.ontology import Ontology +from dsp_tools.commands.project.models.propertyclass import PropertyClass from dsp_tools.models.helpers import DateTimeStamp from dsp_tools.models.langstring import LangString, Languages -from dsp_tools.models.ontology import Ontology -from dsp_tools.models.propertyclass import PropertyClass +from dsp_tools.utils.connection import Connection +from dsp_tools.utils.connection_live import ConnectionLive class TestPropertyClass(unittest.TestCase): diff --git a/test/e2e/test_resourceclass.py b/test/e2e/commands/project/test_resourceclass.py similarity index 92% rename from test/e2e/test_resourceclass.py rename to test/e2e/commands/project/test_resourceclass.py index 4a654c1a7..a89944112 100644 --- a/test/e2e/test_resourceclass.py +++ b/test/e2e/commands/project/test_resourceclass.py @@ -6,11 +6,11 @@ import pytest -from dsp_tools.connection.connection import Connection -from dsp_tools.connection.connection_live import ConnectionLive +from dsp_tools.commands.project.models.ontology import Ontology +from dsp_tools.commands.project.models.resourceclass import ResourceClass from dsp_tools.models.langstring import LangString, Languages -from dsp_tools.models.ontology import Ontology -from dsp_tools.models.resourceclass import ResourceClass +from dsp_tools.utils.connection import Connection +from dsp_tools.utils.connection_live import ConnectionLive class TestResourceClass(unittest.TestCase): diff --git a/test/e2e/test_user.py b/test/e2e/commands/project/test_user.py similarity index 98% rename from test/e2e/test_user.py rename to test/e2e/commands/project/test_user.py index ceffbe12a..4029e24c2 100644 --- a/test/e2e/test_user.py +++ b/test/e2e/commands/project/test_user.py @@ -6,10 +6,10 @@ import pytest -from dsp_tools.connection.connection import Connection -from dsp_tools.connection.connection_live import ConnectionLive +from dsp_tools.commands.project.models.user import User from dsp_tools.models.langstring import Languages -from dsp_tools.models.user import User +from dsp_tools.utils.connection import Connection +from dsp_tools.utils.connection_live import ConnectionLive # define variables for testing iri_project_0001 = "http://rdfh.ch/projects/0001" diff --git a/test/e2e/test_create_get_xmlupload.py b/test/e2e/commands/test_create_get_xmlupload.py similarity index 98% rename from test/e2e/test_create_get_xmlupload.py rename to test/e2e/commands/test_create_get_xmlupload.py index 09f647516..47984c488 100644 --- a/test/e2e/test_create_get_xmlupload.py +++ b/test/e2e/commands/test_create_get_xmlupload.py @@ -6,11 +6,11 @@ import regex -from dsp_tools.utils.id2iri import id2iri -from dsp_tools.utils.project_create import create_project -from dsp_tools.utils.project_get import get_project +from dsp_tools.commands.id2iri import id2iri +from dsp_tools.commands.project.create.project_create import create_project +from dsp_tools.commands.project.get import get_project +from dsp_tools.commands.xmlupload.xmlupload import xmlupload from dsp_tools.utils.shared import get_most_recent_glob_match -from dsp_tools.utils.xmlupload.xmlupload import xmlupload class TestCreateGetXMLUpload(unittest.TestCase): diff --git a/test/e2e/test_fast_xmlupload.py b/test/e2e/commands/test_fast_xmlupload.py similarity index 95% rename from test/e2e/test_fast_xmlupload.py rename to test/e2e/commands/test_fast_xmlupload.py index dc2a3faa2..50f718f1c 100644 --- a/test/e2e/test_fast_xmlupload.py +++ b/test/e2e/commands/test_fast_xmlupload.py @@ -4,10 +4,10 @@ import pytest -from dsp_tools.fast_xmlupload.process_files import process_files -from dsp_tools.fast_xmlupload.upload_files import upload_files -from dsp_tools.fast_xmlupload.upload_xml import fast_xmlupload -from dsp_tools.utils.project_create import create_project +from dsp_tools.commands.fast_xmlupload.process_files import process_files +from dsp_tools.commands.fast_xmlupload.upload_files import upload_files +from dsp_tools.commands.fast_xmlupload.upload_xml import fast_xmlupload +from dsp_tools.commands.project.create.project_create import create_project class TestFastXmlUpload(unittest.TestCase): diff --git a/test/e2e/test_rosetta.py b/test/e2e/commands/test_rosetta.py similarity index 96% rename from test/e2e/test_rosetta.py rename to test/e2e/commands/test_rosetta.py index a9ac79a5c..2e76207b0 100644 --- a/test/e2e/test_rosetta.py +++ b/test/e2e/commands/test_rosetta.py @@ -6,7 +6,7 @@ import pytest -from dsp_tools.utils import rosetta +from dsp_tools.commands import rosetta @pytest.fixture(scope="module", autouse=True) diff --git a/test/unittests/util/__init__.py b/test/e2e/commands/xmlupload/__init__.py similarity index 100% rename from test/unittests/util/__init__.py rename to test/e2e/commands/xmlupload/__init__.py diff --git a/test/e2e/xmlupload/test_list_client_live.py b/test/e2e/commands/xmlupload/test_list_client_live.py similarity index 76% rename from test/e2e/xmlupload/test_list_client_live.py rename to test/e2e/commands/xmlupload/test_list_client_live.py index 11772c466..a8ca4de12 100644 --- a/test/e2e/xmlupload/test_list_client_live.py +++ b/test/e2e/commands/xmlupload/test_list_client_live.py @@ -1,8 +1,8 @@ import regex -from dsp_tools.connection.connection_live import ConnectionLive -from dsp_tools.utils.xmlupload.list_client import ListClientLive -from dsp_tools.utils.xmlupload.project_client import ProjectClientLive +from dsp_tools.commands.xmlupload.list_client import ListClientLive +from dsp_tools.commands.xmlupload.project_client import ProjectClientLive +from dsp_tools.utils.connection_live import ConnectionLive # pylint: disable=missing-function-docstring diff --git a/test/e2e/xmlupload/test_project_client_live.py b/test/e2e/commands/xmlupload/test_project_client_live.py similarity index 89% rename from test/e2e/xmlupload/test_project_client_live.py rename to test/e2e/commands/xmlupload/test_project_client_live.py index 5574ed8f9..e13f51698 100644 --- a/test/e2e/xmlupload/test_project_client_live.py +++ b/test/e2e/commands/xmlupload/test_project_client_live.py @@ -1,7 +1,7 @@ from pytest import fixture -from dsp_tools.connection.connection_live import ConnectionLive -from dsp_tools.utils.xmlupload.project_client import ProjectClient, ProjectClientLive +from dsp_tools.commands.xmlupload.project_client import ProjectClient, ProjectClientLive +from dsp_tools.utils.connection_live import ConnectionLive # pylint: disable=missing-function-docstring,redefined-outer-name diff --git a/test/e2e/test_xmlupload.py b/test/e2e/commands/xmlupload/test_xmlupload.py similarity index 91% rename from test/e2e/test_xmlupload.py rename to test/e2e/commands/xmlupload/test_xmlupload.py index 081b96cad..755e62adb 100644 --- a/test/e2e/test_xmlupload.py +++ b/test/e2e/commands/xmlupload/test_xmlupload.py @@ -4,9 +4,9 @@ import pytest +from dsp_tools.commands.xmlupload.upload_config import UploadConfig +from dsp_tools.commands.xmlupload.xmlupload import xmlupload from dsp_tools.models.exceptions import BaseError -from dsp_tools.utils.xmlupload.upload_config import UploadConfig -from dsp_tools.utils.xmlupload.xmlupload import xmlupload class TestXMLUpload(unittest.TestCase): diff --git a/test/e2e/test_00A1_import_scripts.py b/test/e2e/test_00A1_import_scripts.py index 1691f91b3..7f129af56 100644 --- a/test/e2e/test_00A1_import_scripts.py +++ b/test/e2e/test_00A1_import_scripts.py @@ -7,11 +7,11 @@ import pytest import regex +from dsp_tools.commands.project.create.project_create import create_project +from dsp_tools.commands.xmlupload.upload_config import UploadConfig +from dsp_tools.commands.xmlupload.xmlupload import xmlupload from dsp_tools.models.exceptions import BaseError -from dsp_tools.utils.project_create import create_project from dsp_tools.utils.shared import check_notna -from dsp_tools.utils.xmlupload.upload_config import UploadConfig -from dsp_tools.utils.xmlupload.xmlupload import xmlupload class TestImportScripts(unittest.TestCase): diff --git a/test/e2e/test_cli.py b/test/e2e/test_cli.py index a216bdee0..5257666e3 100644 --- a/test/e2e/test_cli.py +++ b/test/e2e/test_cli.py @@ -5,7 +5,7 @@ import pytest -from dsp_tools.utils.project_create import create_project +from dsp_tools.commands.project.create.project_create import create_project class TestCLI(unittest.TestCase): diff --git a/test/unittests/xmlupload/__init__.py b/test/e2e/utils/__init__.py similarity index 100% rename from test/unittests/xmlupload/__init__.py rename to test/e2e/utils/__init__.py diff --git a/test/e2e/test_connection_live.py b/test/e2e/utils/test_connection_live.py similarity index 98% rename from test/e2e/test_connection_live.py rename to test/e2e/utils/test_connection_live.py index f45e43573..989b46fa1 100644 --- a/test/e2e/test_connection_live.py +++ b/test/e2e/utils/test_connection_live.py @@ -6,8 +6,8 @@ import pytest -from dsp_tools.connection.connection_live import ConnectionLive from dsp_tools.models.exceptions import BaseError +from dsp_tools.utils.connection_live import ConnectionLive class TestConnectionLive(unittest.TestCase): diff --git a/test/unittests/commands/__init__.py b/test/unittests/commands/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/unittests/commands/excel2json/__init__.py b/test/unittests/commands/excel2json/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/unittests/test_excel2json/test_excel2json.py b/test/unittests/commands/excel2json/test_excel2json.py similarity index 95% rename from test/unittests/test_excel2json/test_excel2json.py rename to test/unittests/commands/excel2json/test_excel2json.py index 495be06e5..e45e2529a 100644 --- a/test/unittests/test_excel2json/test_excel2json.py +++ b/test/unittests/commands/excel2json/test_excel2json.py @@ -3,7 +3,7 @@ import unittest from pathlib import Path -from dsp_tools.utils.excel2json.project import excel2json +from dsp_tools.commands.excel2json.project import excel2json class TestExcel2Json(unittest.TestCase): diff --git a/test/unittests/test_excel2json/test_lists.py b/test/unittests/commands/excel2json/test_lists.py similarity index 99% rename from test/unittests/test_excel2json/test_lists.py rename to test/unittests/commands/excel2json/test_lists.py index 50b92d431..dca79adfc 100644 --- a/test/unittests/test_excel2json/test_lists.py +++ b/test/unittests/commands/excel2json/test_lists.py @@ -13,8 +13,8 @@ import pytest import regex +from dsp_tools.commands.excel2json import lists as e2l from dsp_tools.models.exceptions import BaseError -from dsp_tools.utils.excel2json import lists as e2l class TestExcelToJSONList(unittest.TestCase): diff --git a/test/unittests/test_excel2json/test_properties.py b/test/unittests/commands/excel2json/test_properties.py similarity index 99% rename from test/unittests/test_excel2json/test_properties.py rename to test/unittests/commands/excel2json/test_properties.py index 2499643bf..5db936b83 100644 --- a/test/unittests/test_excel2json/test_properties.py +++ b/test/unittests/commands/excel2json/test_properties.py @@ -13,8 +13,8 @@ import pytest from pandas.testing import assert_frame_equal +from dsp_tools.commands.excel2json import properties as e2j from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.excel2json import properties as e2j class TestExcelToProperties(unittest.TestCase): diff --git a/test/unittests/test_excel2json/test_resources.py b/test/unittests/commands/excel2json/test_resources.py similarity index 99% rename from test/unittests/test_excel2json/test_resources.py rename to test/unittests/commands/excel2json/test_resources.py index 734fa1303..04031df5f 100644 --- a/test/unittests/test_excel2json/test_resources.py +++ b/test/unittests/commands/excel2json/test_resources.py @@ -11,8 +11,8 @@ import jsonpath_ng.ext import pytest +from dsp_tools.commands.excel2json import resources as e2j from dsp_tools.models.exceptions import BaseError -from dsp_tools.utils.excel2json import resources as e2j class TestExcelToResource(unittest.TestCase): diff --git a/test/unittests/test_excel2json/test_utils.py b/test/unittests/commands/excel2json/test_utils.py similarity index 99% rename from test/unittests/test_excel2json/test_utils.py rename to test/unittests/commands/excel2json/test_utils.py index d98aab652..647232a3e 100644 --- a/test/unittests/test_excel2json/test_utils.py +++ b/test/unittests/commands/excel2json/test_utils.py @@ -7,7 +7,7 @@ import pytest from pandas.testing import assert_frame_equal, assert_series_equal -import dsp_tools.utils.excel2json.utils as utl +import dsp_tools.commands.excel2json.utils as utl from dsp_tools.models.exceptions import BaseError diff --git a/test/unittests/commands/project/__init__.py b/test/unittests/commands/project/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/unittests/test_create_project.py b/test/unittests/commands/project/test_create_project.py similarity index 98% rename from test/unittests/test_create_project.py rename to test/unittests/commands/project/test_create_project.py index 658f6344f..bff924b52 100644 --- a/test/unittests/test_create_project.py +++ b/test/unittests/commands/project/test_create_project.py @@ -9,9 +9,12 @@ import pytest -from dsp_tools.models.exceptions import BaseError, UserError -from dsp_tools.utils.project_create import _rectify_hlist_of_properties, _sort_prop_classes, _sort_resources -from dsp_tools.utils.project_validate import ( +from dsp_tools.commands.project.create.project_create import ( + _rectify_hlist_of_properties, + _sort_prop_classes, + _sort_resources, +) +from dsp_tools.commands.project.create.project_validate import ( _check_for_duplicate_names, _check_for_undefined_cardinalities, _check_for_undefined_super_property, @@ -20,6 +23,7 @@ _identify_problematic_cardinalities, validate_project, ) +from dsp_tools.models.exceptions import BaseError, UserError from dsp_tools.utils.shared import parse_json_input diff --git a/test/unittests/test_excel2xml.py b/test/unittests/commands/test_excel2xml.py similarity index 99% rename from test/unittests/test_excel2xml.py rename to test/unittests/commands/test_excel2xml.py index 6b5a46cb2..0777aa2d0 100644 --- a/test/unittests/test_excel2xml.py +++ b/test/unittests/commands/test_excel2xml.py @@ -149,6 +149,9 @@ def run_test( class TestExcel2xml(unittest.TestCase): + def tearDown(self) -> None: + Path("excel2xml-invalid-data.xml").unlink(missing_ok=True) + def test_make_xsd_id_compatible(self) -> None: teststring = "0aüZ/_-äöü1234567890?`^':.;+*ç%&/()=±“#Ç[]|{}≠₂₃āṇśṣr̥ṁñἄ𝝺𝝲𝛆’الشعرُאדםПопрыгуньяşğ" expected_ = "_0a_Z__-___1234567890_____.__________________________r______________________________" diff --git a/test/unittests/test_generate_templates.py b/test/unittests/commands/test_generate_templates.py similarity index 91% rename from test/unittests/test_generate_templates.py rename to test/unittests/commands/test_generate_templates.py index f6dd94070..42884ef03 100644 --- a/test/unittests/test_generate_templates.py +++ b/test/unittests/commands/test_generate_templates.py @@ -4,8 +4,8 @@ import pytest +from dsp_tools.commands.template import generate_template_repo from dsp_tools.models.exceptions import UserError -from dsp_tools.utils.generate_templates import generate_template_repo class TestGenerateTemplates(unittest.TestCase): # pylint: disable=missing-class-docstring diff --git a/test/unittests/test_id2iri.py b/test/unittests/commands/test_id2iri.py similarity index 98% rename from test/unittests/test_id2iri.py rename to test/unittests/commands/test_id2iri.py index 7bf4b9360..a2f0dd245 100644 --- a/test/unittests/test_id2iri.py +++ b/test/unittests/commands/test_id2iri.py @@ -8,8 +8,8 @@ import regex from lxml import etree +from dsp_tools.commands.id2iri import _remove_resources_if_id_in_mapping, _replace_ids_by_iris, id2iri from dsp_tools.models.exceptions import BaseError -from dsp_tools.utils.id2iri import _remove_resources_if_id_in_mapping, _replace_ids_by_iris, id2iri class TestIdToIri(unittest.TestCase): diff --git a/test/unittests/commands/xmlupload/__init__.py b/test/unittests/commands/xmlupload/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/unittests/helpers/connection_mock.py b/test/unittests/commands/xmlupload/connection_mock.py similarity index 100% rename from test/unittests/helpers/connection_mock.py rename to test/unittests/commands/xmlupload/connection_mock.py diff --git a/test/unittests/test_analyse_xml_data/test_construct_and_analyze_graph.py b/test/unittests/commands/xmlupload/test_construct_and_analyze_graph.py similarity index 99% rename from test/unittests/test_analyse_xml_data/test_construct_and_analyze_graph.py rename to test/unittests/commands/xmlupload/test_construct_and_analyze_graph.py index 738afd18c..d72289e8f 100644 --- a/test/unittests/test_analyse_xml_data/test_construct_and_analyze_graph.py +++ b/test/unittests/commands/xmlupload/test_construct_and_analyze_graph.py @@ -7,7 +7,7 @@ from lxml import etree from pytest_unordered import unordered -from dsp_tools.analyse_xml_data.construct_and_analyze_graph import ( +from dsp_tools.commands.xmlupload.analyse_xml_data.construct_and_analyze_graph import ( _add_stash_to_lookup_dict, _create_info_from_xml_for_graph_from_one_resource, _create_resptr_link_objects, @@ -21,7 +21,7 @@ generate_upload_order, make_graph, ) -from dsp_tools.analyse_xml_data.models import Edge, ResptrLink, XMLLink +from dsp_tools.commands.xmlupload.analyse_xml_data.models import Edge, ResptrLink, XMLLink def test_create_info_from_xml_for_graph_from_one_resource() -> None: diff --git a/test/unittests/xmlupload/test_iri_resolver.py b/test/unittests/commands/xmlupload/test_iri_resolver.py similarity index 93% rename from test/unittests/xmlupload/test_iri_resolver.py rename to test/unittests/commands/xmlupload/test_iri_resolver.py index 25ed75070..f463ec111 100644 --- a/test/unittests/xmlupload/test_iri_resolver.py +++ b/test/unittests/commands/xmlupload/test_iri_resolver.py @@ -1,6 +1,6 @@ from pytest import fixture -from dsp_tools.utils.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.iri_resolver import IriResolver # pylint: disable=missing-function-docstring,redefined-outer-name diff --git a/test/unittests/xmlupload/test_list_client_live.py b/test/unittests/commands/xmlupload/test_list_client_live.py similarity index 98% rename from test/unittests/xmlupload/test_list_client_live.py rename to test/unittests/commands/xmlupload/test_list_client_live.py index e568eec86..89da2c321 100644 --- a/test/unittests/xmlupload/test_list_client_live.py +++ b/test/unittests/commands/xmlupload/test_list_client_live.py @@ -1,8 +1,8 @@ from dataclasses import dataclass -from test.unittests.helpers.connection_mock import ConnectionMockBase +from test.unittests.commands.xmlupload.connection_mock import ConnectionMockBase from typing import Any -from dsp_tools.utils.xmlupload.list_client import ( +from dsp_tools.commands.xmlupload.list_client import ( List, ListClientLive, ListNode, diff --git a/test/unittests/xmlupload/test_project_client_live.py b/test/unittests/commands/xmlupload/test_project_client_live.py similarity index 95% rename from test/unittests/xmlupload/test_project_client_live.py rename to test/unittests/commands/xmlupload/test_project_client_live.py index f86ed6fc9..9df3882b0 100644 --- a/test/unittests/xmlupload/test_project_client_live.py +++ b/test/unittests/commands/xmlupload/test_project_client_live.py @@ -1,8 +1,8 @@ from dataclasses import dataclass, field -from test.unittests.helpers.connection_mock import ConnectionMockBase +from test.unittests.commands.xmlupload.connection_mock import ConnectionMockBase from typing import Any -from dsp_tools.utils.xmlupload.project_client import ProjectClientLive +from dsp_tools.commands.xmlupload.project_client import ProjectClientLive # pylint: disable=missing-class-docstring,missing-function-docstring,unused-argument,redefined-outer-name diff --git a/test/unittests/xmlupload/test_resource_create_client.py b/test/unittests/commands/xmlupload/test_resource_create_client.py similarity index 98% rename from test/unittests/xmlupload/test_resource_create_client.py rename to test/unittests/commands/xmlupload/test_resource_create_client.py index e926b7393..616d8f2b2 100644 --- a/test/unittests/xmlupload/test_resource_create_client.py +++ b/test/unittests/commands/xmlupload/test_resource_create_client.py @@ -1,9 +1,9 @@ from pytest import raises +from dsp_tools.commands.xmlupload.models.permission import Permissions, PermissionValue +from dsp_tools.commands.xmlupload.models.xmlresource import BitstreamInfo +from dsp_tools.commands.xmlupload.resource_create_client import _make_bitstream_file_value, _to_boolean from dsp_tools.models.exceptions import BaseError -from dsp_tools.models.permission import Permissions, PermissionValue -from dsp_tools.models.xmlresource import BitstreamInfo -from dsp_tools.utils.xmlupload.resource_create_client import _make_bitstream_file_value, _to_boolean # pylint: disable=missing-class-docstring,missing-function-docstring,unused-argument,redefined-outer-name,too-many-public-methods diff --git a/test/unittests/test_xmlupload/test_upload_config.py b/test/unittests/commands/xmlupload/test_upload_config.py similarity index 95% rename from test/unittests/test_xmlupload/test_upload_config.py rename to test/unittests/commands/xmlupload/test_upload_config.py index 56f4814d9..d16e68d5c 100644 --- a/test/unittests/test_xmlupload/test_upload_config.py +++ b/test/unittests/commands/xmlupload/test_upload_config.py @@ -1,4 +1,4 @@ -from dsp_tools.utils.xmlupload.upload_config import UploadConfig, _transform_server_url_to_foldername +from dsp_tools.commands.xmlupload.upload_config import UploadConfig, _transform_server_url_to_foldername # pylint: disable=missing-class-docstring,missing-function-docstring diff --git a/test/unittests/test_xmlupload/test_upload_stash_with_mock.py b/test/unittests/commands/xmlupload/test_upload_stash_with_mock.py similarity index 95% rename from test/unittests/test_xmlupload/test_upload_stash_with_mock.py rename to test/unittests/commands/xmlupload/test_upload_stash_with_mock.py index e21394096..e6f98410c 100644 --- a/test/unittests/test_xmlupload/test_upload_stash_with_mock.py +++ b/test/unittests/commands/xmlupload/test_upload_stash_with_mock.py @@ -2,17 +2,17 @@ from typing import Any from uuid import uuid4 -from dsp_tools.connection.connection import Connection -from dsp_tools.models.value import KnoraStandoffXml -from dsp_tools.utils.xmlupload.iri_resolver import IriResolver -from dsp_tools.utils.xmlupload.stash.stash_models import ( +from dsp_tools.commands.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml +from dsp_tools.commands.xmlupload.stash.stash_models import ( LinkValueStash, LinkValueStashItem, StandoffStash, StandoffStashItem, Stash, ) -from dsp_tools.utils.xmlupload.xmlupload import _upload_stash +from dsp_tools.commands.xmlupload.xmlupload import _upload_stash +from dsp_tools.utils.connection import Connection # pylint: disable=unused-argument,missing-function-docstring,missing-class-docstring,too-few-public-methods diff --git a/test/unittests/test_xmlupload/test_upload_stashed_xml_texts.py b/test/unittests/commands/xmlupload/test_upload_stashed_xml_texts.py similarity index 96% rename from test/unittests/test_xmlupload/test_upload_stashed_xml_texts.py rename to test/unittests/commands/xmlupload/test_upload_stashed_xml_texts.py index d83d3aa92..504e4af2a 100644 --- a/test/unittests/test_xmlupload/test_upload_stashed_xml_texts.py +++ b/test/unittests/commands/xmlupload/test_upload_stashed_xml_texts.py @@ -4,8 +4,8 @@ import pytest -from dsp_tools.models.value import KnoraStandoffXml -from dsp_tools.utils.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.iri_resolver import IriResolver +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml class TestXMLUploadStash(TestCase): diff --git a/test/unittests/test_value.py b/test/unittests/commands/xmlupload/test_value.py similarity index 94% rename from test/unittests/test_value.py rename to test/unittests/commands/xmlupload/test_value.py index 7cbdd81b2..f7b3099b4 100644 --- a/test/unittests/test_value.py +++ b/test/unittests/commands/xmlupload/test_value.py @@ -6,8 +6,8 @@ import pytest +from dsp_tools.commands.xmlupload.models.value import DateValue from dsp_tools.models.helpers import Actions -from dsp_tools.models.value import DateValue class TestValue(unittest.TestCase): diff --git a/test/unittests/test_xmlupload/test_xmlupload.py b/test/unittests/commands/xmlupload/test_xmlupload.py similarity index 97% rename from test/unittests/test_xmlupload/test_xmlupload.py rename to test/unittests/commands/xmlupload/test_xmlupload.py index 29d5b264e..90b691555 100644 --- a/test/unittests/test_xmlupload/test_xmlupload.py +++ b/test/unittests/commands/xmlupload/test_xmlupload.py @@ -8,9 +8,9 @@ import regex from lxml import etree +from dsp_tools.commands.xmlupload.ark2iri import convert_ark_v0_to_resource_iri from dsp_tools.models.exceptions import BaseError from dsp_tools.utils.xml_utils import parse_and_clean_xml_file -from dsp_tools.utils.xmlupload.ark2iri import convert_ark_v0_to_resource_iri class TestXMLUpload(unittest.TestCase): diff --git a/test/unittests/test_xmlupload/test_xmlvalue.py b/test/unittests/commands/xmlupload/test_xmlvalue.py similarity index 95% rename from test/unittests/test_xmlupload/test_xmlvalue.py rename to test/unittests/commands/xmlupload/test_xmlvalue.py index 10a636a04..28cb2168c 100644 --- a/test/unittests/test_xmlupload/test_xmlvalue.py +++ b/test/unittests/commands/xmlupload/test_xmlvalue.py @@ -3,8 +3,8 @@ import pytest from lxml import etree -from dsp_tools.models.value import KnoraStandoffXml -from dsp_tools.models.xmlvalue import XMLValue +from dsp_tools.commands.xmlupload.models.value import KnoraStandoffXml +from dsp_tools.commands.xmlupload.models.xmlvalue import XMLValue class TestXmlValue(unittest.TestCase): diff --git a/test/unittests/models/__init__.py b/test/unittests/models/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/unittests/test_langstring.py b/test/unittests/models/test_langstring.py similarity index 100% rename from test/unittests/test_langstring.py rename to test/unittests/models/test_langstring.py diff --git a/test/unittests/test_cli_with_mock.py b/test/unittests/test_cli_with_mock.py index c4bf101e0..af5ca3a8a 100644 --- a/test/unittests/test_cli_with_mock.py +++ b/test/unittests/test_cli_with_mock.py @@ -3,7 +3,7 @@ import pytest from dsp_tools import cli -from dsp_tools.utils.xmlupload.upload_config import UploadConfig +from dsp_tools.commands.xmlupload.upload_config import UploadConfig def test_invalid_arguments() -> None: @@ -243,7 +243,7 @@ def test_excel2xml(excel2xml: Mock) -> None: ) -@patch("dsp_tools.utils.stack_handling.StackHandler.start_stack") +@patch("dsp_tools.commands.start_stack.StackHandler.start_stack") def test_start_stack(start_stack: Mock) -> None: """Test the 'dsp-tools start-stack' command""" args = "start-stack".split() @@ -251,7 +251,7 @@ def test_start_stack(start_stack: Mock) -> None: start_stack.assert_called_once_with() -@patch("dsp_tools.utils.stack_handling.StackHandler.stop_stack") +@patch("dsp_tools.commands.start_stack.StackHandler.stop_stack") def test_stop_stack(stop_stack: Mock) -> None: """Test the 'dsp-tools stop-stack' command""" args = "stop-stack".split() diff --git a/test/unittests/utils/__init__.py b/test/unittests/utils/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/unittests/util/test_date_util.py b/test/unittests/utils/test_date_util.py similarity index 100% rename from test/unittests/util/test_date_util.py rename to test/unittests/utils/test_date_util.py diff --git a/test/unittests/util/test_iri_util.py b/test/unittests/utils/test_iri_util.py similarity index 100% rename from test/unittests/util/test_iri_util.py rename to test/unittests/utils/test_iri_util.py diff --git a/test/unittests/util/test_json_ld_util.py b/test/unittests/utils/test_json_ld_util.py similarity index 100% rename from test/unittests/util/test_json_ld_util.py rename to test/unittests/utils/test_json_ld_util.py diff --git a/test/unittests/test_shared.py b/test/unittests/utils/test_shared.py similarity index 100% rename from test/unittests/test_shared.py rename to test/unittests/utils/test_shared.py diff --git a/testdata/xml-data/circular-references/analyse_circles_in_xml.py b/testdata/xml-data/circular-references/analyse_circles_in_xml.py index 9f3d77971..9abe874ba 100644 --- a/testdata/xml-data/circular-references/analyse_circles_in_xml.py +++ b/testdata/xml-data/circular-references/analyse_circles_in_xml.py @@ -3,7 +3,7 @@ from viztracer import VizTracer -from dsp_tools.analyse_xml_data.construct_and_analyze_graph import ( +from dsp_tools.commands.xmlupload.analyse_xml_data.construct_and_analyze_graph import ( create_info_from_xml_for_graph, generate_upload_order, make_graph,