otlmow-template 0.6__py3-none-any.whl → 0.7__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 +19 -17
- {otlmow_template-0.6.dist-info → otlmow_template-0.7.dist-info}/METADATA +2 -2
- {otlmow_template-0.6.dist-info → otlmow_template-0.7.dist-info}/RECORD +6 -6
- {otlmow_template-0.6.dist-info → otlmow_template-0.7.dist-info}/LICENSE +0 -0
- {otlmow_template-0.6.dist-info → otlmow_template-0.7.dist-info}/WHEEL +0 -0
- {otlmow_template-0.6.dist-info → otlmow_template-0.7.dist-info}/top_level.txt +0 -0
|
@@ -41,15 +41,17 @@ class SubsetTemplateCreator:
|
|
|
41
41
|
return collector
|
|
42
42
|
|
|
43
43
|
def generate_template_from_subset(self, path_to_subset: Path, path_to_template_file_and_extension: Path,
|
|
44
|
-
ignore_relations: bool = True,
|
|
44
|
+
ignore_relations: bool = True, filter_attributes_by_subset: bool = True,
|
|
45
|
+
**kwargs):
|
|
45
46
|
tempdir = Path(tempfile.gettempdir()) / 'temp-otlmow'
|
|
46
47
|
if not tempdir.exists():
|
|
47
48
|
os.makedirs(tempdir)
|
|
48
49
|
test = ntpath.basename(path_to_template_file_and_extension)
|
|
49
50
|
temporary_path = Path(tempdir) / test
|
|
50
|
-
instantiated_attributes = self.generate_basic_template(
|
|
51
|
+
instantiated_attributes = (self.generate_basic_template(
|
|
51
52
|
path_to_subset=path_to_subset, temporary_path=temporary_path, ignore_relations=ignore_relations,
|
|
52
|
-
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))
|
|
53
55
|
extension = os.path.splitext(path_to_template_file_and_extension)[-1].lower()
|
|
54
56
|
if extension == '.xlsx':
|
|
55
57
|
self.alter_excel_template(path_to_template_file_and_extension=path_to_template_file_and_extension,
|
|
@@ -68,8 +70,9 @@ class SubsetTemplateCreator:
|
|
|
68
70
|
list_of_otl_objectUri = None
|
|
69
71
|
if kwargs is not None:
|
|
70
72
|
list_of_otl_objectUri = kwargs.get('list_of_otl_objectUri', None)
|
|
73
|
+
collector = self._load_collector_from_subset_path(path_to_subset=path_to_subset)
|
|
71
74
|
filtered_class_list = self.filters_classes_by_subset(
|
|
72
|
-
|
|
75
|
+
collector=collector, list_of_otl_objectUri=list_of_otl_objectUri)
|
|
73
76
|
otl_objects = []
|
|
74
77
|
amount_of_examples = kwargs.get('amount_of_examples', 0)
|
|
75
78
|
model_directory = None
|
|
@@ -77,25 +80,24 @@ class SubsetTemplateCreator:
|
|
|
77
80
|
model_directory = kwargs.get('model_directory', None)
|
|
78
81
|
relation_dict = get_hardcoded_relation_dict(model_directory=model_directory)
|
|
79
82
|
|
|
83
|
+
generate_dummy_records = 1
|
|
84
|
+
if amount_of_examples > 1:
|
|
85
|
+
generate_dummy_records = amount_of_examples
|
|
86
|
+
|
|
80
87
|
for class_object in [cl for cl in filtered_class_list if cl.abstract == 0]:
|
|
81
88
|
if ignore_relations and class_object.objectUri in relation_dict:
|
|
82
89
|
continue
|
|
83
|
-
|
|
84
|
-
if amount_of_examples != 0:
|
|
85
|
-
for _ in range(amount_of_examples):
|
|
86
|
-
instance = dynamic_create_instance_from_uri(class_object.objectUri, model_directory=model_directory)
|
|
87
|
-
if instance is None:
|
|
88
|
-
continue
|
|
89
|
-
instance.fill_with_dummy_data()
|
|
90
|
-
otl_objects.append(instance)
|
|
91
|
-
else:
|
|
90
|
+
for _ in range(generate_dummy_records):
|
|
92
91
|
instance = dynamic_create_instance_from_uri(class_object.objectUri, model_directory=model_directory)
|
|
93
92
|
if instance is None:
|
|
94
93
|
continue
|
|
95
|
-
|
|
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()
|
|
96
98
|
otl_objects.append(instance)
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
DotnotationHelper.clear_list_of_list_attributes(instance)
|
|
99
101
|
|
|
100
102
|
converter = OtlmowConverter()
|
|
101
103
|
converter.from_objects_to_file(file_path=temporary_path,
|
|
@@ -150,11 +152,11 @@ class SubsetTemplateCreator:
|
|
|
150
152
|
[f.unlink() for f in Path(file_location).glob("*") if f.is_file()]
|
|
151
153
|
|
|
152
154
|
@classmethod
|
|
153
|
-
def filters_classes_by_subset(cls,
|
|
155
|
+
def filters_classes_by_subset(cls, collector: OSLOCollector,
|
|
156
|
+
list_of_otl_objectUri: [str] = None) -> list[OSLOClass]:
|
|
154
157
|
if list_of_otl_objectUri is None:
|
|
155
158
|
list_of_otl_objectUri = []
|
|
156
159
|
|
|
157
|
-
collector = cls._load_collector_from_subset_path(path_to_subset=path_to_subset)
|
|
158
160
|
if list_of_otl_objectUri == []:
|
|
159
161
|
return collector.classes
|
|
160
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,10 +1,10 @@
|
|
|
1
1
|
otlmow_template/CsvTemplateCreator.py,sha256=PQq2zGmliWk0N9bhYNB7ZEa8PWV16OTbvoHh3--qCMs,7538
|
|
2
2
|
otlmow_template/ExcelTemplateCreator.py,sha256=wW-7Uq2Gzr1vHYMO1I7TtqZSBTVFFSWotHvjwzCelV4,10853
|
|
3
|
-
otlmow_template/SubsetTemplateCreator.py,sha256=
|
|
3
|
+
otlmow_template/SubsetTemplateCreator.py,sha256=vNJobrczgw0FsyKEvDw4mZ7k5VwT6er5e3sa48fHvY0,24891
|
|
4
4
|
otlmow_template/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
otlmow_template/Exceptions/MissingTypeUriException.py,sha256=DSKwywmP9Bq8n7rzBoDcEPlxvC1IChx18QIHFUCTtdA,51
|
|
6
|
-
otlmow_template-0.
|
|
7
|
-
otlmow_template-0.
|
|
8
|
-
otlmow_template-0.
|
|
9
|
-
otlmow_template-0.
|
|
10
|
-
otlmow_template-0.
|
|
6
|
+
otlmow_template-0.7.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
7
|
+
otlmow_template-0.7.dist-info/METADATA,sha256=En5QPEko7FNtXwIjxc6oeLHaw9j_-Q-Q9yCmxmro4RI,43999
|
|
8
|
+
otlmow_template-0.7.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
9
|
+
otlmow_template-0.7.dist-info/top_level.txt,sha256=zPgBoaTLG-avoOLySlwOUEtHaFyA5Vc5wJqkSeX1l6A,16
|
|
10
|
+
otlmow_template-0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|