otlmow-template 0.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: otlmow_template
3
- Version: 0.6
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>=0.15
700
+ Requires-Dist: otlmow-converter>=1.6
701
701
  Requires-Dist: otlmow-modelbuilder>=0.24
702
702
 
703
703
  # OTLMOW-Template
@@ -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, **kwargs):
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, **kwargs)
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
- path_to_subset=path_to_subset, list_of_otl_objectUri=list_of_otl_objectUri)
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
- instance.fill_with_dummy_data()
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
- DotnotationHelper.clear_list_of_list_attributes(instance)
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, path_to_subset: Path, list_of_otl_objectUri: [str] = None) -> list[OSLOClass]:
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.6
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>=0.15
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>=0.15
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.6"
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 >= 0.15',
32
+ 'otlmow-converter >= 1.6',
33
33
  'otlmow-modelbuilder >= 0.24',
34
34
  ]
35
35
 
File without changes
File without changes
File without changes