grzctl 0.1.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.
@@ -0,0 +1,195 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ #pdm.lock
114
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
115
+ # in version control.
116
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
117
+ .pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
122
+ __pypackages__/
123
+
124
+ # Celery stuff
125
+ celerybeat-schedule
126
+ celerybeat.pid
127
+
128
+ # SageMath parsed files
129
+ *.sage.py
130
+
131
+ # Environments
132
+ .env
133
+ .venv
134
+ env/
135
+ venv/
136
+ ENV/
137
+ env.bak/
138
+ venv.bak/
139
+
140
+ # Spyder project settings
141
+ .spyderproject
142
+ .spyproject
143
+
144
+ # Rope project settings
145
+ .ropeproject
146
+
147
+ # mkdocs documentation
148
+ /site
149
+
150
+ # mypy
151
+ .mypy_cache/
152
+ .dmypy.json
153
+ dmypy.json
154
+
155
+ # Pyre type checker
156
+ .pyre/
157
+
158
+ # pytype static type analyzer
159
+ .pytype/
160
+
161
+ # Cython debug symbols
162
+ cython_debug/
163
+
164
+ # PyCharm
165
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
166
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
168
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
169
+ #.idea/
170
+
171
+ # Abstra
172
+ # Abstra is an AI-powered process automation framework.
173
+ # Ignore directories containing user credentials, local state, and settings.
174
+ # Learn more at https://abstra.io/docs
175
+ .abstra/
176
+
177
+ # Visual Studio Code
178
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
179
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
180
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
181
+ # you could uncomment the following to ignore the entire vscode folder
182
+ # .vscode/
183
+
184
+ # Ruff stuff:
185
+ .ruff_cache/
186
+
187
+ # PyPI configuration file
188
+ .pypirc
189
+
190
+ # Cursor
191
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
192
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
193
+ # refer to https://docs.cursor.com/context/ignore-files
194
+ .cursorignore
195
+ .cursorindexingignore
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2025-06-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * migrate to monorepo configuration ([36c7360](https://github.com/BfArM-MVH/grz-tools/commit/36c736044ce09473cc664b4471117465c5cab9a3))
grzctl-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: grzctl
3
+ Version: 0.1.0
4
+ Summary: Control CLI for GRZ administrators.
5
+ Project-URL: Homepage, https://github.com/BfArM-MVH/grz-tools
6
+ Project-URL: Repository, https://github.com/BfArM-MVH/grz-tools
7
+ Project-URL: Documentation, https://github.com/BfArM-MVH/grz-tools/tree/main/packages/grzctl
8
+ Project-URL: Issues, https://github.com/BfArM-MVH/grz-tools/issues
9
+ Author-email: Koray Kirli <koraykirli@gmail.com>, Mathias Lesche <mathias.lesche@tu-dresden.de>, "Florian R. Hölzlwimmer" <git.ich@frhoelzlwimmer.de>, Till Hartmann <till.hartmann@bih-charite.de>, Thomas Sell <thomas.sell@bih-charite.de>, Travis Wrightsman <travis.wrightsman@uni-tuebingen.de>
10
+ License-Expression: MIT
11
+ Keywords: GDC,GRZ,S3
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: boto3<2,>=1.36
16
+ Requires-Dist: click<9,>=8.1.7
17
+ Requires-Dist: crypt4gh<2,>=1.7
18
+ Requires-Dist: grz-common
19
+ Requires-Dist: grz-db
20
+ Requires-Dist: grz-pydantic-models>=1.3.0
21
+ Requires-Dist: jsonschema<5,>=4.23.0
22
+ Requires-Dist: platformdirs<5,>=4.3.6
23
+ Requires-Dist: pydantic-settings<2.10,>=2.9.0
24
+ Requires-Dist: pydantic<2.10,>=2.9.2
25
+ Requires-Dist: pysam==0.23.*
26
+ Requires-Dist: pyyaml<7,>=6.0.2
27
+ Requires-Dist: requests<3,>=2.32.3
28
+ Requires-Dist: rich==13.*
29
+ Requires-Dist: tqdm<5,>=4.66.5
30
+ Description-Content-Type: text/markdown
31
+
32
+ GRZ internal tooling.
grzctl-0.1.0/README.md ADDED
@@ -0,0 +1 @@
1
+ GRZ internal tooling.
@@ -0,0 +1,59 @@
1
+ [project]
2
+ name = "grzctl"
3
+ description = "Control CLI for GRZ administrators."
4
+ readme = "README.md"
5
+ license = "MIT"
6
+ authors = [
7
+ { name = "Koray Kirli", email = "koraykirli@gmail.com" },
8
+ { name = "Mathias Lesche", email = "mathias.lesche@tu-dresden.de" },
9
+ { name = "Florian R. Hölzlwimmer", email = "git.ich@frhoelzlwimmer.de" },
10
+ { name = "Till Hartmann", email = "till.hartmann@bih-charite.de" },
11
+ { name = "Thomas Sell", email = "thomas.sell@bih-charite.de" },
12
+ { name = "Travis Wrightsman", email = "travis.wrightsman@uni-tuebingen.de" }
13
+ ]
14
+ dynamic = ["version"]
15
+ dependencies = [
16
+ "boto3 >=1.36,<2",
17
+ "click >=8.1.7,<9",
18
+ "crypt4gh >=1.7,<2",
19
+ "jsonschema >=4.23.0,<5",
20
+ "pyyaml >=6.0.2,<7",
21
+ "tqdm >=4.66.5,<5",
22
+ "pydantic >=2.9.2,<2.10",
23
+ "pydantic-settings >=2.9.0,<2.10",
24
+ "platformdirs >=4.3.6,<5",
25
+ "grz-pydantic-models >=1.3.0",
26
+ "pysam ==0.23.*",
27
+ "rich ==13.*",
28
+ "requests >=2.32.3,<3",
29
+ "grz-db",
30
+ "grz-common",
31
+ ]
32
+ classifiers = [
33
+ "Programming Language :: Python :: 3",
34
+ "Operating System :: OS Independent"
35
+ ]
36
+ requires-python = ">=3.12"
37
+ keywords = ["GRZ", "GDC", "S3"]
38
+
39
+ [tool.uv.sources]
40
+ grz-common = { workspace = true }
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/BfArM-MVH/grz-tools"
44
+ Repository = "https://github.com/BfArM-MVH/grz-tools"
45
+ Documentation = "https://github.com/BfArM-MVH/grz-tools/tree/main/packages/grzctl"
46
+ Issues = "https://github.com/BfArM-MVH/grz-tools/issues"
47
+
48
+ [project.scripts]
49
+ grzctl = "grzctl.cli:main"
50
+
51
+ [build-system]
52
+ requires = ["hatchling"]
53
+ build-backend = "hatchling.build"
54
+
55
+ [tool.hatch.version]
56
+ path = "src/grzctl/__init__.py"
57
+
58
+ [tool.hatch.build.targets.wheel]
59
+ packages = ["src/grzctl"]
@@ -0,0 +1,5 @@
1
+ """
2
+ GRZ Control CLI for GRZ administrators.
3
+ """
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,113 @@
1
+ """
2
+ CLI module for handling command-line interface operations for GRZ administrators.
3
+ """
4
+
5
+ PACKAGE_ROOT = "grzctl"
6
+
7
+ import logging
8
+ import logging.config
9
+ from importlib.metadata import version
10
+
11
+ import click
12
+ import grz_pydantic_models.submission.metadata
13
+ from grz_cli.commands.encrypt import encrypt
14
+ from grz_cli.commands.submit import submit
15
+ from grz_cli.commands.upload import upload
16
+ from grz_cli.commands.validate import validate
17
+ from grz_common.logging_setup import add_filelogger
18
+
19
+ from .commands.archive import archive
20
+ from .commands.clean import clean
21
+ from .commands.consent import consent
22
+ from .commands.db import db
23
+ from .commands.decrypt import decrypt
24
+ from .commands.download import download
25
+ from .commands.list_submissions import list_submissions
26
+ from .commands.pruefbericht import pruefbericht
27
+
28
+ log = logging.getLogger(PACKAGE_ROOT + ".cli")
29
+
30
+
31
+ class OrderedGroup(click.Group):
32
+ """
33
+ A click Group that keeps track of the order in which commands are added.
34
+ """
35
+
36
+ def list_commands(self, ctx):
37
+ """Return the list of commands in the order they were added."""
38
+ return list(self.commands.keys())
39
+
40
+
41
+ def build_cli():
42
+ """
43
+ Factory for building the CLI application.
44
+ """
45
+
46
+ @click.group(
47
+ cls=OrderedGroup,
48
+ help="GRZ Control CLI for GRZ administrators.",
49
+ )
50
+ @click.version_option(
51
+ version=version("grzctl"),
52
+ prog_name="grzctl",
53
+ message=f"%(prog)s v%(version)s (metadata schema versions: {', '.join(grz_pydantic_models.submission.metadata.get_supported_versions())})",
54
+ )
55
+ @click.option("--log-file", metavar="FILE", type=str, help="Path to log file")
56
+ @click.option(
57
+ "--log-level",
58
+ default="INFO",
59
+ type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]),
60
+ help="Set the log level (default: INFO)",
61
+ )
62
+ def cli(log_file: str | None = None, log_level: str = "INFO"):
63
+ """
64
+ Command-line interface function for setting up logging.
65
+
66
+ :param log_file: Path to the log file. If provided, a file logger will be added.
67
+ :param log_level: Log level for the logger. It should be one of the following:
68
+ DEBUG, INFO, WARNING, ERROR, CRITICAL.
69
+ """
70
+ if log_file:
71
+ add_filelogger(
72
+ log_file,
73
+ log_level.upper(),
74
+ ) # Add file logger
75
+
76
+ # show only time and log level in STDOUT
77
+ logging.basicConfig(
78
+ format="%(asctime)s - %(levelname)s - %(message)s",
79
+ )
80
+
81
+ # set the log level for this package
82
+ logging.getLogger(PACKAGE_ROOT).setLevel(log_level.upper())
83
+
84
+ log.debug("Logging setup complete.")
85
+
86
+ # For convenience, include grz-cli commands as well.
87
+ cli.add_command(validate)
88
+ cli.add_command(encrypt)
89
+ cli.add_command(upload)
90
+ cli.add_command(submit)
91
+
92
+ cli.add_command(list_submissions, name="list")
93
+ cli.add_command(download)
94
+ cli.add_command(decrypt)
95
+ cli.add_command(archive)
96
+ cli.add_command(clean)
97
+ cli.add_command(consent)
98
+ cli.add_command(pruefbericht)
99
+ cli.add_command(db)
100
+
101
+ return cli
102
+
103
+
104
+ def main():
105
+ """
106
+ Main entry point for the CLI application.
107
+ """
108
+ cli = build_cli()
109
+ cli()
110
+
111
+
112
+ if __name__ == "__main__":
113
+ main()
@@ -0,0 +1,3 @@
1
+ """
2
+ Command modules for the grzctl package.
3
+ """
@@ -0,0 +1,43 @@
1
+ """Command for archiving a submission."""
2
+
3
+ import logging
4
+ from pathlib import Path
5
+
6
+ import click
7
+ from grz_common.workers.worker import Worker
8
+
9
+ from ..models.config import ArchiveConfig
10
+
11
+ log = logging.getLogger(__name__)
12
+
13
+ from grz_common.cli import config_file, submission_dir, threads
14
+
15
+
16
+ @click.command()
17
+ @submission_dir
18
+ @config_file
19
+ @threads
20
+ def archive(
21
+ submission_dir,
22
+ config_file,
23
+ threads,
24
+ ):
25
+ """
26
+ Archive a submission within a GRZ/GDC.
27
+ """
28
+ config = ArchiveConfig.from_path(config_file)
29
+
30
+ log.info("Starting archival...")
31
+
32
+ submission_dir = Path(submission_dir)
33
+
34
+ worker_inst = Worker(
35
+ metadata_dir=submission_dir / "metadata",
36
+ files_dir=submission_dir / "files",
37
+ log_dir=submission_dir / "logs",
38
+ encrypted_files_dir=submission_dir / "encrypted_files",
39
+ threads=threads,
40
+ )
41
+ worker_inst.archive(config.s3)
42
+
43
+ log.info("Archival finished!")
@@ -0,0 +1,77 @@
1
+ """Command for cleaning a submission from the S3 inbox."""
2
+
3
+ import logging
4
+ import sys
5
+
6
+ import click
7
+ from grz_common.cli import config_file, submission_id
8
+ from grz_common.transfer import init_s3_resource
9
+
10
+ from ..models.config import CleanConfig
11
+
12
+ log = logging.getLogger(__name__)
13
+
14
+
15
+ @click.command()
16
+ @submission_id
17
+ @config_file
18
+ @click.option("--yes-i-really-mean-it", is_flag=True)
19
+ def clean(submission_id, config_file, yes_i_really_mean_it: bool):
20
+ """
21
+ Remove all files of a submission from the S3 inbox.
22
+ """
23
+ config = CleanConfig.from_path(config_file)
24
+ bucket_name = config.s3.bucket
25
+
26
+ if yes_i_really_mean_it or click.confirm(
27
+ f"Are you SURE you want to delete the submission from the inbox bucket ({bucket_name})?",
28
+ default=False,
29
+ show_default=True,
30
+ ):
31
+ prefix = submission_id
32
+ prefix = prefix + "/" if not prefix.endswith("/") else prefix
33
+
34
+ resource = init_s3_resource(config.s3)
35
+ bucket = resource.Bucket(bucket_name)
36
+ log.info(f"Deleting {prefix} from {bucket_name} …")
37
+
38
+ responses = bucket.objects.filter(Prefix=prefix).delete()
39
+ if not responses:
40
+ sys.exit(f"No objects with prefix '{prefix}' in bucket '{bucket_name}' found for deletion.")
41
+
42
+ successfully_deleted_keys = []
43
+ errors_encountered = []
44
+ objects_found = 0
45
+
46
+ # responses is a list of dicts reporting the result of the deletion API call
47
+ # because the API does things in batches
48
+ for response in responses:
49
+ deleted_batch = response.get("Deleted", [])
50
+ for deleted_obj in deleted_batch:
51
+ key = deleted_obj.get("Key")
52
+ if key:
53
+ successfully_deleted_keys.append(key)
54
+
55
+ errors_batch = response.get("Errors", [])
56
+ for error_obj in errors_batch:
57
+ errors_encountered.append(
58
+ {
59
+ "Key": error_obj.get("Key", "N/A"),
60
+ "Code": error_obj.get("Code", "N/A"),
61
+ "Message": error_obj.get("Message", "N/A"),
62
+ }
63
+ )
64
+
65
+ objects_found += len(deleted_batch) + len(errors_batch)
66
+
67
+ log.info(f"Total objects attempted to delete: {objects_found}")
68
+ log.info(f"Successfully deleted: {len(successfully_deleted_keys)} objects.")
69
+ log.info(f"Failed to delete: {len(errors_encountered)} objects.")
70
+
71
+ for error in errors_encountered:
72
+ log.error(f" - Key: {error['Key']}, Code: {error['Code']}, Message: {error['Message']}")
73
+
74
+ if errors_encountered:
75
+ sys.exit(f"Errors encountered while deleting objects from bucket '{bucket_name}'. See log for details.")
76
+
77
+ log.info(f"Deleted '{prefix}' from '{bucket_name}'.")
@@ -0,0 +1,116 @@
1
+ """Command for determining whether a submission is consented for research."""
2
+
3
+ import enum
4
+ import json
5
+ import logging
6
+ import sys
7
+ import typing
8
+ from pathlib import Path
9
+ from typing import Any
10
+
11
+ import click
12
+ import rich.console
13
+ import rich.table
14
+ import rich.text
15
+ from grz_common.cli import output_json, show_details, submission_dir
16
+ from grz_common.workers.submission import GrzSubmissionMetadata, SubmissionMetadata
17
+
18
+ log = logging.getLogger(__name__)
19
+
20
+ MDAT_WISSENSCHAFTLICH_NUTZEN_EU_DSGVO_NIVEAU = "2.16.840.1.113883.3.1937.777.24.5.3.8"
21
+
22
+
23
+ class FhirProvision(enum.StrEnum):
24
+ """Possible FHIR Provision options."""
25
+
26
+ PERMIT = "permit"
27
+ DENY = "deny"
28
+
29
+
30
+ @click.command()
31
+ @submission_dir
32
+ @output_json
33
+ @show_details
34
+ def consent(submission_dir, output_json, show_details):
35
+ """
36
+ Check if a submission is consented for research.
37
+
38
+ Returns 'true' if consented, 'false' if not.
39
+ A submission is considered consented if all donors have consented for research, that is
40
+ the FHIR MII IG Consent profiles all have a "permit" provision for code 2.16.840.1.113883.3.1937.777.24.5.3.8
41
+ """
42
+ metadata = SubmissionMetadata(Path(submission_dir) / "metadata" / "metadata.json").content
43
+
44
+ consents = _gather_consent_information(metadata)
45
+ overall_consent = _submission_has_research_consent(consents)
46
+
47
+ match output_json, show_details:
48
+ case True, True:
49
+ json.dump(consents, sys.stdout)
50
+ case True, False:
51
+ json.dump(overall_consent, sys.stdout)
52
+ case False, True:
53
+ _print_rich_table(consents)
54
+ case False, False:
55
+ click.echo(str(overall_consent).lower())
56
+
57
+
58
+ def _submission_has_research_consent(consents):
59
+ return all(consents.values())
60
+
61
+
62
+ def _print_rich_table(consents: dict[str, bool]):
63
+ console = rich.console.Console()
64
+ table = rich.table.Table()
65
+ table.add_column("Donor", no_wrap=True)
66
+ table.add_column("Research Consent", no_wrap=True)
67
+ for donor_pseudonym, consent_value in consents.items():
68
+ research_consent = rich.text.Text(
69
+ "True" if consent_value else "False",
70
+ style="green" if consent_value else "red",
71
+ )
72
+ table.add_row(
73
+ donor_pseudonym,
74
+ research_consent,
75
+ )
76
+ console.print(table)
77
+
78
+
79
+ def _gather_consent_information(metadata: GrzSubmissionMetadata) -> dict[str, bool]:
80
+ consents = {donor.donor_pseudonym: False for donor in metadata.donors}
81
+ for donor in metadata.donors:
82
+ for research_consent in donor.research_consents:
83
+ mii_consent = research_consent.scope
84
+ if isinstance(mii_consent, str):
85
+ mii_consent = json.loads(mii_consent)
86
+ mii_consent = typing.cast(dict[str, Any], mii_consent)
87
+
88
+ if top_level_provision := mii_consent.get("provision"):
89
+ if top_level_provision.get("type") != FhirProvision.DENY:
90
+ sys.exit(
91
+ f"The root provision type must be deny, not {top_level_provision.get('type')}, "
92
+ f"since the profile follows an opt-in consent scheme. "
93
+ f"Explicit opt-in consents must be made via nested provisions."
94
+ )
95
+ else:
96
+ nested_provisions = top_level_provision.get("provision")
97
+ consents[donor.donor_pseudonym] = _check_nested_provisions(nested_provisions)
98
+
99
+ return consents
100
+
101
+
102
+ def _check_nested_provisions(provisions: list[dict[str, Any]]) -> bool:
103
+ for provision in provisions:
104
+ if provision.get("type") == FhirProvision.PERMIT:
105
+ for codeable_concept in provision.get("code", []):
106
+ for coding in codeable_concept.get("coding", []):
107
+ code = coding.get("code")
108
+ if isinstance(code, str):
109
+ if code == MDAT_WISSENSCHAFTLICH_NUTZEN_EU_DSGVO_NIVEAU:
110
+ return True
111
+ elif isinstance(code, dict):
112
+ if (value := code.get("value")) and value == MDAT_WISSENSCHAFTLICH_NUTZEN_EU_DSGVO_NIVEAU:
113
+ return True
114
+ else:
115
+ raise ValueError(code, f"Expected str or dict, got {type(code)}")
116
+ return False