instance support to spreadsheet
parent
206aec490f
commit
18f830157f
|
@ -148,7 +148,7 @@ class VSETB_OT_spreadsheet_from_file(Operator):
|
||||||
|
|
||||||
rows = [r for r in rows if any(r)]
|
rows = [r for r in rows if any(r)]
|
||||||
|
|
||||||
print('rows', rows)
|
#print('rows', rows)
|
||||||
|
|
||||||
cell_types = project.get_cell_types()
|
cell_types = project.get_cell_types()
|
||||||
for cell_name in rows[0]:
|
for cell_name in rows[0]:
|
||||||
|
@ -397,6 +397,9 @@ class VSETB_OT_import_spreadsheet(Operator):
|
||||||
|
|
||||||
if spreadsheet.import_casting:
|
if spreadsheet.import_casting:
|
||||||
strip_settings.casting.clear()
|
strip_settings.casting.clear()
|
||||||
|
strip_settings.casting.update()
|
||||||
|
|
||||||
|
#print('Clear Casting of strip', strip)
|
||||||
|
|
||||||
for cell_name, cell_value in zip(header, row):
|
for cell_name, cell_value in zip(header, row):
|
||||||
if not cell_name:
|
if not cell_name:
|
||||||
|
@ -429,17 +432,22 @@ class VSETB_OT_import_spreadsheet(Operator):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#print(norm_str(asset_name), norm_str(project.assets[0].tracker_name))
|
#print(norm_str(asset_name), norm_str(project.assets[0].tracker_name))
|
||||||
|
norm_asset_name = norm_str(asset_name)
|
||||||
|
|
||||||
if spreadsheet.use_custom_name:
|
if spreadsheet.use_custom_name:
|
||||||
asset = next((a for a in project.assets if norm_str(a.get('metadata', {}).get(spreadsheet.custom_name)) == norm_str(asset_name)), None)
|
asset = next((a for a in project.assets if norm_str(a.get('metadata', {}).get(spreadsheet.custom_name)) == norm_asset_name), None)
|
||||||
else:
|
else:
|
||||||
asset = next((a for a in project.assets if norm_str(a.tracker_name) == norm_str(asset_name)), None)
|
asset = next((a for a in project.assets if norm_str(a.tracker_name) == norm_asset_name), None)
|
||||||
|
|
||||||
if asset:
|
if asset:
|
||||||
item = strip_settings.casting.add()
|
item = next((item for item in strip_settings.casting if item.asset == asset), None)
|
||||||
item.name = asset.name
|
if item:
|
||||||
item.id = asset.id
|
item.instance += 1
|
||||||
item['_name'] = asset.label
|
else:
|
||||||
|
item = strip_settings.casting.add()
|
||||||
|
item.name = asset.name
|
||||||
|
item.id = asset.id
|
||||||
|
item['_name'] = asset.label
|
||||||
|
|
||||||
strip_settings.casting.update()
|
strip_settings.casting.update()
|
||||||
else:
|
else:
|
||||||
|
@ -546,7 +554,7 @@ class VSETB_OT_export_spreadsheet(Operator):
|
||||||
cells = spreadsheet.cells
|
cells = spreadsheet.cells
|
||||||
rows.append([cell.name for cell in cells])
|
rows.append([cell.name for cell in cells])
|
||||||
|
|
||||||
#print(rows)
|
print(rows)
|
||||||
#raise Exception('')
|
#raise Exception('')
|
||||||
|
|
||||||
separator = spreadsheet.separator.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')
|
separator = spreadsheet.separator.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')
|
||||||
|
@ -568,13 +576,14 @@ class VSETB_OT_export_spreadsheet(Operator):
|
||||||
|
|
||||||
if spreadsheet.use_custom_name and spreadsheet.use_custom_cells:
|
if spreadsheet.use_custom_name and spreadsheet.use_custom_cells:
|
||||||
if asset.get('metadata', {}).get(spreadsheet.custom_name):
|
if asset.get('metadata', {}).get(spreadsheet.custom_name):
|
||||||
asset_castings.append(asset['metadata'][spreadsheet.custom_name])
|
asset_castings += [asset['metadata'][spreadsheet.custom_name]]*asset_casting.instance
|
||||||
else:
|
else:
|
||||||
self.report({'ERROR'}, f'The asset {asset.tracker_name} has no data {spreadsheet.custom_name}')
|
self.report({'ERROR'}, f'The asset {asset.tracker_name} has no data {spreadsheet.custom_name}')
|
||||||
else:
|
else:
|
||||||
asset_castings.append(asset.tracker_name)
|
asset_castings += [asset.tracker_name]*asset_casting.instance
|
||||||
|
|
||||||
row += [separator.join(asset_castings)]
|
row += [separator.join(asset_castings)]
|
||||||
|
|
||||||
elif cell.field_name == 'EPISODE':
|
elif cell.field_name == 'EPISODE':
|
||||||
row += [settings.active_episode.name]
|
row += [settings.active_episode.name]
|
||||||
elif cell.field_name == 'SEQUENCE':
|
elif cell.field_name == 'SEQUENCE':
|
||||||
|
@ -614,12 +623,19 @@ class VSETB_OT_export_spreadsheet(Operator):
|
||||||
|
|
||||||
#2023_04_11_kitsu_boris_ep01_shots
|
#2023_04_11_kitsu_boris_ep01_shots
|
||||||
export_path.parent.mkdir(parents=True, exist_ok=True)
|
export_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
if export_path.exists():
|
||||||
|
try:
|
||||||
|
print('Removing File', export_path)
|
||||||
|
export_path.unlink()
|
||||||
|
except Exception:
|
||||||
|
self.report({'ERROR'}, f'You need to close the file {export_path}')
|
||||||
|
|
||||||
if spreadsheet.format == 'csv':
|
if spreadsheet.format == 'csv':
|
||||||
print('Writing .csv file to', export_path)
|
print('Writing .csv file to', export_path)
|
||||||
with open(str(export_path), 'w', newline='\n', encoding='utf-8') as f:
|
with open(str(export_path), 'w', newline='\n', encoding='utf-8') as f:
|
||||||
writer = csv.writer(f, delimiter=spreadsheet.delimiter)
|
writer = csv.writer(f, delimiter=spreadsheet.delimiter)
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
#print(row)
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
|
|
||||||
elif spreadsheet.format == 'xlsx':
|
elif spreadsheet.format == 'xlsx':
|
||||||
|
|
Loading…
Reference in New Issue