dapla-toolbelt-metadata 0.2.6__tar.gz → 0.3.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.
Potentially problematic release.
This version of dapla-toolbelt-metadata might be problematic. Click here for more details.
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/PKG-INFO +1 -1
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/pyproject.toml +1 -1
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/config.py +6 -1
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/core.py +2 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/user_info.py +27 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/utility/utils.py +13 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/LICENSE +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/README.md +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/__init__.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/__init__.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/code_list.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/dapla_dataset_path_info.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/dataset_parser.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/external_sources/__init__.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/external_sources/external_sources.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/model_backwards_compatibility.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/model_validation.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/py.typed +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/statistic_subject_mapping.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/utility/__init__.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/utility/constants.py +0 -0
- {dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/utility/enums.py +0 -0
|
@@ -41,7 +41,7 @@ def _load_dotenv_file() -> None:
|
|
|
41
41
|
def _get_config_item(item: str) -> str | None:
|
|
42
42
|
"""Get a config item. Makes sure all access is logged."""
|
|
43
43
|
_load_dotenv_file()
|
|
44
|
-
value = os.
|
|
44
|
+
value = os.environ.get(item)
|
|
45
45
|
logger.debug("Config accessed. %s", item)
|
|
46
46
|
return value
|
|
47
47
|
|
|
@@ -78,3 +78,8 @@ def get_dapla_service() -> DaplaService | None:
|
|
|
78
78
|
def get_oidc_token() -> str | None:
|
|
79
79
|
"""Get the JWT token from the environment."""
|
|
80
80
|
return _get_config_item("OIDC_TOKEN")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def get_group_context() -> str | None:
|
|
84
|
+
"""Get the JWT token from the environment."""
|
|
85
|
+
return _get_config_item("DAPLA_GROUP_CONTEXT")
|
{dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/core.py
RENAMED
|
@@ -42,6 +42,7 @@ from dapla_metadata.datasets.utility.utils import (
|
|
|
42
42
|
num_obligatory_variables_fields_completed,
|
|
43
43
|
)
|
|
44
44
|
from dapla_metadata.datasets.utility.utils import override_dataset_fields
|
|
45
|
+
from dapla_metadata.datasets.utility.utils import set_dataset_owner
|
|
45
46
|
from dapla_metadata.datasets.utility.utils import set_default_values_dataset
|
|
46
47
|
from dapla_metadata.datasets.utility.utils import set_default_values_variables
|
|
47
48
|
|
|
@@ -189,6 +190,7 @@ class Datadoc:
|
|
|
189
190
|
self._set_metadata(existing_metadata or extracted_metadata)
|
|
190
191
|
set_default_values_variables(self.variables)
|
|
191
192
|
set_default_values_dataset(self.dataset)
|
|
193
|
+
set_dataset_owner(self.dataset)
|
|
192
194
|
self._create_variables_lookup()
|
|
193
195
|
|
|
194
196
|
def _get_existing_file_path(
|
|
@@ -86,3 +86,30 @@ def get_user_info_for_current_platform() -> UserInfo:
|
|
|
86
86
|
"Was not possible to retrieve user information! Some fields may not be set.",
|
|
87
87
|
)
|
|
88
88
|
return UnknownUserInfo()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def get_owner() -> str:
|
|
92
|
+
"""Returns the owner read from the GROUP_CONTEXT environment variable."""
|
|
93
|
+
if group := config.get_group_context():
|
|
94
|
+
return parse_team_name(group)
|
|
95
|
+
msg = "DAPLA_GROUP_CONTEXT environment variable not found"
|
|
96
|
+
raise OSError(msg)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def parse_team_name(group: str) -> str:
|
|
100
|
+
"""Parses the group to get the current team.
|
|
101
|
+
|
|
102
|
+
>>> parse_team_name(dapla-metadata-developers)
|
|
103
|
+
(dapla-metadata)
|
|
104
|
+
|
|
105
|
+
>>> parse_team_name(dapla-metadata-data-admins)
|
|
106
|
+
(dapla-metadata)
|
|
107
|
+
|
|
108
|
+
>>> parse_team_name(dapla-metadata)
|
|
109
|
+
(dapla)
|
|
110
|
+
|
|
111
|
+
>>> parse_team_name(dapla-metadata-not-real-name)
|
|
112
|
+
(dapla-metadata-not-real)
|
|
113
|
+
"""
|
|
114
|
+
parts = group.split("-")
|
|
115
|
+
return "-".join(parts[:-2] if group.endswith("data-admins") else parts[:-1])
|
|
@@ -14,6 +14,7 @@ from datadoc_model.model import Assessment
|
|
|
14
14
|
from datadoc_model.model import DataSetState
|
|
15
15
|
from datadoc_model.model import VariableRole
|
|
16
16
|
|
|
17
|
+
from dapla_metadata.datasets import user_info
|
|
17
18
|
from dapla_metadata.datasets.utility.constants import (
|
|
18
19
|
DATASET_FIELDS_FROM_EXISTING_METADATA,
|
|
19
20
|
)
|
|
@@ -139,6 +140,18 @@ def set_default_values_dataset(dataset: model.Dataset) -> None:
|
|
|
139
140
|
dataset.contains_personal_data = False
|
|
140
141
|
|
|
141
142
|
|
|
143
|
+
def set_dataset_owner(dataset: model.Dataset) -> None:
|
|
144
|
+
"""Sets the owner of the dataset from the DAPLA_GROUP_CONTEXT enviornment variable.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
dataset: The dataset object to set default values on.
|
|
148
|
+
"""
|
|
149
|
+
try:
|
|
150
|
+
dataset.owner = user_info.get_owner()
|
|
151
|
+
except OSError:
|
|
152
|
+
logger.exception("Failed to find environment variable DAPLA_GROUP_CONTEXT")
|
|
153
|
+
|
|
154
|
+
|
|
142
155
|
def set_variables_inherit_from_dataset(
|
|
143
156
|
dataset: model.Dataset,
|
|
144
157
|
variables: list,
|
|
File without changes
|
|
File without changes
|
{dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dapla_toolbelt_metadata-0.2.6 → dapla_toolbelt_metadata-0.3.0}/src/dapla_metadata/datasets/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|