From 0baf457abd0479760297c0a898251976e80546c8 Mon Sep 17 00:00:00 2001 From: "florentin.luce" Date: Wed, 14 Feb 2024 15:04:11 +0100 Subject: [PATCH] read spreadsheet --- operators/spreadsheet.py | 10 ++++++---- ui/properties.py | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/operators/spreadsheet.py b/operators/spreadsheet.py index d7b7f1f..9f89641 100644 --- a/operators/spreadsheet.py +++ b/operators/spreadsheet.py @@ -148,8 +148,6 @@ class VSETB_OT_spreadsheet_from_file(Operator): rows = [r for r in rows if any(r)] - #print('rows', rows) - cell_types = project.get_cell_types() for cell_name in rows[0]: if not cell_name: @@ -157,8 +155,12 @@ class VSETB_OT_spreadsheet_from_file(Operator): cell = import_cells.add() cell.name = cell_name - cell.import_name = max(cell_types.keys(), key=lambda x: fuzzy_match(cell_name, x)) - cell.enabled = True + + matches = [(k, fuzzy_match(cell_name, k)) for k in cell_types.keys()] + best_name, best_match = max(matches, key=lambda x: x[1]) + + cell.import_name = best_name + cell.enabled = best_match > 0.75 project.spreadsheet_import.use_custom_cells = True diff --git a/ui/properties.py b/ui/properties.py index c79cb8d..a3dc4bd 100644 --- a/ui/properties.py +++ b/ui/properties.py @@ -308,6 +308,9 @@ class Project(PropertyGroup): for asset_type in project.asset_types: cell_types[asset_type.name] = 'ASSET_TYPE' + for task_type in project.task_types: + cell_types[task_type.name] = 'TASK_TYPE' + return cell_types def set_spreadsheet(self):