ghga-transpiler 1.2.0__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0}/PKG-INFO +18 -10
  2. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0}/README.md +2 -2
  3. ghga_transpiler-2.0.0/pyproject.toml +45 -0
  4. ghga_transpiler-2.0.0/setup.cfg +4 -0
  5. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/__init__.py +10 -1
  6. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/cli.py +21 -6
  7. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/config/config.py +17 -18
  8. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/core.py +21 -11
  9. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/io.py +4 -5
  10. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/transformations.py +22 -1
  11. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler.egg-info/PKG-INFO +18 -10
  12. ghga_transpiler-2.0.0/src/ghga_transpiler.egg-info/SOURCES.txt +23 -0
  13. ghga_transpiler-2.0.0/src/ghga_transpiler.egg-info/requires.txt +6 -0
  14. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler.egg-info/top_level.txt +0 -2
  15. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0}/tests/test_convert_workbook.py +3 -1
  16. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0}/tests/test_create_config.py +3 -1
  17. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0}/tests/test_io.py +1 -1
  18. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0}/tests/test_process_workbook.py +9 -5
  19. ghga_transpiler-1.2.0/ghga_transpiler/configs/0.10.0.yaml +0 -109
  20. ghga_transpiler-1.2.0/ghga_transpiler/configs/1.0.0.yaml +0 -109
  21. ghga_transpiler-1.2.0/ghga_transpiler/configs/1.1.0.yaml +0 -109
  22. ghga_transpiler-1.2.0/ghga_transpiler.egg-info/SOURCES.txt +0 -43
  23. ghga_transpiler-1.2.0/ghga_transpiler.egg-info/not-zip-safe +0 -1
  24. ghga_transpiler-1.2.0/ghga_transpiler.egg-info/requires.txt +0 -7
  25. ghga_transpiler-1.2.0/scripts/__init__.py +0 -17
  26. ghga_transpiler-1.2.0/scripts/get_package_name.py +0 -46
  27. ghga_transpiler-1.2.0/scripts/license_checker.py +0 -562
  28. ghga_transpiler-1.2.0/scripts/script_utils/__init__.py +0 -17
  29. ghga_transpiler-1.2.0/scripts/script_utils/cli.py +0 -36
  30. ghga_transpiler-1.2.0/scripts/update_all.py +0 -51
  31. ghga_transpiler-1.2.0/scripts/update_config_docs.py +0 -158
  32. ghga_transpiler-1.2.0/scripts/update_readme.py +0 -221
  33. ghga_transpiler-1.2.0/scripts/update_template_files.py +0 -250
  34. ghga_transpiler-1.2.0/setup.cfg +0 -46
  35. ghga_transpiler-1.2.0/setup.py +0 -23
  36. ghga_transpiler-1.2.0/tests/fixtures/__init__.py +0 -16
  37. ghga_transpiler-1.2.0/tests/fixtures/configs/0.0.0.yaml +0 -16
  38. ghga_transpiler-1.2.0/tests/fixtures/configs/__init__.py +0 -15
  39. ghga_transpiler-1.2.0/tests/fixtures/test_data_objects/__init__.py +0 -16
  40. ghga_transpiler-1.2.0/tests/fixtures/test_data_objects/conversion_data.py +0 -43
  41. ghga_transpiler-1.2.0/tests/fixtures/utils.py +0 -33
  42. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0}/LICENSE +0 -0
  43. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/__main__.py +0 -0
  44. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/config/__init__.py +0 -0
  45. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/config/exceptions.py +0 -0
  46. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler/configs/__init__.py +0 -0
  47. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler.egg-info/dependency_links.txt +0 -0
  48. {ghga_transpiler-1.2.0 → ghga_transpiler-2.0.0/src}/ghga_transpiler.egg-info/entry_points.txt +0 -0
@@ -1,28 +1,36 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ghga_transpiler
3
- Version: 1.2.0
4
- Summary: GHGA-Transpiler - GHGA metadata XLSX to JSON transpilation
5
- Home-page: https://github.com/ghga-de/ghga-transpiler
6
- Author: German Human Genome Phenome Archive (GHGA)
7
- Author-email: contact@ghga.de
3
+ Version: 2.0.0
4
+ Summary: GHGA-Transpiler - excel to JSON converter
5
+ Author-email: "German Human Genome Phenome Archive (GHGA)" <contact@ghga.de>
8
6
  License: Apache 2.0
7
+ Project-URL: Repository, https://github.com/ghga-de/ghga-transpiler
8
+ Classifier: Development Status :: 1 - Planning
9
9
  Classifier: Operating System :: POSIX :: Linux
10
10
  Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
11
13
  Classifier: License :: OSI Approved :: Apache Software License
12
14
  Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
13
- Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Classifier: Intended Audience :: Developers
14
17
  Requires-Python: >=3.9
15
- Description-Content-Type: text/markdown; charset=UTF-8
16
- Provides-Extra: all
18
+ Description-Content-Type: text/markdown
17
19
  License-File: LICENSE
20
+ Requires-Dist: typer~=0.9.0
21
+ Requires-Dist: openpyxl==3.*,>=3.1.2
22
+ Requires-Dist: defusedxml==0.*,>=0.7
23
+ Requires-Dist: pydantic<3,>=2
24
+ Requires-Dist: PyYAML~=6.0
25
+ Requires-Dist: semver==3.*
18
26
 
19
27
 
20
- [![tests](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml/badge.svg)](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml)
28
+ [![tests](https://github.com/ghga-de/ghga-transpiler/actions/workflows/tests.yaml/badge.svg)](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml)
21
29
  [![Coverage Status](https://coveralls.io/repos/github/ghga-de/ghga-transpiler/badge.svg?branch=main)](https://coveralls.io/github/ghga-de/ghga-transpiler?branch=main)
22
30
 
23
31
  # Ghga Transpiler
24
32
 
25
- GHGA-Transpiler - GHGA metadata XLSX to JSON transpilation
33
+ GHGA-Transpiler - excel to JSON converter
26
34
 
27
35
  ## Description
28
36
 
@@ -1,10 +1,10 @@
1
1
 
2
- [![tests](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml/badge.svg)](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml)
2
+ [![tests](https://github.com/ghga-de/ghga-transpiler/actions/workflows/tests.yaml/badge.svg)](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml)
3
3
  [![Coverage Status](https://coveralls.io/repos/github/ghga-de/ghga-transpiler/badge.svg?branch=main)](https://coveralls.io/github/ghga-de/ghga-transpiler?branch=main)
4
4
 
5
5
  # Ghga Transpiler
6
6
 
7
- GHGA-Transpiler - GHGA metadata XLSX to JSON transpilation
7
+ GHGA-Transpiler - excel to JSON converter
8
8
 
9
9
  ## Description
10
10
 
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["setuptools>=67.7.2"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ # please adapt to package name
7
+ name = "ghga_transpiler"
8
+ version = "2.0.0"
9
+ description = "GHGA-Transpiler - excel to JSON converter"
10
+ readme = "README.md"
11
+ authors = [
12
+ { name = "German Human Genome Phenome Archive (GHGA)", email = "contact@ghga.de" },
13
+ ]
14
+ requires-python = ">=3.9"
15
+ license = { text = "Apache 2.0" }
16
+ classifiers = [
17
+ "Development Status :: 1 - Planning",
18
+ "Operating System :: POSIX :: Linux",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "License :: OSI Approved :: Apache Software License",
23
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
24
+ "Topic :: Software Development :: Libraries",
25
+ "Intended Audience :: Developers",
26
+ ]
27
+ dependencies = [
28
+ "typer ~= 0.9.0",
29
+ "openpyxl >= 3.1.2, == 3.*",
30
+ "defusedxml >= 0.7, == 0.*",
31
+ "pydantic >=2, <3",
32
+ "PyYAML ~= 6.0",
33
+ "semver == 3.*"
34
+ ]
35
+
36
+ [project.urls]
37
+ # please adapt to package name
38
+ Repository = "https://github.com/ghga-de/ghga-transpiler"
39
+
40
+ [project.scripts]
41
+ # please adapt to package name
42
+ ghga-transpiler = "ghga_transpiler.__main__:run"
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -15,4 +15,13 @@
15
15
 
16
16
  """Short description of package""" # Please adapt to package
17
17
 
18
- __version__ = "1.2.0"
18
+ from importlib.metadata import version
19
+
20
+ from openpyxl.xml import DEFUSEDXML
21
+
22
+ __version__ = version(__package__)
23
+
24
+ if not DEFUSEDXML:
25
+ raise RuntimeError(
26
+ "The 'defusedxml' package must be present to safely run ghga-transpiler."
27
+ )
@@ -13,21 +13,27 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- """ CLI-specific wrappers around core functions."""
16
+ """CLI-specific wrappers around core functions."""
17
17
  import sys
18
18
  from pathlib import Path
19
19
  from typing import Optional
20
20
 
21
21
  import typer
22
22
 
23
- from ghga_transpiler import io
24
-
23
+ from . import __version__, io
25
24
  from .config.exceptions import UnknownVersionError
26
- from .core import convert_workbook
25
+ from .core import InvalidSematicVersion, convert_workbook
27
26
 
28
27
  cli = typer.Typer()
29
28
 
30
29
 
30
+ def version_callback(value: bool):
31
+ """Prints the package version"""
32
+ if value:
33
+ print(__version__)
34
+ raise typer.Exit()
35
+
36
+
31
37
  @cli.command()
32
38
  def transpile(
33
39
  spread_sheet: Path = typer.Argument(
@@ -43,15 +49,24 @@ def transpile(
43
49
  force: bool = typer.Option(
44
50
  False, "--force", "-f", help="Override output file if it exists."
45
51
  ),
52
+ version: bool = typer.Option(
53
+ False,
54
+ "--version",
55
+ "-v",
56
+ callback=version_callback,
57
+ is_eager=True,
58
+ help="Print package version",
59
+ ),
46
60
  ):
47
61
  """ghga-transpiler is a command line utility to transpile the official GHGA
48
62
  metadata XLSX workbooks to JSON. Please note that ghga-transpiler does not
49
63
  validate that the provided metadata is compliant with the GHGA Metadata
50
64
  Schema. This can be achieved by running ghga-validator on the JSON data
51
- generated by the ghga-transpiler."""
65
+ generated by the ghga-transpiler.
66
+ """
52
67
  try:
53
68
  ghga_workbook = io.read_workbook(spread_sheet)
54
- except (SyntaxError, UnknownVersionError) as exc:
69
+ except (SyntaxError, UnknownVersionError, InvalidSematicVersion) as exc:
55
70
  sys.exit(f"Unable to parse input file '{spread_sheet}': {exc}")
56
71
 
57
72
  converted = convert_workbook(ghga_workbook)
@@ -21,7 +21,7 @@ from importlib import resources
21
21
  from typing import Callable, Optional
22
22
 
23
23
  import yaml
24
- from pydantic import BaseModel, root_validator
24
+ from pydantic import BaseModel, model_validator
25
25
 
26
26
  from .exceptions import DuplicatedName, UnknownVersionError
27
27
 
@@ -40,11 +40,11 @@ class WorksheetSettings(BaseModel):
40
40
  """A data model for the per-worksheet settings of a transpiler config"""
41
41
 
42
42
  name: str
43
- header_row: Optional[int]
44
- start_row: Optional[int]
45
- start_column: Optional[int]
46
- end_column: Optional[int]
47
- transformations: Optional[dict[str, Callable]]
43
+ header_row: Optional[int] = None
44
+ start_row: Optional[int] = None
45
+ start_column: Optional[int] = None
46
+ end_column: Optional[int] = None
47
+ transformations: Optional[dict[str, Callable]] = None
48
48
 
49
49
 
50
50
  class Worksheet(BaseModel):
@@ -61,21 +61,21 @@ class Config(BaseModel):
61
61
  default_settings: DefaultSettings
62
62
  worksheets: list[Worksheet]
63
63
 
64
- @root_validator(pre=False)
65
- def get_param(cls, values): # pylint: disable=no-self-argument
64
+ @model_validator(mode="after")
65
+ def get_param(cls, values): # noqa
66
66
  """Function to manage parameters of global and worksheet specific configuration"""
67
- for sheet in values.get("worksheets"):
68
- for key in values.get("default_settings").__dict__:
67
+ for sheet in values.worksheets:
68
+ for key in values.default_settings.__dict__:
69
69
  if getattr(sheet.settings, key) is None:
70
- val = getattr(values.get("default_settings"), key)
70
+ val = getattr(values.default_settings, key)
71
71
  setattr(sheet.settings, key, val)
72
72
  return values
73
73
 
74
- @root_validator(pre=False)
75
- def check_name(cls, values): # pylint: disable=no-self-argument
74
+ @model_validator(mode="after")
75
+ def check_name(cls, values): # noqa
76
76
  """Function to ensure that each worksheets has a unique sheet_name and name attributes."""
77
77
  # Check for duplicate attribute names
78
- attrs_counter = Counter(ws.settings.name for ws in values["worksheets"])
78
+ attrs_counter = Counter(ws.settings.name for ws in values.worksheets)
79
79
  dup_attrs = [name for name, count in attrs_counter.items() if count > 1]
80
80
  if dup_attrs:
81
81
  raise DuplicatedName(
@@ -83,7 +83,7 @@ class Config(BaseModel):
83
83
  )
84
84
 
85
85
  # Check for duplicate worksheet names
86
- attrs_counter = Counter(ws.sheet_name for ws in values["worksheets"])
86
+ attrs_counter = Counter(ws.sheet_name for ws in values.worksheets)
87
87
  dup_ws_names = [name for name, count in attrs_counter.items() if count > 1]
88
88
  if dup_ws_names:
89
89
  raise DuplicatedName(
@@ -94,11 +94,10 @@ class Config(BaseModel):
94
94
 
95
95
  def load_config(version: str, package: resources.Package) -> Config:
96
96
  """Reads configuration yaml file from default location and creates a Config object"""
97
-
98
97
  config_resource = resources.files(package).joinpath(f"{version}.yaml")
99
98
  try:
100
99
  config_str = config_resource.read_text(encoding="utf8")
101
100
  except FileNotFoundError:
102
101
  # pylint: disable=raise-missing-from
103
- raise UnknownVersionError(f"Unknown metadata version: {version}")
104
- return Config.parse_obj(yaml.load(config_str, yaml.Loader)) # nosec
102
+ raise UnknownVersionError(f"Unknown metadata version: {version}") from None
103
+ return Config.model_validate(yaml.load(config_str, yaml.Loader)) # noqa # nosec
@@ -15,16 +15,17 @@
15
15
  #
16
16
 
17
17
  """This module contains functionalities for processing excel sheets into json object."""
18
- import re
19
18
  from importlib import resources
20
19
  from typing import Callable, Optional, Union
21
20
 
21
+ import semver
22
22
  from openpyxl import Workbook
23
23
 
24
- from ghga_transpiler import config
24
+ from . import config
25
25
 
26
- # pylint: disable=line-too-long
27
- SEMVER_REGEX = r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
26
+
27
+ class InvalidSematicVersion(Exception):
28
+ """Raised when a version string is invalid."""
28
29
 
29
30
 
30
31
  class GHGAWorkbook:
@@ -33,20 +34,28 @@ class GHGAWorkbook:
33
34
  def __init__(self, workbook: Workbook, configs_package: resources.Package):
34
35
  """Create a new GHGAWorkbook object from an XLSX workbook"""
35
36
  self.workbook = workbook
36
- self.version = GHGAWorkbook._get_version(workbook)
37
- self.config = config.load_config(self.version, configs_package)
37
+ self.wb_version = GHGAWorkbook._get_version(workbook)
38
+ self.config = config.load_config(self.major_minor_version, configs_package)
38
39
 
39
40
  @staticmethod
40
41
  def _get_version(workbook):
41
42
  """Function to get workbook version from the worksheet _properties"""
42
43
  if "__properties" in workbook.sheetnames:
43
- version = str(workbook["__properties"].cell(1, 1).value)
44
- if re.fullmatch(SEMVER_REGEX, version):
45
- return version
44
+ try:
45
+ return semver.Version.parse(workbook["__properties"].cell(1, 1).value)
46
+ except ValueError:
47
+ raise InvalidSematicVersion(
48
+ "Unable to extract metadata model version from the provided workbook (not a valid semantic version)."
49
+ ) from None
46
50
  raise SyntaxError(
47
- "Unable to extract metadata version from the provided workbook."
51
+ "Unable to extract metadata model version from the provided workbook (missing)."
48
52
  )
49
53
 
54
+ @property
55
+ def major_minor_version(self):
56
+ """Returns only major and minor version numbers"""
57
+ return f"{self.wb_version.major}.{self.wb_version.minor}"
58
+
50
59
 
51
60
  def get_worksheet_rows(
52
61
  worksheet,
@@ -81,7 +90,8 @@ def get_header(
81
90
 
82
91
  def convert_rows(header, rows) -> list[dict]:
83
92
  """Function to return list of dictionaries, rows as worksheet row values and
84
- column names as keys"""
93
+ column names as keys
94
+ """
85
95
  return [
86
96
  {
87
97
  key: value
@@ -24,15 +24,13 @@ from typing import Optional, TextIO
24
24
 
25
25
  from openpyxl import load_workbook
26
26
 
27
- from ghga_transpiler.core import GHGAWorkbook
27
+ from .core import GHGAWorkbook
28
28
 
29
29
 
30
30
  def read_workbook(
31
31
  path: Path, configs_package: resources.Package = "ghga_transpiler.configs"
32
32
  ) -> GHGAWorkbook:
33
- """
34
- Function to read-in a workbook
35
- """
33
+ """Function to read-in a workbook"""
36
34
  return GHGAWorkbook(load_workbook(path), configs_package=configs_package)
37
35
 
38
36
 
@@ -43,7 +41,8 @@ def _write_json(data: dict, file: TextIO):
43
41
 
44
42
  def write_json(data: dict, path: Optional[Path], force: bool) -> None:
45
43
  """Write the data provided as a dictionary to the specified output path or
46
- to stdout if the path is None."""
44
+ to stdout if the path is None.
45
+ """
47
46
  if path is None:
48
47
  _write_json(data, sys.stdout)
49
48
  elif path.exists() and not force:
@@ -38,7 +38,28 @@ def to_attributes() -> Callable:
38
38
  return dict(zip(("key", "value"), splitted))
39
39
 
40
40
  def split_mult(value: str) -> list[dict]:
41
- """Function to convert string to attributes"""
41
+ """Converts string to attributes"""
42
42
  return [split_one(elem) for elem in split_by_semicolon(value)]
43
43
 
44
44
  return split_mult
45
+
46
+
47
+ def snake_case(cv: str) -> str:
48
+ """Converts format of a string to SNAKE_CASE"""
49
+ return cv.replace(" ", "_").upper()
50
+
51
+
52
+ def to_snake_case() -> Callable:
53
+ """Returns a function that converts a string to SNAKE_CASE"""
54
+ return snake_case
55
+
56
+
57
+ def snake_case_list(value: str) -> list[str]:
58
+ """Combines the functions to split_by_semicolon and convert_to_snake_case"""
59
+ list_to_convert = split_by_semicolon(value)
60
+ return [snake_case(elem) for elem in list_to_convert]
61
+
62
+
63
+ def to_snake_case_list() -> Callable:
64
+ """Returns a function that converts a semicolon separated string into a list of snake-cased strings"""
65
+ return snake_case_list
@@ -1,28 +1,36 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ghga-transpiler
3
- Version: 1.2.0
4
- Summary: GHGA-Transpiler - GHGA metadata XLSX to JSON transpilation
5
- Home-page: https://github.com/ghga-de/ghga-transpiler
6
- Author: German Human Genome Phenome Archive (GHGA)
7
- Author-email: contact@ghga.de
3
+ Version: 2.0.0
4
+ Summary: GHGA-Transpiler - excel to JSON converter
5
+ Author-email: "German Human Genome Phenome Archive (GHGA)" <contact@ghga.de>
8
6
  License: Apache 2.0
7
+ Project-URL: Repository, https://github.com/ghga-de/ghga-transpiler
8
+ Classifier: Development Status :: 1 - Planning
9
9
  Classifier: Operating System :: POSIX :: Linux
10
10
  Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
11
13
  Classifier: License :: OSI Approved :: Apache Software License
12
14
  Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
13
- Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Classifier: Intended Audience :: Developers
14
17
  Requires-Python: >=3.9
15
- Description-Content-Type: text/markdown; charset=UTF-8
16
- Provides-Extra: all
18
+ Description-Content-Type: text/markdown
17
19
  License-File: LICENSE
20
+ Requires-Dist: typer~=0.9.0
21
+ Requires-Dist: openpyxl==3.*,>=3.1.2
22
+ Requires-Dist: defusedxml==0.*,>=0.7
23
+ Requires-Dist: pydantic<3,>=2
24
+ Requires-Dist: PyYAML~=6.0
25
+ Requires-Dist: semver==3.*
18
26
 
19
27
 
20
- [![tests](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml/badge.svg)](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml)
28
+ [![tests](https://github.com/ghga-de/ghga-transpiler/actions/workflows/tests.yaml/badge.svg)](https://github.com/ghga-de/ghga-transpiler/actions/workflows/unit_and_int_tests.yaml)
21
29
  [![Coverage Status](https://coveralls.io/repos/github/ghga-de/ghga-transpiler/badge.svg?branch=main)](https://coveralls.io/github/ghga-de/ghga-transpiler?branch=main)
22
30
 
23
31
  # Ghga Transpiler
24
32
 
25
- GHGA-Transpiler - GHGA metadata XLSX to JSON transpilation
33
+ GHGA-Transpiler - excel to JSON converter
26
34
 
27
35
  ## Description
28
36
 
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ghga_transpiler/__init__.py
5
+ src/ghga_transpiler/__main__.py
6
+ src/ghga_transpiler/cli.py
7
+ src/ghga_transpiler/core.py
8
+ src/ghga_transpiler/io.py
9
+ src/ghga_transpiler/transformations.py
10
+ src/ghga_transpiler.egg-info/PKG-INFO
11
+ src/ghga_transpiler.egg-info/SOURCES.txt
12
+ src/ghga_transpiler.egg-info/dependency_links.txt
13
+ src/ghga_transpiler.egg-info/entry_points.txt
14
+ src/ghga_transpiler.egg-info/requires.txt
15
+ src/ghga_transpiler.egg-info/top_level.txt
16
+ src/ghga_transpiler/config/__init__.py
17
+ src/ghga_transpiler/config/config.py
18
+ src/ghga_transpiler/config/exceptions.py
19
+ src/ghga_transpiler/configs/__init__.py
20
+ tests/test_convert_workbook.py
21
+ tests/test_create_config.py
22
+ tests/test_io.py
23
+ tests/test_process_workbook.py
@@ -0,0 +1,6 @@
1
+ typer~=0.9.0
2
+ openpyxl==3.*,>=3.1.2
3
+ defusedxml==0.*,>=0.7
4
+ pydantic<3,>=2
5
+ PyYAML~=6.0
6
+ semver==3.*
@@ -13,6 +13,9 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
+
17
+ """Tests for converting the workbook"""
18
+
16
19
  from ghga_transpiler import io
17
20
  from ghga_transpiler.core import convert_workbook
18
21
 
@@ -22,7 +25,6 @@ from .fixtures.utils import get_project_root
22
25
 
23
26
  def test_convert_workbook() -> None:
24
27
  """Function to test workbook to json conversion"""
25
-
26
28
  workbook_path = (
27
29
  get_project_root() / "tests" / "fixtures" / "workbooks" / "a_workbook.xlsx"
28
30
  )
@@ -13,6 +13,9 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
+
17
+ """Tests for creating the config"""
18
+
16
19
  from ghga_transpiler.config.config import (
17
20
  Config,
18
21
  DefaultSettings,
@@ -23,7 +26,6 @@ from ghga_transpiler.config.config import (
23
26
 
24
27
  def test_config_params() -> None:
25
28
  """Testing if default parameters of config yaml are used in the absence of worksheet settings"""
26
-
27
29
  books_sheet = Worksheet(
28
30
  sheet_name="books", settings=WorksheetSettings(name="books", end_column=3)
29
31
  )
@@ -30,7 +30,7 @@ def test_write_json_file(tmp_path):
30
30
  out_path = tmp_path.joinpath("out.json")
31
31
  io.write_json(data=EXPECTED_CONVERSION, path=out_path, force=False)
32
32
 
33
- with open(file=out_path, mode="r", encoding="utf8") as in_file:
33
+ with open(file=out_path, encoding="utf8") as in_file:
34
34
  data = json.load(fp=in_file)
35
35
  assert data == EXPECTED_CONVERSION
36
36
 
@@ -16,27 +16,31 @@
16
16
  """Unit tests for core functions"""
17
17
 
18
18
  import pytest
19
+ import semver
19
20
 
20
- from ghga_transpiler.core import GHGAWorkbook
21
+ from ghga_transpiler.core import GHGAWorkbook, InvalidSematicVersion
21
22
 
22
23
  from .fixtures.utils import create_workbook
23
24
 
24
25
 
25
26
  def test_extract_good_version() -> None:
26
27
  """Function to check if the version extraction correctly gets workbook
27
- version from _properties worksheet"""
28
+ version from _properties worksheet
29
+ """
28
30
  workbook = create_workbook("__properties")
29
31
  value = workbook["__properties"].cell(row=1, column=1, value="10.3.1-rc2").value
30
32
  # pylint: disable=protected-access
31
33
  version = GHGAWorkbook._get_version(workbook)
32
- assert version == value
34
+ assert version == semver.Version.parse(str(value))
33
35
 
34
36
 
35
37
  def test_extract_bad_version() -> None:
36
38
  """Function to check if the version extraction correctly fails when an non
37
- semver string is specified in the _properties worksheet"""
39
+ semver string is specified in the _properties worksheet
40
+ """
38
41
  workbook = create_workbook("__properties")
39
42
  workbook["__properties"].cell(row=1, column=1, value="20.10.3.1")
40
- with pytest.raises(SyntaxError):
43
+
44
+ with pytest.raises(InvalidSematicVersion):
41
45
  # pylint: disable=protected-access
42
46
  GHGAWorkbook._get_version(workbook)