fix refacto

This commit is contained in:
“christopheseux”
2023-05-02 20:46:45 +02:00
parent 41a4c7a3a4
commit 4a3042030f
6 changed files with 94 additions and 75 deletions
+21 -19
View File
@@ -50,8 +50,8 @@ class VSETB_OT_load_settings(Operator):
addon_config['trackers'] = addon_config.get('trackers')
trackers = addon_config.pop('trackers')
addon_config['spreadsheet'] = addon_config.get('spreadsheet')
spreadsheet = addon_config.pop('spreadsheet')
addon_config['spreadsheet_export'] = addon_config.get('spreadsheet_export')
spreadsheet_export_config = addon_config.pop('spreadsheet_export')
project_name = addon_config.get('project_name')
if project_name:
@@ -64,30 +64,32 @@ class VSETB_OT_load_settings(Operator):
except Exception:
print(f'Could not set property {k} with value {v} to project {settings.project_name}')
if spreadsheet.get('cells'):
#project.spreadsheet.clear()
export_cells = project.spreadsheet_export.cells
for k, v in spreadsheet_export_config.items():
if k == 'cells':
#project.spreadsheet.clear()
for i, cell_data in enumerate(spreadsheet['cells']):
if not 'name' in cell_data:
print(f'cell_data {cell_data} need to have a attribute name')
continue
for i, cell_data in enumerate(v):
if not 'name' in cell_data:
print(f'cell_data {cell_data} need to have a attribute name')
continue
cell = project.spreadsheet.get(cell_data['name'])
cell = export_cells.get(cell_data['name'])
if not cell:
print(f"cell {cell_data['name']} not in spreadsheet")
continue
if not cell:
print(f"cell {cell_data['name']} not in spreadsheet")
continue
project.spreadsheet.move(list(project.spreadsheet).index(cell), i)
export_cells.move(list(export_cells).index(cell), i)
for prop_name in ('export_name', 'enabled'):
if prop_name in cell_data:
setattr(cell, prop_name, cell_data[prop_name])
for prop_name in ('export_name', 'enabled'):
if prop_name in cell_data:
setattr(cell, prop_name, cell_data[prop_name])
if spreadsheet.get('options'):
for k, v in spreadsheet['options'].items():
else:
try:
setattr(project.spreadsheet_options, k, v)
setattr(project.spreadsheet_export, k, v)
except Exception:
print(f'Could not set option {k} with value {v} to spreadsheet')