clipboard import

This commit is contained in:
“christopheseux”
2023-05-04 18:45:17 +02:00
parent ec4212740c
commit 38b3e7b504
5 changed files with 264 additions and 110 deletions
+40 -2
View File
@@ -10,7 +10,7 @@ import vse_toolbox
from vse_toolbox.bl_utils import (get_addon_prefs, get_scene_settings)
from vse_toolbox.file_utils import (read_file, )
from vse_toolbox.file_utils import (read_file, norm_str)
@@ -50,9 +50,12 @@ class VSETB_OT_load_settings(Operator):
addon_config['trackers'] = addon_config.get('trackers')
trackers = addon_config.pop('trackers')
addon_config['spreadsheet_export'] = addon_config.get('spreadsheet_export')
addon_config['spreadsheet_export'] = addon_config.get('spreadsheet_export', {})
spreadsheet_export_config = addon_config.pop('spreadsheet_export')
addon_config['spreadsheet_import'] = addon_config.get('spreadsheet_import', {})
spreadsheet_import_config = addon_config.pop('spreadsheet_import')
project_name = addon_config.get('project_name')
if project_name:
settings.project_name = project_name
@@ -93,6 +96,41 @@ class VSETB_OT_load_settings(Operator):
except Exception:
print(f'Could not set option {k} with value {v} to spreadsheet')
import_cells = project.spreadsheet_import.cells
if spreadsheet_import_config:
import_cells.clear()
cell_names = project.get_cell_names()
for k, v in spreadsheet_import_config.items():
if k == 'cells':
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 = import_cells.add()
cell.name = cell_data['name']
norm_import_name = norm_str(cell_data.get('import_name', cell_data['name']))
import_name = next((c for c in cell_names if norm_str(c) == norm_import_name), None)
if import_name is None:
print(f'import_name {norm_import_name} not in {cell_names}')
else:
cell.import_name = import_name
if 'enabled' in cell_data:
try:
cell.enabled = cell_data['enabled']
except TypeError as e:
print(e)
else:
try:
setattr(project.spreadsheet_import, k, v)
except Exception:
print(f'Could not set option {k} with value {v} to spreadsheet')
return {'FINISHED'}