otlmow-template 0.10__py3-none-any.whl → 0.11rc1__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.
- otlmow_template/SubsetTemplateCreator.py +18 -8
- {otlmow_template-0.10.dist-info → otlmow_template-0.11rc1.dist-info}/METADATA +3 -2
- otlmow_template-0.11rc1.dist-info/RECORD +10 -0
- {otlmow_template-0.10.dist-info → otlmow_template-0.11rc1.dist-info}/WHEEL +1 -1
- otlmow_template-0.10.dist-info/RECORD +0 -10
- {otlmow_template-0.10.dist-info → otlmow_template-0.11rc1.dist-info}/LICENSE +0 -0
- {otlmow_template-0.10.dist-info → otlmow_template-0.11rc1.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
import csv
|
|
2
3
|
import logging
|
|
3
4
|
import ntpath
|
|
4
5
|
import os
|
|
5
6
|
import site
|
|
6
7
|
import tempfile
|
|
8
|
+
from asyncio import sleep
|
|
7
9
|
from pathlib import Path
|
|
8
10
|
|
|
9
11
|
|
|
@@ -20,6 +22,7 @@ from otlmow_model.OtlmowModel.BaseClasses.OTLObject import dynamic_create_instan
|
|
|
20
22
|
from otlmow_model.OtlmowModel.Helpers.generated_lists import get_hardcoded_relation_dict
|
|
21
23
|
from otlmow_modelbuilder.OSLOCollector import OSLOCollector
|
|
22
24
|
from otlmow_modelbuilder.SQLDataClasses.OSLOClass import OSLOClass
|
|
25
|
+
from universalasync import async_to_sync_wraps
|
|
23
26
|
|
|
24
27
|
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
25
28
|
|
|
@@ -40,7 +43,8 @@ class SubsetTemplateCreator:
|
|
|
40
43
|
collector.collect_all(include_abstract=True)
|
|
41
44
|
return collector
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
@async_to_sync_wraps
|
|
47
|
+
async def generate_template_from_subset(self, path_to_subset: Path, path_to_template_file_and_extension: Path,
|
|
44
48
|
ignore_relations: bool = True, filter_attributes_by_subset: bool = True,
|
|
45
49
|
**kwargs):
|
|
46
50
|
tempdir = Path(tempfile.gettempdir()) / 'temp-otlmow'
|
|
@@ -48,24 +52,26 @@ class SubsetTemplateCreator:
|
|
|
48
52
|
os.makedirs(tempdir)
|
|
49
53
|
test = ntpath.basename(path_to_template_file_and_extension)
|
|
50
54
|
temporary_path = Path(tempdir) / test
|
|
51
|
-
instantiated_attributes = (self.generate_basic_template(
|
|
55
|
+
instantiated_attributes = (await self.generate_basic_template(
|
|
52
56
|
path_to_subset=path_to_subset, temporary_path=temporary_path, ignore_relations=ignore_relations,
|
|
53
57
|
path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
54
58
|
filter_attributes_by_subset=filter_attributes_by_subset, **kwargs))
|
|
55
59
|
extension = os.path.splitext(path_to_template_file_and_extension)[-1].lower()
|
|
56
60
|
if extension == '.xlsx':
|
|
57
|
-
self.alter_excel_template(path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
61
|
+
await self.alter_excel_template(path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
58
62
|
temporary_path=temporary_path,
|
|
59
63
|
path_to_subset=path_to_subset, instantiated_attributes=instantiated_attributes,
|
|
60
64
|
**kwargs)
|
|
61
65
|
elif extension == '.csv':
|
|
62
|
-
self.determine_multiplicity_csv(
|
|
66
|
+
await self.determine_multiplicity_csv(
|
|
67
|
+
path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
63
68
|
path_to_subset=path_to_subset,
|
|
64
69
|
instantiated_attributes=instantiated_attributes,
|
|
65
70
|
temporary_path=temporary_path,
|
|
66
71
|
**kwargs)
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
@async_to_sync_wraps
|
|
74
|
+
async def generate_basic_template(self, path_to_subset: Path, path_to_template_file_and_extension: Path,
|
|
69
75
|
temporary_path: Path, ignore_relations: bool = True, **kwargs):
|
|
70
76
|
list_of_otl_objectUri = None
|
|
71
77
|
if kwargs is not None:
|
|
@@ -105,7 +111,7 @@ class SubsetTemplateCreator:
|
|
|
105
111
|
DotnotationHelper.clear_list_of_list_attributes(instance)
|
|
106
112
|
|
|
107
113
|
converter = OtlmowConverter()
|
|
108
|
-
converter.from_objects_to_file(file_path=temporary_path,
|
|
114
|
+
await converter.from_objects_to_file(file_path=temporary_path,
|
|
109
115
|
sequence_of_objects=otl_objects, **kwargs)
|
|
110
116
|
path_is_split = kwargs.get('split_per_type', True)
|
|
111
117
|
extension = os.path.splitext(path_to_template_file_and_extension)[-1].lower()
|
|
@@ -116,7 +122,8 @@ class SubsetTemplateCreator:
|
|
|
116
122
|
return instantiated_attributes
|
|
117
123
|
|
|
118
124
|
@classmethod
|
|
119
|
-
|
|
125
|
+
@async_to_sync_wraps
|
|
126
|
+
async def alter_excel_template(cls, path_to_template_file_and_extension: Path, path_to_subset: Path,
|
|
120
127
|
instantiated_attributes: list, temporary_path, **kwargs):
|
|
121
128
|
generate_choice_list = kwargs.get('generate_choice_list', False)
|
|
122
129
|
add_geo_artefact = kwargs.get('add_geo_artefact', False)
|
|
@@ -125,6 +132,7 @@ class SubsetTemplateCreator:
|
|
|
125
132
|
amount_of_examples = kwargs.get('amount_of_examples', 0)
|
|
126
133
|
if add_attribute_info and amount_of_examples == 0:
|
|
127
134
|
amount_of_examples = 1
|
|
135
|
+
await sleep(0)
|
|
128
136
|
wb = load_workbook(temporary_path)
|
|
129
137
|
wb.create_sheet('Keuzelijsten')
|
|
130
138
|
# Volgorde is belangrijk! Eerst rijen verwijderen indien nodig dan choice list toevoegen,
|
|
@@ -144,9 +152,11 @@ class SubsetTemplateCreator:
|
|
|
144
152
|
file_location = os.path.dirname(temporary_path)
|
|
145
153
|
[f.unlink() for f in Path(file_location).glob("*") if f.is_file()]
|
|
146
154
|
|
|
147
|
-
|
|
155
|
+
@async_to_sync_wraps
|
|
156
|
+
async def determine_multiplicity_csv(self, path_to_template_file_and_extension: Path, path_to_subset: Path,
|
|
148
157
|
instantiated_attributes: list, temporary_path: Path, **kwargs):
|
|
149
158
|
path_is_split = kwargs.get('split_per_type', True)
|
|
159
|
+
await sleep(0)
|
|
150
160
|
if path_is_split is False:
|
|
151
161
|
self.alter_csv_template(path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
152
162
|
temporary_path=temporary_path, path_to_subset=path_to_subset, **kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: otlmow_template
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11rc1
|
|
4
4
|
Author-email: David Vlaminck <david.vlaminck@mow.vlaanderen.be>, Jasper Berton <jasperberton1@telenet.be>
|
|
5
5
|
License: GNU GENERAL PUBLIC LICENSE
|
|
6
6
|
Version 3, 29 June 2007
|
|
@@ -699,6 +699,7 @@ Description-Content-Type: text/markdown
|
|
|
699
699
|
License-File: LICENSE
|
|
700
700
|
Requires-Dist: otlmow-converter>=1.7
|
|
701
701
|
Requires-Dist: otlmow-modelbuilder>=0.25
|
|
702
|
+
Requires-Dist: universalasync>=0.4.0
|
|
702
703
|
|
|
703
704
|
# OTLMOW-Template
|
|
704
705
|
[](https://pypi.org/project/otlmow-template/)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
otlmow_template/CsvTemplateCreator.py,sha256=PQq2zGmliWk0N9bhYNB7ZEa8PWV16OTbvoHh3--qCMs,7538
|
|
2
|
+
otlmow_template/ExcelTemplateCreator.py,sha256=wW-7Uq2Gzr1vHYMO1I7TtqZSBTVFFSWotHvjwzCelV4,10853
|
|
3
|
+
otlmow_template/SubsetTemplateCreator.py,sha256=DpTwiRJihigmCpZSmT1Iz3-2Gep0EBpyygXjVwxPfnY,25524
|
|
4
|
+
otlmow_template/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
otlmow_template/Exceptions/MissingTypeUriException.py,sha256=DSKwywmP9Bq8n7rzBoDcEPlxvC1IChx18QIHFUCTtdA,51
|
|
6
|
+
otlmow_template-0.11rc1.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
7
|
+
otlmow_template-0.11rc1.dist-info/METADATA,sha256=lfKPmGuFW-3zyPkYuOtkakBPAaCMRNOjKNj6-neRkTY,44040
|
|
8
|
+
otlmow_template-0.11rc1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
otlmow_template-0.11rc1.dist-info/top_level.txt,sha256=zPgBoaTLG-avoOLySlwOUEtHaFyA5Vc5wJqkSeX1l6A,16
|
|
10
|
+
otlmow_template-0.11rc1.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
otlmow_template/CsvTemplateCreator.py,sha256=PQq2zGmliWk0N9bhYNB7ZEa8PWV16OTbvoHh3--qCMs,7538
|
|
2
|
-
otlmow_template/ExcelTemplateCreator.py,sha256=wW-7Uq2Gzr1vHYMO1I7TtqZSBTVFFSWotHvjwzCelV4,10853
|
|
3
|
-
otlmow_template/SubsetTemplateCreator.py,sha256=FQNaOp-3_EelKijpOBT5KjwZ3X30yD5K9xpmY0euDLo,25225
|
|
4
|
-
otlmow_template/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
otlmow_template/Exceptions/MissingTypeUriException.py,sha256=DSKwywmP9Bq8n7rzBoDcEPlxvC1IChx18QIHFUCTtdA,51
|
|
6
|
-
otlmow_template-0.10.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
7
|
-
otlmow_template-0.10.dist-info/METADATA,sha256=0FveCcFEZtR8CqXMNDG0VPhWurSVOtXOtEzsfPMfsik,44000
|
|
8
|
-
otlmow_template-0.10.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
9
|
-
otlmow_template-0.10.dist-info/top_level.txt,sha256=zPgBoaTLG-avoOLySlwOUEtHaFyA5Vc5wJqkSeX1l6A,16
|
|
10
|
-
otlmow_template-0.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|