c39b3051 by 周伟奇

add rebuild result

1 parent e9bc46f2
......@@ -255,7 +255,7 @@ class Command(BaseCommand, LoggerMixin):
result_dict = ocr_res.get('data', {})
wb = BSWorkbook(set(), set(), set(), set(), set())
wb.ltgt_build(label, result_dict)
rebuild_res = wb.ltgt_build(label, result_dict)
wb.remove_base_sheet()
wb.save(excel_path)
except Exception as e:
......
......@@ -704,21 +704,28 @@ class BSWorkbook(Workbook):
def ltgt_build(self, label, result_dict):
ws = self.create_sheet(label)
rebuild_res = {}
for key, value in result_dict.items():
if isinstance(value, list):
value_list = [dict_item.get('words') for dict_item in value]
ws.append((key, *value_list))
ws.append((key, '、'.join(value_list)))
rebuild_res[key] = '、'.join(value_list)
elif isinstance(value, dict):
if 'words' in value:
ws.append((key, value['words']))
rebuild_res[key] = value['words']
else:
for sub_key, sub_value in value.items():
if isinstance(sub_value, dict):
ws.append(('{0}: {1}'.format(key, sub_key), sub_value.get('words', '')))
rebuild_res['{0}: {1}'.format(key, sub_key)] = sub_value.get('words', '')
else:
ws.append(('{0}: {1}'.format(key, sub_key), sub_value))
rebuild_res['{0}: {1}'.format(key, sub_key)] = sub_value
else:
ws.append((key, value))
rebuild_res[key] = value
return rebuild_res
def simple_license_rebuild(self, license_summary, document_scheme):
# for ic_license_dict in license_summary.get(consts.IC_CLASSIFY, []):
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!