Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: harmonize CLI flags, rename CLI entry point and add tests for the CLI (DEV-2525) #463

Merged
merged 18 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ types-pyyaml = "^6.0.12.10"


[tool.poetry.scripts]
dsp-tools = "dsp_tools.dsp_tools:main" # definition of the CLI entry point
dsp-tools = "dsp_tools.cli_entry_point:main" # definition of the CLI entry point
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved


[tool.poetry-exec-plugin.commands]
Expand Down
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _make_parser(
help="The links in the XML file point to IRIs (on the server) instead of IDs (in the same XML file).",
)
parser_upload.add_argument(
"-V", "--validate", action="store_true", help="validate the XML file without uploading it"
"-V", "--validate-only", action="store_true", help="validate the XML file without uploading it"
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
)
parser_upload.add_argument("-v", "--verbose", action="store_true", help=verbose_text)
parser_upload.add_argument("-m", "--metrics", action="store_true", help="write metrics into a 'metrics' folder")
Expand Down Expand Up @@ -449,7 +449,7 @@ def _call_requested_action(args: argparse.Namespace) -> bool:
verbose=args.verbose,
)
elif args.action == "xmlupload":
if args.validate:
if args.validate_only:
success = validate_xml_against_schema(input_file=args.xmlfile)
else:
success = xml_upload(
Expand Down
8 changes: 4 additions & 4 deletions src/dsp_tools/excel2xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,14 +1267,14 @@ def make_text_prop(
for val in values:
kwargs = {"permissions": val.permissions}
if check_notna(val.comment):
kwargs["comment"] = val.comment # type: ignore
kwargs["comment"] = str(val.comment)
if check_notna(val.encoding):
kwargs["encoding"] = val.encoding # type: ignore
kwargs["encoding"] = str(val.encoding)
else:
kwargs["encoding"] = "utf8"
value_ = etree.Element(
"{%s}text" % xml_namespace_map[None],
**kwargs, # type: ignore
**kwargs, # type: ignore[arg-type]
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
nsmap=xml_namespace_map,
)
if kwargs["encoding"] == "utf8":
Expand Down Expand Up @@ -2274,7 +2274,7 @@ def excel2xml(
It takes a tabular data source in CSV/XLS(X) format that is formatted according to the specifications,
and transforms it into a DSP-conforming XML file
that can be uploaded to a DSP server with the xmlupload command.
The output file is saved in the same directory as the input file,
The output file is saved in the current working directory,
with the name [default_ontology]-data.xml.

Please note that this method doesn't do any data cleaning or data transformation tasks.
Expand Down
2 changes: 1 addition & 1 deletion src/dsp_tools/utils/id_to_iri.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def id_to_iri(
out_file = file_name + "_replaced_" + timestamp_str + ".xml"

et = etree.ElementTree(tree.getroot())
et.write(out_file, pretty_print=True)
et.write(out_file, pretty_print=True, xml_declaration=True, encoding="utf-8")
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
print(f"XML with replaced IDs was written to file {out_file}.")

return success
3 changes: 2 additions & 1 deletion test/e2e/test_00A1_import_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import re
import subprocess
import unittest

import pytest
Expand All @@ -27,7 +28,7 @@ def test_import_scripts(self) -> None:
the DSP server.
"""
# pull the latest state of the git submodule
os.system("git submodule update --init --recursive")
subprocess.run("git submodule update --init --recursive", check=True, shell=True)
from dsp_tools.import_scripts import import_script # pylint: disable=import-outside-toplevel

# execute the import script in its directory
Expand Down
Loading
Loading