otlmow-template 0.5__tar.gz → 0.7__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.
- {otlmow_template-0.5 → otlmow_template-0.7}/PKG-INFO +2 -2
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template/SubsetTemplateCreator.py +24 -17
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template.egg-info/PKG-INFO +2 -2
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template.egg-info/requires.txt +1 -1
- {otlmow_template-0.5 → otlmow_template-0.7}/pyproject.toml +2 -2
- {otlmow_template-0.5 → otlmow_template-0.7}/LICENSE +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/README.md +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template/CsvTemplateCreator.py +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template/ExcelTemplateCreator.py +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template/Exceptions/MissingTypeUriException.py +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template/__init__.py +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template.egg-info/SOURCES.txt +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template.egg-info/dependency_links.txt +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template.egg-info/top_level.txt +0 -0
- {otlmow_template-0.5 → otlmow_template-0.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: otlmow_template
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7
|
|
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
|
|
@@ -697,7 +697,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
697
697
|
Requires-Python: >=3.9
|
|
698
698
|
Description-Content-Type: text/markdown
|
|
699
699
|
License-File: LICENSE
|
|
700
|
-
Requires-Dist: otlmow-converter>=
|
|
700
|
+
Requires-Dist: otlmow-converter>=1.6
|
|
701
701
|
Requires-Dist: otlmow-modelbuilder>=0.24
|
|
702
702
|
|
|
703
703
|
# OTLMOW-Template
|
|
@@ -19,6 +19,7 @@ from otlmow_model.OtlmowModel.BaseClasses.KeuzelijstField import KeuzelijstField
|
|
|
19
19
|
from otlmow_model.OtlmowModel.BaseClasses.OTLObject import dynamic_create_instance_from_uri
|
|
20
20
|
from otlmow_model.OtlmowModel.Helpers.generated_lists import get_hardcoded_relation_dict
|
|
21
21
|
from otlmow_modelbuilder.OSLOCollector import OSLOCollector
|
|
22
|
+
from otlmow_modelbuilder.SQLDataClasses.OSLOClass import OSLOClass
|
|
22
23
|
|
|
23
24
|
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
24
25
|
|
|
@@ -40,15 +41,17 @@ class SubsetTemplateCreator:
|
|
|
40
41
|
return collector
|
|
41
42
|
|
|
42
43
|
def generate_template_from_subset(self, path_to_subset: Path, path_to_template_file_and_extension: Path,
|
|
43
|
-
ignore_relations: bool = True,
|
|
44
|
+
ignore_relations: bool = True, filter_attributes_by_subset: bool = True,
|
|
45
|
+
**kwargs):
|
|
44
46
|
tempdir = Path(tempfile.gettempdir()) / 'temp-otlmow'
|
|
45
47
|
if not tempdir.exists():
|
|
46
48
|
os.makedirs(tempdir)
|
|
47
49
|
test = ntpath.basename(path_to_template_file_and_extension)
|
|
48
50
|
temporary_path = Path(tempdir) / test
|
|
49
|
-
instantiated_attributes = self.generate_basic_template(
|
|
51
|
+
instantiated_attributes = (self.generate_basic_template(
|
|
50
52
|
path_to_subset=path_to_subset, temporary_path=temporary_path, ignore_relations=ignore_relations,
|
|
51
|
-
path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
53
|
+
path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
54
|
+
filter_attributes_by_subset=filter_attributes_by_subset, **kwargs))
|
|
52
55
|
extension = os.path.splitext(path_to_template_file_and_extension)[-1].lower()
|
|
53
56
|
if extension == '.xlsx':
|
|
54
57
|
self.alter_excel_template(path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
@@ -64,7 +67,12 @@ class SubsetTemplateCreator:
|
|
|
64
67
|
|
|
65
68
|
def generate_basic_template(self, path_to_subset: Path, path_to_template_file_and_extension: Path,
|
|
66
69
|
temporary_path: Path, ignore_relations: bool = True, **kwargs):
|
|
70
|
+
list_of_otl_objectUri = None
|
|
71
|
+
if kwargs is not None:
|
|
72
|
+
list_of_otl_objectUri = kwargs.get('list_of_otl_objectUri', None)
|
|
67
73
|
collector = self._load_collector_from_subset_path(path_to_subset=path_to_subset)
|
|
74
|
+
filtered_class_list = self.filters_classes_by_subset(
|
|
75
|
+
collector=collector, list_of_otl_objectUri=list_of_otl_objectUri)
|
|
68
76
|
otl_objects = []
|
|
69
77
|
amount_of_examples = kwargs.get('amount_of_examples', 0)
|
|
70
78
|
model_directory = None
|
|
@@ -72,25 +80,24 @@ class SubsetTemplateCreator:
|
|
|
72
80
|
model_directory = kwargs.get('model_directory', None)
|
|
73
81
|
relation_dict = get_hardcoded_relation_dict(model_directory=model_directory)
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
generate_dummy_records = 1
|
|
84
|
+
if amount_of_examples > 1:
|
|
85
|
+
generate_dummy_records = amount_of_examples
|
|
86
|
+
|
|
87
|
+
for class_object in [cl for cl in filtered_class_list if cl.abstract == 0]:
|
|
76
88
|
if ignore_relations and class_object.objectUri in relation_dict:
|
|
77
89
|
continue
|
|
78
|
-
|
|
79
|
-
if amount_of_examples != 0:
|
|
80
|
-
for _ in range(amount_of_examples):
|
|
81
|
-
instance = dynamic_create_instance_from_uri(class_object.objectUri, model_directory=model_directory)
|
|
82
|
-
if instance is None:
|
|
83
|
-
continue
|
|
84
|
-
instance.fill_with_dummy_data()
|
|
85
|
-
otl_objects.append(instance)
|
|
86
|
-
else:
|
|
90
|
+
for _ in range(generate_dummy_records):
|
|
87
91
|
instance = dynamic_create_instance_from_uri(class_object.objectUri, model_directory=model_directory)
|
|
88
92
|
if instance is None:
|
|
89
93
|
continue
|
|
90
|
-
|
|
94
|
+
attributen = collector.find_attributes_by_class(class_object)
|
|
95
|
+
for attribute_object in attributen:
|
|
96
|
+
attr = getattr(instance, '_' + attribute_object.name)
|
|
97
|
+
attr.fill_with_dummy_data()
|
|
91
98
|
otl_objects.append(instance)
|
|
92
99
|
|
|
93
|
-
|
|
100
|
+
DotnotationHelper.clear_list_of_list_attributes(instance)
|
|
94
101
|
|
|
95
102
|
converter = OtlmowConverter()
|
|
96
103
|
converter.from_objects_to_file(file_path=temporary_path,
|
|
@@ -145,11 +152,11 @@ class SubsetTemplateCreator:
|
|
|
145
152
|
[f.unlink() for f in Path(file_location).glob("*") if f.is_file()]
|
|
146
153
|
|
|
147
154
|
@classmethod
|
|
148
|
-
def
|
|
155
|
+
def filters_classes_by_subset(cls, collector: OSLOCollector,
|
|
156
|
+
list_of_otl_objectUri: [str] = None) -> list[OSLOClass]:
|
|
149
157
|
if list_of_otl_objectUri is None:
|
|
150
158
|
list_of_otl_objectUri = []
|
|
151
159
|
|
|
152
|
-
collector = cls._load_collector_from_subset_path(path_to_subset=path_to_subset)
|
|
153
160
|
if list_of_otl_objectUri == []:
|
|
154
161
|
return collector.classes
|
|
155
162
|
return [x for x in collector.classes if x.objectUri in list_of_otl_objectUri]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: otlmow_template
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7
|
|
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
|
|
@@ -697,7 +697,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
697
697
|
Requires-Python: >=3.9
|
|
698
698
|
Description-Content-Type: text/markdown
|
|
699
699
|
License-File: LICENSE
|
|
700
|
-
Requires-Dist: otlmow-converter>=
|
|
700
|
+
Requires-Dist: otlmow-converter>=1.6
|
|
701
701
|
Requires-Dist: otlmow-modelbuilder>=0.24
|
|
702
702
|
|
|
703
703
|
# OTLMOW-Template
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
otlmow-converter>=
|
|
1
|
+
otlmow-converter>=1.6
|
|
2
2
|
otlmow-modelbuilder>=0.24
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "otlmow_template"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.7"
|
|
8
8
|
authors = [{name = "David Vlaminck", email = "david.vlaminck@mow.vlaanderen.be"},
|
|
9
9
|
{name = "Jasper Berton", email = "jasperberton1@telenet.be"},]
|
|
10
10
|
readme = "README.md"
|
|
@@ -29,7 +29,7 @@ classifiers = [
|
|
|
29
29
|
]
|
|
30
30
|
requires-python = ">=3.9"
|
|
31
31
|
dependencies = [
|
|
32
|
-
'otlmow-converter >=
|
|
32
|
+
'otlmow-converter >= 1.6',
|
|
33
33
|
'otlmow-modelbuilder >= 0.24',
|
|
34
34
|
]
|
|
35
35
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{otlmow_template-0.5 → otlmow_template-0.7}/otlmow_template/Exceptions/MissingTypeUriException.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|