otlmow-template 0.6__py3-none-any.whl → 0.8__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.
@@ -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,29 @@ 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()
98
+ try:
99
+ geo_attr = getattr(instance, '_geometry')
100
+ geo_attr.fill_with_dummy_data()
101
+ except AttributeError:
102
+ pass
96
103
  otl_objects.append(instance)
97
104
 
98
- DotnotationHelper.clear_list_of_list_attributes(instance)
105
+ DotnotationHelper.clear_list_of_list_attributes(instance)
99
106
 
100
107
  converter = OtlmowConverter()
101
108
  converter.from_objects_to_file(file_path=temporary_path,
@@ -150,11 +157,11 @@ class SubsetTemplateCreator:
150
157
  [f.unlink() for f in Path(file_location).glob("*") if f.is_file()]
151
158
 
152
159
  @classmethod
153
- def filters_classes_by_subset(cls, path_to_subset: Path, list_of_otl_objectUri: [str] = None) -> list[OSLOClass]:
160
+ def filters_classes_by_subset(cls, collector: OSLOCollector,
161
+ list_of_otl_objectUri: [str] = None) -> list[OSLOClass]:
154
162
  if list_of_otl_objectUri is None:
155
163
  list_of_otl_objectUri = []
156
164
 
157
- collector = cls._load_collector_from_subset_path(path_to_subset=path_to_subset)
158
165
  if list_of_otl_objectUri == []:
159
166
  return collector.classes
160
167
  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.8
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.7
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=VGpl6RWjSxi5t2HvaOCW5awgToP1lZErv4SsqSdI-FE,24731
3
+ otlmow_template/SubsetTemplateCreator.py,sha256=552FsvmbS3g48f_h2o2Y5t2Ank4NBW1dfJlQXowHD74,25090
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.6.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
7
- otlmow_template-0.6.dist-info/METADATA,sha256=bdqoC44BK1kiQkExkqOFwj7uwk6tDqUzk2nlKSoevDI,44000
8
- otlmow_template-0.6.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
9
- otlmow_template-0.6.dist-info/top_level.txt,sha256=zPgBoaTLG-avoOLySlwOUEtHaFyA5Vc5wJqkSeX1l6A,16
10
- otlmow_template-0.6.dist-info/RECORD,,
6
+ otlmow_template-0.8.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
7
+ otlmow_template-0.8.dist-info/METADATA,sha256=63EBk5omnZoL47HGvtX789ZVImk63OugJY9ht3fnoQk,43999
8
+ otlmow_template-0.8.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
9
+ otlmow_template-0.8.dist-info/top_level.txt,sha256=zPgBoaTLG-avoOLySlwOUEtHaFyA5Vc5wJqkSeX1l6A,16
10
+ otlmow_template-0.8.dist-info/RECORD,,