otlmow-template 0.11rc2__tar.gz → 0.11rc4__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.2
2
2
  Name: otlmow_template
3
- Version: 0.11rc2
3
+ Version: 0.11rc4
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
@@ -97,6 +97,7 @@ class SubsetTemplateCreator:
97
97
  continue
98
98
  for _ in range(generate_dummy_records):
99
99
  instance = dynamic_create_instance_from_uri(class_object.objectUri, model_directory=model_directory)
100
+ await sleep(0)
100
101
  if instance is None:
101
102
  continue
102
103
  attributen = collector.find_attributes_by_class(class_object)
@@ -112,6 +113,7 @@ class SubsetTemplateCreator:
112
113
 
113
114
  DotnotationHelper.clear_list_of_list_attributes(instance)
114
115
 
116
+ await sleep(0)
115
117
  converter = OtlmowConverter()
116
118
  await converter.from_objects_to_file(file_path=temporary_path,
117
119
  sequence_of_objects=otl_objects, **kwargs)
@@ -146,10 +148,13 @@ class SubsetTemplateCreator:
146
148
  if generate_choice_list:
147
149
  await sleep(0)
148
150
  await cls.add_choice_list_excel(workbook=wb, instantiated_attributes=instantiated_attributes,
149
- path_to_subset=path_to_subset)
151
+ path_to_subset=path_to_subset, add_attribute_info=add_attribute_info)
152
+ await sleep(0)
153
+ cls.add_mock_data_excel(workbook=wb, rows_of_examples=amount_of_examples) # remove dummy rows if needed
154
+
155
+ await cls.custom_exel_fixes(workbook=wb, instantiated_attributes=instantiated_attributes,
156
+ add_attribute_info=add_attribute_info)
150
157
  await sleep(0)
151
- cls.add_mock_data_excel(workbook=wb, rows_of_examples=amount_of_examples)
152
- await cls.add_type_uri_choice_list_in_excel(workbook=wb, instantiated_attributes=instantiated_attributes)
153
158
  if highlight_deprecated_attributes:
154
159
  await sleep(0)
155
160
  cls.check_for_deprecated_attributes(workbook=wb, instantiated_attributes=instantiated_attributes)
@@ -157,8 +162,6 @@ class SubsetTemplateCreator:
157
162
  await sleep(0)
158
163
  await cls.add_attribute_info_excel(workbook=wb, instantiated_attributes=instantiated_attributes)
159
164
  await sleep(0)
160
- await cls.design_workbook_excel(workbook=wb)
161
- await sleep(0)
162
165
  wb.save(path_to_template_file_and_extension)
163
166
  file_location = os.path.dirname(temporary_path)
164
167
  [f.unlink() for f in Path(file_location).glob("*") if f.is_file()]
@@ -196,55 +199,78 @@ class SubsetTemplateCreator:
196
199
 
197
200
  @classmethod
198
201
  @async_to_sync_wraps
199
- async def add_type_uri_choice_list_in_excel(cls, workbook, instantiated_attributes):
200
- for sheet in workbook:
201
- await sleep(0)
202
- if sheet.title == 'Keuzelijsten':
203
- break
204
- type_uri_found = False
205
- for row in sheet.iter_rows(min_row=1, max_row=1):
206
- for cell in row:
207
- if cell.value == 'typeURI':
208
- type_uri_found = True
209
- break
210
- if type_uri_found:
202
+ async def add_type_uri_choice_list_in_excel(cls, sheet, instantiated_attributes, add_attribute_info: bool):
203
+ starting_row = '3' if add_attribute_info else '2'
204
+ await sleep(0)
205
+ if sheet.title == 'Keuzelijsten':
206
+ return
207
+ type_uri_found = False
208
+ for row in sheet.iter_rows(min_row=1, max_row=1):
209
+ for cell in row:
210
+ if cell.value == 'typeURI':
211
+ type_uri_found = True
211
212
  break
212
- if not type_uri_found:
213
- continue
213
+ if type_uri_found:
214
+ break
215
+ if not type_uri_found:
216
+ return
214
217
 
215
- await sleep(0)
216
- sheet_name = sheet.title
217
- type_uri = ''
218
- if sheet_name.startswith('http'):
219
- type_uri = sheet_name
220
- else:
221
- split_name = sheet_name.split("#")
222
- subclass_name = split_name[1]
223
-
224
- possible_classes = [x for x in instantiated_attributes if x.typeURI.endswith(subclass_name)]
225
- if len(possible_classes) == 1:
226
- type_uri = possible_classes[0].typeURI
227
-
228
- if type_uri == '':
229
- continue
218
+ await sleep(0)
219
+ sheet_name = sheet.title
220
+ type_uri = ''
221
+ if sheet_name.startswith('http'):
222
+ type_uri = sheet_name
223
+ else:
224
+ split_name = sheet_name.split("#")
225
+ subclass_name = split_name[1]
230
226
 
231
- data_validation = DataValidation(type="list", formula1=f'"{type_uri}"', allow_blank=True)
232
- await sleep(0)
233
- for rows in sheet.iter_rows(min_row=1, max_row=1, min_col=1, max_col=1):
234
- for cell in rows:
235
- column = cell.column
236
- sheet.add_data_validation(data_validation)
237
- data_validation.add(f'{get_column_letter(column)}2:{get_column_letter(column)}1000')
227
+ possible_classes = [x for x in instantiated_attributes if x.typeURI.endswith(subclass_name)]
228
+ if len(possible_classes) == 1:
229
+ type_uri = possible_classes[0].typeURI
230
+
231
+ if type_uri == '':
232
+ return
233
+
234
+ data_validation = DataValidation(type="list", formula1=f'"{type_uri}"', allow_blank=True)
235
+ await sleep(0)
236
+ for rows in sheet.iter_rows(min_row=1, max_row=1, min_col=1, max_col=1):
237
+ for cell in rows:
238
+ await sleep(0)
239
+ column = cell.column
240
+ sheet.add_data_validation(data_validation)
241
+ data_validation.add(f'{get_column_letter(column)}{starting_row}:{get_column_letter(column)}1000')
238
242
 
239
243
  @classmethod
240
244
  @async_to_sync_wraps
241
- async def design_workbook_excel(cls, workbook):
245
+ async def custom_exel_fixes(cls, workbook, instantiated_attributes, add_attribute_info: bool):
242
246
  for sheet in workbook:
243
- dim_holder = DimensionHolder(worksheet=sheet)
244
- for col in range(sheet.min_column, sheet.max_column + 1):
247
+ await sleep(0)
248
+ await cls.set_fixed_column_width(sheet=sheet, width=25)
249
+ await cls.add_type_uri_choice_list_in_excel(sheet=sheet, instantiated_attributes=instantiated_attributes,
250
+ add_attribute_info=add_attribute_info)
251
+ await cls.remove_asset_versie(sheet=sheet)
252
+
253
+ @classmethod
254
+ @async_to_sync_wraps
255
+ async def remove_asset_versie(cls, sheet):
256
+ for row in sheet.iter_rows(min_row=1, max_row=1, min_col=4):
257
+ for cell in row:
245
258
  await sleep(0)
246
- dim_holder[get_column_letter(col)] = ColumnDimension(sheet, min=col, max=col, width=25)
247
- sheet.column_dimensions = dim_holder
259
+ if cell.value is None or not cell.value.startswith('assetVersie'):
260
+ continue
261
+ for rows in sheet.iter_rows(min_col=cell.column, max_col=cell.column, min_row=2, max_row=1000):
262
+ for c in rows:
263
+ await sleep(0)
264
+ c.value = ''
265
+
266
+ @classmethod
267
+ @async_to_sync_wraps
268
+ async def set_fixed_column_width(cls, sheet, width: int):
269
+ dim_holder = DimensionHolder(worksheet=sheet)
270
+ for col in range(sheet.min_column, sheet.max_column + 1):
271
+ await sleep(0)
272
+ dim_holder[get_column_letter(col)] = ColumnDimension(sheet, min=col, max=col, width=width)
273
+ sheet.column_dimensions = dim_holder
248
274
 
249
275
  @classmethod
250
276
  @async_to_sync_wraps
@@ -323,8 +349,10 @@ class SubsetTemplateCreator:
323
349
 
324
350
  @classmethod
325
351
  @async_to_sync_wraps
326
- async def add_choice_list_excel(cls, workbook, instantiated_attributes: list, path_to_subset: Path):
352
+ async def add_choice_list_excel(cls, workbook, instantiated_attributes: list, path_to_subset: Path,
353
+ add_attribute_info: bool=False):
327
354
  choice_list_dict = {}
355
+ starting_row = '3' if add_attribute_info else '2'
328
356
  dotnotation_module = DotnotationHelper()
329
357
  for sheet in workbook:
330
358
  await sleep(0)
@@ -356,14 +384,16 @@ class SubsetTemplateCreator:
356
384
  data_val = DataValidation(type="list", formula1=f"Keuzelijsten!{start_range}:{end_range}",
357
385
  allowBlank=True)
358
386
  sheet.add_data_validation(data_val)
359
- data_val.add(f'{get_column_letter(cell.column)}2:{get_column_letter(cell.column)}1000')
387
+ data_val.add(f'{get_column_letter(cell.column)}{starting_row}:'
388
+ f'{get_column_letter(cell.column)}1000')
360
389
 
361
390
  await sleep(0)
362
391
  if issubclass(dotnotation_attribute.field, BooleanField):
363
392
  data_validation = DataValidation(type="list", formula1='"TRUE,FALSE,"', allow_blank=True)
364
393
  column = cell.column
365
394
  sheet.add_data_validation(data_validation)
366
- data_validation.add(f'{get_column_letter(column)}2:{get_column_letter(column)}1000')
395
+ data_validation.add(f'{get_column_letter(column)}{starting_row}:'
396
+ f'{get_column_letter(column)}1000')
367
397
 
368
398
 
369
399
  @classmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: otlmow_template
3
- Version: 0.11rc2
3
+ Version: 0.11rc4
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "otlmow_template"
7
- version = "0.11-rc2"
7
+ version = "0.11-rc4"
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"