1
0
forked from ScoDoc/ScoDoc

deal with binary files (zip)

This commit is contained in:
Jean-Marie Place 2021-09-26 23:27:54 +02:00
parent 16b3701815
commit 9ee7dec202
2 changed files with 7 additions and 5 deletions

View File

@ -164,11 +164,12 @@ def list_directory_filenames(path):
return R return R
def add_local_file_to_zip(zipfile, ziproot, pathname, path_in_zip): def add_local_file_to_zip(zipfile, ziproot, pathname, path_in_zip, mode='r'):
"""Read pathname server file and add content to zip under path_in_zip""" """Read pathname server file and add content to zip under path_in_zip"""
rooted_path_in_zip = os.path.join(ziproot, path_in_zip) rooted_path_in_zip = os.path.join(ziproot, path_in_zip)
data = open(pathname).read()
breakpoint() breakpoint()
with open(rooted_path_in_zip, mode=mode) as f:
data = f.read()
zipfile.writestr(rooted_path_in_zip, data) zipfile.writestr(rooted_path_in_zip, data)

View File

@ -471,7 +471,10 @@ class GenTable(object):
def excel(self, wb=None): def excel(self, wb=None):
"""Simple Excel representation of the table""" """Simple Excel representation of the table"""
if wb is None:
ses = sco_excel.ScoExcelSheet(sheet_name=self.xls_sheet_name, wb=wb) ses = sco_excel.ScoExcelSheet(sheet_name=self.xls_sheet_name, wb=wb)
else:
ses = wb.create_sheet(sheet_name=self.xls_sheet_name)
ses.rows += self.xls_before_table ses.rows += self.xls_before_table
style_bold = sco_excel.excel_make_style(bold=True) style_bold = sco_excel.excel_make_style(bold=True)
style_base = sco_excel.excel_make_style() style_base = sco_excel.excel_make_style()
@ -486,8 +489,6 @@ class GenTable(object):
ses.append_single_cell_row(self.origin, style_base) ses.append_single_cell_row(self.origin, style_base)
if wb is None: if wb is None:
return ses.generate() return ses.generate()
else:
ses.generate()
def text(self): def text(self):
"raw text representation of the table" "raw text representation of the table"