ghga-transpiler 2.3.1__py3-none-any.whl → 3.0.0rc1__py3-none-any.whl

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.
@@ -1,135 +0,0 @@
1
- ghga_metadata_version: 1.1.0
2
- default_settings:
3
- header_row: 1
4
- start_row: 7
5
- start_column: 1
6
- transformations:
7
- attributes: !!python/object/apply:ghga_transpiler.transformations.to_attributes []
8
- format: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
9
- forward_or_reverse: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
10
- worksheets:
11
- - settings:
12
- end_column: 6
13
- name: analyses
14
- sheet_name: Analysis
15
- - settings:
16
- end_column: 9
17
- name: analysis_process_output_files
18
- sheet_name: AnalysisProcessOutputFile
19
- - settings:
20
- end_column: 5
21
- name: analysis_processes
22
- transformations:
23
- study_input_files: !!python/object/apply:ghga_transpiler.transformations.to_list []
24
- sample_input_files: !!python/object/apply:ghga_transpiler.transformations.to_list []
25
- sequencing_process_input_files: !!python/object/apply:ghga_transpiler.transformations.to_list []
26
- sheet_name: AnalysisProcess
27
- - settings:
28
- end_column: 10
29
- name: biospecimens
30
- transformations:
31
- vital_status_at_sampling: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
32
- age_at_sampling: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
33
- sheet_name: Biospecimen
34
- - settings:
35
- end_column: 9
36
- name: conditions
37
- transformations:
38
- disease_or_healthy: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
39
- case_control_status: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
40
- mutant_or_wildtype: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
41
- sheet_name: Condition
42
- - settings:
43
- end_column: 3
44
- name: data_access_committees
45
- sheet_name: DataAccessCommittee
46
- - settings:
47
- end_column: 8
48
- name: data_access_policies
49
- transformations:
50
- data_use_modifiers: !!python/object/apply:ghga_transpiler.transformations.to_snake_case_list []
51
- data_use_permission: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
52
- sheet_name: DataAccessPolicy
53
- - settings:
54
- end_column: 5
55
- name: datasets
56
- transformations:
57
- types: !!python/object/apply:ghga_transpiler.transformations.to_list []
58
- sheet_name: Dataset
59
- - settings:
60
- end_column: 6
61
- name: individuals
62
- transformations:
63
- ancestries: !!python/object/apply:ghga_transpiler.transformations.to_list []
64
- phenotypic_features: !!python/object/apply:ghga_transpiler.transformations.to_list []
65
- karyotype: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
66
- sex: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
67
- sheet_name: Individual
68
- - settings:
69
- end_column: 14
70
- name: library_preparation_protocols
71
- transformations:
72
- target_regions: !!python/object/apply:ghga_transpiler.transformations.to_list []
73
- attributes: !!python/object/apply:ghga_transpiler.transformations.to_attributes []
74
- library_layout: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
75
- library_type: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
76
- library_selection: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
77
- library_preparation_kit_retail_name: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
78
- rnaseq_strandedness: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
79
- primer: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
80
- end_bias: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
81
- sheet_name: LibraryPreparationProtocol
82
- - settings:
83
- end_column: 9
84
- name: publications
85
- transformations:
86
- xref: !!python/object/apply:ghga_transpiler.transformations.to_list []
87
- sheet_name: Publication
88
- - settings:
89
- end_column: 9
90
- name: sample_files
91
- sheet_name: SampleFile
92
- - settings:
93
- end_column: 10
94
- name: samples
95
- transformations:
96
- xref: !!python/object/apply:ghga_transpiler.transformations.to_list []
97
- type: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
98
- sheet_name: Sample
99
- - settings:
100
- end_column: 7
101
- name: sequencing_experiments
102
- sheet_name: SequencingExperiment
103
- - settings:
104
- end_column: 9
105
- name: sequencing_process_files
106
- sheet_name: SequencingProcessFile
107
- - settings:
108
- end_column: 12
109
- name: sequencing_processes
110
- sheet_name: SequencingProcess
111
- - settings:
112
- end_column: 17
113
- name: sequencing_protocols
114
- transformations:
115
- instrument_model: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
116
- flow_cell_type: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
117
- umi_barcode_read: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
118
- sample_barcode_read: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
119
- sheet_name: SequencingProtocol
120
- - settings:
121
- end_column: 6
122
- name: studies
123
- transformations:
124
- affiliations: !!python/object/apply:ghga_transpiler.transformations.to_list []
125
- attributes: !!python/object/apply:ghga_transpiler.transformations.to_attributes []
126
- type: !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
127
- sheet_name: Study
128
- - settings:
129
- end_column: 9
130
- name: study_files
131
- sheet_name: StudyFile
132
- - settings:
133
- end_column: 4
134
- name: trios
135
- sheet_name: Trio
@@ -1,170 +0,0 @@
1
- ghga_metadata_version: 2.0.0
2
- default_settings:
3
- header_row: 1
4
- start_row: 7
5
- start_column: 1
6
- transformations:
7
- attributes:
8
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
9
- format:
10
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
11
- worksheets:
12
- - settings:
13
- end_column: 7
14
- name: analyses
15
- transformations:
16
- research_data_files:
17
- !!python/object/apply:ghga_transpiler.transformations.to_list []
18
- sheet_name: Analysis
19
- - settings:
20
- end_column: 11
21
- name: analysis_methods
22
- transformations:
23
- parameters:
24
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
25
- software_versions:
26
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
27
- sheet_name: AnalysisMethod
28
- - settings:
29
- end_column: 7
30
- name: analysis_method_supporting_files
31
- sheet_name: AnalysisMethodSupportingFile
32
- - settings:
33
- end_column: 7
34
- name: studies
35
- transformations:
36
- affiliations:
37
- !!python/object/apply:ghga_transpiler.transformations.to_list []
38
- attributes:
39
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
40
- types:
41
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case_list []
42
- attributes:
43
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
44
- sheet_name: Study
45
- - settings:
46
- end_column: 10
47
- name: individuals
48
- transformations:
49
- phenotypic_features_terms:
50
- !!python/object/apply:ghga_transpiler.transformations.to_list []
51
- phenotypic_features_ids:
52
- !!python/object/apply:ghga_transpiler.transformations.to_list []
53
- diagnosis_ids:
54
- !!python/object/apply:ghga_transpiler.transformations.to_list []
55
- diagnosis_terms:
56
- !!python/object/apply:ghga_transpiler.transformations.to_list []
57
- sex:
58
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
59
- ancestry_terms:
60
- !!python/object/apply:ghga_transpiler.transformations.to_list []
61
- ancestry_ids:
62
- !!python/object/apply:ghga_transpiler.transformations.to_list []
63
- sheet_name: Individual
64
- - settings:
65
- end_column: 7
66
- name: individual_supporting_files
67
- sheet_name: IndividualSupportingFile
68
- - settings:
69
- end_column: 21
70
- name: samples
71
- transformations:
72
- type:
73
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
74
- storage:
75
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
76
- disease_or_healthy:
77
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
78
- case_control_status:
79
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
80
- xref: !!python/object/apply:ghga_transpiler.transformations.to_list []
81
- biospecimen_age_at_sampling:
82
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
83
- biospecimen_vital_status_at_sampling:
84
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
85
- biospecimen_isolation:
86
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
87
- biospecimen_storage:
88
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
89
- attributes:
90
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
91
- sheet_name: Sample
92
- - settings:
93
- end_column: 23
94
- name: experiment_methods
95
- transformations:
96
- library_type:
97
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
98
- library_selection_methods:
99
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case_list []
100
- library_preparation_kit_retail_name:
101
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
102
- primer:
103
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
104
- end_bias:
105
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
106
- target_regions:
107
- !!python/object/apply:ghga_transpiler.transformations.to_list []
108
- rnaseq_strandedness:
109
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
110
- instrument_model:
111
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
112
- sequencing_layout:
113
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
114
- flow_cell_type:
115
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
116
- sample_barcode_read:
117
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
118
- sequencing_layout:
119
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
120
- attributes:
121
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
122
- sheet_name: ExperimentMethod
123
- - settings:
124
- end_column: 7
125
- name: experiment_method_supporting_files
126
- sheet_name: ExperimentMethodSupportingFile
127
- - settings:
128
- end_column: 8
129
- name: experiments
130
- sheet_name: Experiment
131
- - settings:
132
- end_column: 9
133
- name: research_data_files
134
- transformations:
135
- experiments:
136
- !!python/object/apply:ghga_transpiler.transformations.to_list []
137
- format:
138
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
139
- sheet_name: ResearchDataFile
140
- - settings:
141
- end_column: 7
142
- name: process_data_files
143
- sheet_name: ProcessDataFile
144
- - settings:
145
- end_column: 7
146
- name: datasets
147
- transformations:
148
- types: !!python/object/apply:ghga_transpiler.transformations.to_list []
149
- sheet_name: Dataset
150
- - settings:
151
- end_column: 11
152
- name: data_access_policies
153
- transformations:
154
- data_use_modifier_terms:
155
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case_list []
156
- data_use_permission_term:
157
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
158
- data_use_modifier_ids:
159
- !!python/object/apply:ghga_transpiler.transformations.to_list []
160
- sheet_name: DataAccessPolicy
161
- - settings:
162
- end_column: 4
163
- name: data_access_committees
164
- sheet_name: DataAccessCommittee
165
- - settings:
166
- end_column: 9
167
- name: publications
168
- transformations:
169
- xref: !!python/object/apply:ghga_transpiler.transformations.to_list []
170
- sheet_name: Publication
@@ -1,172 +0,0 @@
1
- ghga_metadata_version: 2.1.0
2
- default_settings:
3
- header_row: 1
4
- start_row: 7
5
- start_column: 1
6
- transformations:
7
- attributes:
8
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
9
- format:
10
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
11
- worksheets:
12
- - settings:
13
- end_column: 7
14
- name: analyses
15
- transformations:
16
- research_data_files:
17
- !!python/object/apply:ghga_transpiler.transformations.to_list []
18
- sheet_name: Analysis
19
- - settings:
20
- end_column: 12
21
- name: analysis_methods
22
- transformations:
23
- parameters:
24
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
25
- software_versions:
26
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
27
- attributes:
28
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
29
- sheet_name: AnalysisMethod
30
- - settings:
31
- end_column: 7
32
- name: analysis_method_supporting_files
33
- sheet_name: AnalysisMethodSupportingFile
34
- - settings:
35
- end_column: 7
36
- name: studies
37
- transformations:
38
- affiliations:
39
- !!python/object/apply:ghga_transpiler.transformations.to_list []
40
- attributes:
41
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
42
- types:
43
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case_list []
44
- attributes:
45
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
46
- sheet_name: Study
47
- - settings:
48
- end_column: 10
49
- name: individuals
50
- transformations:
51
- phenotypic_features_terms:
52
- !!python/object/apply:ghga_transpiler.transformations.to_list []
53
- phenotypic_features_ids:
54
- !!python/object/apply:ghga_transpiler.transformations.to_list []
55
- diagnosis_ids:
56
- !!python/object/apply:ghga_transpiler.transformations.to_list []
57
- diagnosis_terms:
58
- !!python/object/apply:ghga_transpiler.transformations.to_list []
59
- sex:
60
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
61
- ancestry_terms:
62
- !!python/object/apply:ghga_transpiler.transformations.to_list []
63
- ancestry_ids:
64
- !!python/object/apply:ghga_transpiler.transformations.to_list []
65
- sheet_name: Individual
66
- - settings:
67
- end_column: 7
68
- name: individual_supporting_files
69
- sheet_name: IndividualSupportingFile
70
- - settings:
71
- end_column: 21
72
- name: samples
73
- transformations:
74
- type:
75
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
76
- storage:
77
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
78
- disease_or_healthy:
79
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
80
- case_control_status:
81
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
82
- xref: !!python/object/apply:ghga_transpiler.transformations.to_list []
83
- biospecimen_age_at_sampling:
84
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
85
- biospecimen_vital_status_at_sampling:
86
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
87
- biospecimen_isolation:
88
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
89
- biospecimen_storage:
90
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
91
- attributes:
92
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
93
- sheet_name: Sample
94
- - settings:
95
- end_column: 23
96
- name: experiment_methods
97
- transformations:
98
- library_type:
99
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
100
- library_selection_methods:
101
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case_list []
102
- library_preparation_kit_retail_name:
103
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
104
- primer:
105
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
106
- end_bias:
107
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
108
- target_regions:
109
- !!python/object/apply:ghga_transpiler.transformations.to_list []
110
- rnaseq_strandedness:
111
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
112
- instrument_model:
113
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
114
- sequencing_layout:
115
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
116
- flow_cell_type:
117
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
118
- sample_barcode_read:
119
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
120
- sequencing_layout:
121
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
122
- attributes:
123
- !!python/object/apply:ghga_transpiler.transformations.to_attributes []
124
- sheet_name: ExperimentMethod
125
- - settings:
126
- end_column: 7
127
- name: experiment_method_supporting_files
128
- sheet_name: ExperimentMethodSupportingFile
129
- - settings:
130
- end_column: 8
131
- name: experiments
132
- sheet_name: Experiment
133
- - settings:
134
- end_column: 9
135
- name: research_data_files
136
- transformations:
137
- experiments:
138
- !!python/object/apply:ghga_transpiler.transformations.to_list []
139
- format:
140
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
141
- sheet_name: ResearchDataFile
142
- - settings:
143
- end_column: 7
144
- name: process_data_files
145
- sheet_name: ProcessDataFile
146
- - settings:
147
- end_column: 7
148
- name: datasets
149
- transformations:
150
- types: !!python/object/apply:ghga_transpiler.transformations.to_list []
151
- sheet_name: Dataset
152
- - settings:
153
- end_column: 11
154
- name: data_access_policies
155
- transformations:
156
- data_use_modifier_terms:
157
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case_list []
158
- data_use_permission_term:
159
- !!python/object/apply:ghga_transpiler.transformations.to_snake_case []
160
- data_use_modifier_ids:
161
- !!python/object/apply:ghga_transpiler.transformations.to_list []
162
- sheet_name: DataAccessPolicy
163
- - settings:
164
- end_column: 4
165
- name: data_access_committees
166
- sheet_name: DataAccessCommittee
167
- - settings:
168
- end_column: 9
169
- name: publications
170
- transformations:
171
- xref: !!python/object/apply:ghga_transpiler.transformations.to_list []
172
- sheet_name: Publication
@@ -1,16 +0,0 @@
1
- # Copyright 2021 - 2025 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
2
- # for the German Human Genome-Phenome Archive (GHGA)
3
-
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
-
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- #
ghga_transpiler/core.py DELETED
@@ -1,155 +0,0 @@
1
- # Copyright 2021 - 2025 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
2
- # for the German Human Genome-Phenome Archive (GHGA)
3
-
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
-
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- #
17
-
18
- """This module contains functionalities for processing excel sheets into json object."""
19
-
20
- from __future__ import annotations
21
-
22
- from collections.abc import Callable
23
- from importlib import resources
24
-
25
- import semver
26
- from openpyxl import Workbook
27
-
28
- from . import config
29
-
30
-
31
- class InvalidSematicVersion(Exception):
32
- """Raised when a version string is invalid."""
33
-
34
-
35
- class GHGAWorkbook:
36
- """A GHGA metadata XLSX workbook"""
37
-
38
- def __init__(self, workbook: Workbook, configs_package: resources.Package):
39
- """Create a new GHGAWorkbook object from an XLSX workbook"""
40
- self.workbook = workbook
41
- self.wb_version = GHGAWorkbook._get_version(workbook)
42
- self.config = config.load_config(self.major_minor_version, configs_package)
43
-
44
- @staticmethod
45
- def _get_version(workbook):
46
- """Function to get workbook version from the worksheet _properties"""
47
- if "__properties" in workbook.sheetnames:
48
- try:
49
- return semver.Version.parse(workbook["__properties"].cell(1, 1).value)
50
- except ValueError:
51
- raise InvalidSematicVersion(
52
- "Unable to extract metadata model version from the provided workbook (not a valid semantic version)."
53
- ) from None
54
- raise SyntaxError(
55
- "Unable to extract metadata model version from the provided workbook (missing)."
56
- )
57
-
58
- @property
59
- def major_minor_version(self):
60
- """Returns only major and minor version numbers"""
61
- return f"{self.wb_version.major}.{self.wb_version.minor}"
62
-
63
-
64
- def get_worksheet_rows(
65
- worksheet,
66
- min_row: int | None,
67
- max_row: int,
68
- min_col: int | None,
69
- max_col: int | None,
70
- ) -> list:
71
- """Function to create a list of rows of a worksheet"""
72
- return list(
73
- row
74
- for row in worksheet.iter_rows(
75
- min_row, max_row, min_col, max_col, values_only=True
76
- )
77
- if not all(cell is None for cell in row)
78
- )
79
-
80
-
81
- def get_header(
82
- worksheet,
83
- header_row: int | None,
84
- min_col: int | None,
85
- max_col: int | None,
86
- ) -> list[str]:
87
- """Function to return a list column names of a worksheet"""
88
- return list(
89
- cell.value
90
- for row in worksheet.iter_rows(header_row, header_row, min_col, max_col)
91
- for cell in row
92
- )
93
-
94
-
95
- def convert_rows(header, rows) -> list[dict]:
96
- """Function to return list of dictionaries, rows as worksheet row values and
97
- column names as keys
98
- """
99
- return [
100
- {
101
- key: value
102
- for key, value in zip(header, row)
103
- if value is not None and value != ""
104
- }
105
- for row in rows
106
- ]
107
-
108
-
109
- def transform_rows(
110
- rows: list[dict], transformations: dict[str, Callable] | None
111
- ) -> list[dict]:
112
- """Transforms row values if it is applicable with a given function"""
113
- transformed = []
114
- for row in rows:
115
- transformed_row = {}
116
- for key, value in row.items():
117
- if transformations and key in transformations:
118
- transformed_row[key] = transformations[key](value)
119
- else:
120
- transformed_row[key] = value
121
- transformed.append(transformed_row)
122
- return transformed
123
-
124
-
125
- def convert_workbook(ghga_workbook: GHGAWorkbook) -> dict:
126
- """Function to convert an input spreadsheet into JSON"""
127
- converted_workbook = {}
128
- for sheet in ghga_workbook.config.worksheets:
129
- if sheet.settings is not None:
130
- if sheet.sheet_name in ghga_workbook.workbook:
131
- rows = get_worksheet_rows(
132
- ghga_workbook.workbook[sheet.sheet_name],
133
- sheet.settings.start_row,
134
- ghga_workbook.workbook[sheet.sheet_name].max_row,
135
- sheet.settings.start_column,
136
- sheet.settings.end_column,
137
- )
138
-
139
- header = get_header(
140
- ghga_workbook.workbook[sheet.sheet_name],
141
- sheet.settings.header_row,
142
- sheet.settings.start_column,
143
- sheet.settings.end_column,
144
- )
145
- converted_rows = convert_rows(header, rows)
146
- transformed_rows = transform_rows(
147
- converted_rows, sheet.settings.transformations
148
- )
149
- converted_workbook[sheet.settings.name] = transformed_rows
150
- else:
151
- converted_workbook[sheet.settings.name] = []
152
-
153
- else:
154
- raise ValueError(f"{sheet.settings} will never be None")
155
- return converted_workbook
@@ -1,21 +0,0 @@
1
- ghga_transpiler/__init__.py,sha256=b_JlBjNvngOiIolsfKKbwonyfOtS7b5_LJKLuB5LyNQ,908
2
- ghga_transpiler/__main__.py,sha256=k82ZsGuAOTrbqB4rCNkGOS-AWU8GICtD1_owfiey-Sk,847
3
- ghga_transpiler/cli.py,sha256=CvRQdiprRj1ZHjXgHpZ7JhDoAum7WB-sdFyMKknjtxk,2522
4
- ghga_transpiler/core.py,sha256=Fhf5pICDmVPKrUOhQNo6uN-mZB8mA1Vlyq3VGeeVSZ8,5235
5
- ghga_transpiler/io.py,sha256=e9DT5l5UumX2NcBJOkrR0y7ho_FPvK914WeFRZ4rOjw,1805
6
- ghga_transpiler/transformations.py,sha256=th320v3teZwjn13T-xS9n2_lCrBo5Wrl9wq0qOnbMEs,2222
7
- ghga_transpiler/config/__init__.py,sha256=CsnuJcqYMBx5zDcMgAzuKGRs5GQSS9N0evzDZ-T_g7k,817
8
- ghga_transpiler/config/config.py,sha256=YlIMQwnnpi8BelrdHtbZpJsp9RfwHCDZ56tCvU89wts,3823
9
- ghga_transpiler/config/exceptions.py,sha256=WB0YM5hJAn7iVGB_SY0p6Q4D0do1ti7AM4pKnMyVfLc,1090
10
- ghga_transpiler/configs/0.10.yaml,sha256=hsS8xwzJ00SRSb-VIfM-oM8UM0hOdR3xeuflf1fra4Y,5683
11
- ghga_transpiler/configs/1.0.yaml,sha256=MgSEkDpZjn7I76uLFAfpCfmOqOaCBjEojn6VDX6TnUc,5683
12
- ghga_transpiler/configs/1.1.yaml,sha256=rgxTV7bEVMwk1UeJ8hAeCZcqTwX10KXQKoaYnpV0bxI,5683
13
- ghga_transpiler/configs/2.0.yaml,sha256=3lwXFjtbEW-mWGj99d3PaWJflLnuy7WAS5AvNubDJlI,6637
14
- ghga_transpiler/configs/2.1.yaml,sha256=A-vJbxUcW0yyAKpgz2IkN81n92wxIC2A3sYEq-UZ9d0,6738
15
- ghga_transpiler/configs/__init__.py,sha256=xL0pfHoTdBh0LhdqA8lpdhp3W68HJVXF7AURhBM7pU4,686
16
- ghga_transpiler-2.3.1.dist-info/licenses/LICENSE,sha256=nKgIWA3zoWy18_YSW6e9Gd6_p7d7ccwjNZrfJzvKALE,11452
17
- ghga_transpiler-2.3.1.dist-info/METADATA,sha256=RKXPB_H8N5uLyKugDxk2ptbUG0jxsV4xLaVijDh3C8c,4452
18
- ghga_transpiler-2.3.1.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
19
- ghga_transpiler-2.3.1.dist-info/entry_points.txt,sha256=Fr_VQJynZZl95NXjrQW2gE0bCocgjKVNEZQpaLls8po,65
20
- ghga_transpiler-2.3.1.dist-info/top_level.txt,sha256=TksRpDO3Y4mvK-B09UhQU3ceZpG19fljNlVDGTfjg8o,16
21
- ghga_transpiler-2.3.1.dist-info/RECORD,,