otlmow-template 1.6__py3-none-any.whl → 1.9__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 +44 -10
- {otlmow_template-1.6.dist-info → otlmow_template-1.9.dist-info}/METADATA +11 -8
- otlmow_template-1.9.dist-info/RECORD +7 -0
- {otlmow_template-1.6.dist-info → otlmow_template-1.9.dist-info}/WHEEL +1 -1
- otlmow_template-1.6.dist-info/RECORD +0 -7
- {otlmow_template-1.6.dist-info → otlmow_template-1.9.dist-info}/licenses/LICENSE +0 -0
- {otlmow_template-1.6.dist-info → otlmow_template-1.9.dist-info}/top_level.txt +0 -0
|
@@ -96,6 +96,11 @@ class SubsetTemplateCreator:
|
|
|
96
96
|
add_geometry=add_geometry, filter_attributes_by_subset=filter_attributes_by_subset,
|
|
97
97
|
dummy_data_rows=dummy_data_rows, model_directory=model_directory)
|
|
98
98
|
|
|
99
|
+
abbreviate_excel_after = False
|
|
100
|
+
if kwargs.get('abbreviate_excel_sheettitles') == True:
|
|
101
|
+
kwargs['abbreviate_excel_sheettitles'] = False
|
|
102
|
+
abbreviate_excel_after = True
|
|
103
|
+
|
|
99
104
|
# write the file
|
|
100
105
|
await OtlmowConverter.from_objects_to_file_async(
|
|
101
106
|
file_path=template_file_path, sequence_of_objects=objects, split_per_type=split_per_type, **kwargs)
|
|
@@ -105,7 +110,8 @@ class SubsetTemplateCreator:
|
|
|
105
110
|
if extension == '.xlsx':
|
|
106
111
|
await cls.alter_excel_template_async(
|
|
107
112
|
generate_choice_list=generate_choice_list, file_path=template_file_path, dummy_data_rows=dummy_data_rows,
|
|
108
|
-
instances=objects, add_deprecated=add_deprecated, add_attribute_info=add_attribute_info
|
|
113
|
+
instances=objects, add_deprecated=add_deprecated, add_attribute_info=add_attribute_info,
|
|
114
|
+
abbreviate_excel_sheettitles=abbreviate_excel_after)
|
|
109
115
|
|
|
110
116
|
elif extension == '.csv':
|
|
111
117
|
await cls.alter_csv_template_async(
|
|
@@ -151,6 +157,11 @@ class SubsetTemplateCreator:
|
|
|
151
157
|
add_geometry=add_geometry, filter_attributes_by_subset=filter_attributes_by_subset,
|
|
152
158
|
dummy_data_rows=dummy_data_rows, model_directory=model_directory)
|
|
153
159
|
|
|
160
|
+
abbreviate_excel_after = False
|
|
161
|
+
if kwargs.get('abbreviate_excel_sheettitles') == True:
|
|
162
|
+
kwargs['abbreviate_excel_sheettitles'] = False
|
|
163
|
+
abbreviate_excel_after = True
|
|
164
|
+
|
|
154
165
|
# write the file
|
|
155
166
|
OtlmowConverter.from_objects_to_file(
|
|
156
167
|
file_path=template_file_path, sequence_of_objects=objects, split_per_type=split_per_type,
|
|
@@ -161,7 +172,8 @@ class SubsetTemplateCreator:
|
|
|
161
172
|
if extension == '.xlsx':
|
|
162
173
|
cls.alter_excel_template(
|
|
163
174
|
generate_choice_list=generate_choice_list, file_path=template_file_path, dummy_data_rows=dummy_data_rows,
|
|
164
|
-
instances=objects, add_deprecated=add_deprecated, add_attribute_info=add_attribute_info
|
|
175
|
+
instances=objects, add_deprecated=add_deprecated, add_attribute_info=add_attribute_info,
|
|
176
|
+
abbreviate_excel_sheettitles=abbreviate_excel_after)
|
|
165
177
|
elif extension == '.csv':
|
|
166
178
|
cls.alter_csv_template(
|
|
167
179
|
split_per_type=split_per_type, file_path=template_file_path, dummy_data_rows=dummy_data_rows,
|
|
@@ -340,7 +352,8 @@ class SubsetTemplateCreator:
|
|
|
340
352
|
|
|
341
353
|
@classmethod
|
|
342
354
|
def alter_excel_template(cls, instances: list, file_path: Path, add_attribute_info: bool,
|
|
343
|
-
generate_choice_list: bool, dummy_data_rows: int, add_deprecated: bool
|
|
355
|
+
generate_choice_list: bool, dummy_data_rows: int, add_deprecated: bool,
|
|
356
|
+
abbreviate_excel_sheettitles: bool):
|
|
344
357
|
wb = load_workbook(file_path)
|
|
345
358
|
wb.create_sheet('Keuzelijsten')
|
|
346
359
|
|
|
@@ -351,7 +364,8 @@ class SubsetTemplateCreator:
|
|
|
351
364
|
|
|
352
365
|
cls.alter_excel_sheet(add_attribute_info=add_attribute_info, choice_list_dict=choice_list_dict,
|
|
353
366
|
generate_choice_list=generate_choice_list, dummy_data_rows=dummy_data_rows,
|
|
354
|
-
instances=instances, sheet=sheet, add_deprecated=add_deprecated, workbook=wb
|
|
367
|
+
instances=instances, sheet=sheet, add_deprecated=add_deprecated, workbook=wb,
|
|
368
|
+
abbreviate_excel_sheettitle=abbreviate_excel_sheettitles)
|
|
355
369
|
|
|
356
370
|
wb.save(file_path)
|
|
357
371
|
wb.close()
|
|
@@ -455,7 +469,8 @@ class SubsetTemplateCreator:
|
|
|
455
469
|
|
|
456
470
|
@classmethod
|
|
457
471
|
async def alter_excel_template_async(cls, instances: list, file_path: Path, add_attribute_info: bool,
|
|
458
|
-
|
|
472
|
+
generate_choice_list: bool, dummy_data_rows: int, add_deprecated: bool,
|
|
473
|
+
abbreviate_excel_sheettitles: bool):
|
|
459
474
|
wb = load_workbook(file_path)
|
|
460
475
|
wb.create_sheet('Keuzelijsten')
|
|
461
476
|
|
|
@@ -466,7 +481,8 @@ class SubsetTemplateCreator:
|
|
|
466
481
|
|
|
467
482
|
cls.alter_excel_sheet(add_attribute_info=add_attribute_info, choice_list_dict=choice_list_dict,
|
|
468
483
|
generate_choice_list=generate_choice_list, dummy_data_rows=dummy_data_rows,
|
|
469
|
-
instances=instances, sheet=sheet, add_deprecated=add_deprecated, workbook=wb
|
|
484
|
+
instances=instances, sheet=sheet, add_deprecated=add_deprecated, workbook=wb,
|
|
485
|
+
abbreviate_excel_sheettitle=abbreviate_excel_sheettitles)
|
|
470
486
|
await sleep(0)
|
|
471
487
|
|
|
472
488
|
wb.save(file_path)
|
|
@@ -475,7 +491,7 @@ class SubsetTemplateCreator:
|
|
|
475
491
|
@classmethod
|
|
476
492
|
def alter_excel_sheet(cls, add_attribute_info: bool, choice_list_dict: dict, generate_choice_list: bool,
|
|
477
493
|
instances: [OTLObject], sheet: Worksheet, add_deprecated: bool, workbook: Workbook,
|
|
478
|
-
dummy_data_rows: int):
|
|
494
|
+
dummy_data_rows: int, abbreviate_excel_sheettitle: bool = True):
|
|
479
495
|
type_uri = cls.get_uri_from_sheet_name(sheet.title)
|
|
480
496
|
instance = next((x for x in instances if x.typeURI == type_uri), None)
|
|
481
497
|
if instance is None:
|
|
@@ -483,7 +499,7 @@ class SubsetTemplateCreator:
|
|
|
483
499
|
if instance is None:
|
|
484
500
|
raise UnknownExcelError(f'When creating a template, no instance could be created for {type_uri}')
|
|
485
501
|
|
|
486
|
-
boolean_validation = DataValidation(type="list", formula1='"TRUE,FALSE
|
|
502
|
+
boolean_validation = DataValidation(type="list", formula1='"TRUE,FALSE,-"', allow_blank=True)
|
|
487
503
|
sheet.add_data_validation(boolean_validation)
|
|
488
504
|
collected_attribute_info = []
|
|
489
505
|
deprecated_attributes_row = []
|
|
@@ -538,6 +554,9 @@ class SubsetTemplateCreator:
|
|
|
538
554
|
|
|
539
555
|
cls.set_fixed_column_width(sheet=sheet, width=25)
|
|
540
556
|
|
|
557
|
+
if abbreviate_excel_sheettitle:
|
|
558
|
+
cls.abbreviate_excel_sheettitle(sheet=sheet)
|
|
559
|
+
|
|
541
560
|
@classmethod
|
|
542
561
|
def color_choice_lists_green(cls, sheet: Worksheet, header_cell_column: Cell):
|
|
543
562
|
for cell in sheet.iter_rows(min_col=header_cell_column.column, max_col=header_cell_column.column,
|
|
@@ -573,7 +592,7 @@ class SubsetTemplateCreator:
|
|
|
573
592
|
options=choice_list_values, choice_list_dict=choice_list_dict)
|
|
574
593
|
column_in_choice_sheet = choice_list_dict[attribute.field.naam]
|
|
575
594
|
start_range = f"${column_in_choice_sheet}$2"
|
|
576
|
-
end_range = f"${column_in_choice_sheet}${len(choice_list_values) +
|
|
595
|
+
end_range = f"${column_in_choice_sheet}${len(choice_list_values) + 2}"
|
|
577
596
|
data_val = DataValidation(type="list", formula1=f"Keuzelijsten!{start_range}:{end_range}",
|
|
578
597
|
allowBlank=True)
|
|
579
598
|
sheet.add_data_validation(data_val)
|
|
@@ -603,7 +622,9 @@ class SubsetTemplateCreator:
|
|
|
603
622
|
if new_header.value is not None:
|
|
604
623
|
raise ValueError(f'Header already exists at column {column_nr}: {new_header.value}')
|
|
605
624
|
new_header.value = name
|
|
606
|
-
|
|
625
|
+
cell = active_sheet.cell(row=row_nr + 1, column=column_nr)
|
|
626
|
+
cell.value = "-"
|
|
627
|
+
for index, option in enumerate(options, start=2):
|
|
607
628
|
cell = active_sheet.cell(row=row_nr + index, column=column_nr)
|
|
608
629
|
cell.value = option.invulwaarde
|
|
609
630
|
|
|
@@ -644,3 +665,16 @@ class SubsetTemplateCreator:
|
|
|
644
665
|
target=doel_instance, model_directory=model_directory)
|
|
645
666
|
|
|
646
667
|
otl_objects.append(relation_instance)
|
|
668
|
+
|
|
669
|
+
@classmethod
|
|
670
|
+
def abbreviate_excel_sheettitle(cls, sheet):
|
|
671
|
+
class_name = sheet.title
|
|
672
|
+
# abbreviates the class_name so it doesn't exceed the 31 character limit of sheet titles in excel
|
|
673
|
+
if '#' not in class_name:
|
|
674
|
+
sheet.title = class_name[:31]
|
|
675
|
+
return
|
|
676
|
+
split_name = class_name.split("#")
|
|
677
|
+
namespace_name = split_name[0]
|
|
678
|
+
subclass_name = split_name[1]
|
|
679
|
+
class_name = f"{namespace_name[:3]}#{subclass_name}"
|
|
680
|
+
sheet.title = class_name[:31]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: otlmow_template
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.9
|
|
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
|
|
@@ -698,12 +698,13 @@ Requires-Python: >=3.9
|
|
|
698
698
|
Description-Content-Type: text/markdown
|
|
699
699
|
License-File: LICENSE
|
|
700
700
|
Requires-Dist: otlmow-converter>=1.14
|
|
701
|
-
Requires-Dist: otlmow-modelbuilder>=0.
|
|
701
|
+
Requires-Dist: otlmow-modelbuilder>=0.37
|
|
702
702
|
Provides-Extra: test
|
|
703
703
|
Requires-Dist: pytest; extra == "test"
|
|
704
704
|
Requires-Dist: pytest-cov; extra == "test"
|
|
705
705
|
Requires-Dist: pytest-subtests; extra == "test"
|
|
706
706
|
Requires-Dist: pytest-timeout; extra == "test"
|
|
707
|
+
Requires-Dist: pytest-asyncio; extra == "test"
|
|
707
708
|
Dynamic: license-file
|
|
708
709
|
|
|
709
710
|
# OTLMOW-Template
|
|
@@ -731,16 +732,18 @@ It is split into different packages to reduce compatibility issues
|
|
|
731
732
|
- [otlmow_gui](https://github.com/davidvlaminck/OTLMOW-GUI)
|
|
732
733
|
|
|
733
734
|
## Installation and requirements
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
To install the OTL MOW project into your Python project, use pip to install it:
|
|
735
|
+
I recommend working with uv. Install this first:
|
|
737
736
|
```
|
|
738
|
-
pip install
|
|
737
|
+
pip install uv
|
|
739
738
|
```
|
|
740
|
-
|
|
739
|
+
Then install this package by using the uv pip install command:
|
|
741
740
|
```
|
|
742
|
-
pip install
|
|
741
|
+
uv pip install otlmow-template
|
|
743
742
|
```
|
|
743
|
+
If you are a developer, use this command to install the dependencies, including those needed to run the test suite.
|
|
744
|
+
```
|
|
745
|
+
uv pip install -r pyproject.toml --extra test
|
|
746
|
+
```
|
|
744
747
|
|
|
745
748
|
## Usage
|
|
746
749
|
#TODO
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
otlmow_template/SubsetTemplateCreator.py,sha256=dWzMZaBmJqK_k2J7ouyZyd_TovVRKPbpco47y6uc7Hk,34777
|
|
2
|
+
otlmow_template/Exceptions/MissingTypeUriException.py,sha256=DSKwywmP9Bq8n7rzBoDcEPlxvC1IChx18QIHFUCTtdA,51
|
|
3
|
+
otlmow_template-1.9.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
4
|
+
otlmow_template-1.9.dist-info/METADATA,sha256=YK9C8pnQbWaCUge2I_3pCtXVJLt4aW9d8e82wnurCxE,44340
|
|
5
|
+
otlmow_template-1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
+
otlmow_template-1.9.dist-info/top_level.txt,sha256=zPgBoaTLG-avoOLySlwOUEtHaFyA5Vc5wJqkSeX1l6A,16
|
|
7
|
+
otlmow_template-1.9.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
otlmow_template/SubsetTemplateCreator.py,sha256=yvRxRRmOnWrMdyALG9q3HaADoQwiUh-sTki7Ui_oudM,33140
|
|
2
|
-
otlmow_template/Exceptions/MissingTypeUriException.py,sha256=DSKwywmP9Bq8n7rzBoDcEPlxvC1IChx18QIHFUCTtdA,51
|
|
3
|
-
otlmow_template-1.6.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
4
|
-
otlmow_template-1.6.dist-info/METADATA,sha256=yL3w0hRhDAYHBDBy56HFy-BMuCXBj3w5vP-tbERc478,44220
|
|
5
|
-
otlmow_template-1.6.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
6
|
-
otlmow_template-1.6.dist-info/top_level.txt,sha256=zPgBoaTLG-avoOLySlwOUEtHaFyA5Vc5wJqkSeX1l6A,16
|
|
7
|
-
otlmow_template-1.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|