markup: pass workdir around, don't recalc all the time
This commit is contained in:
@ -15,16 +15,19 @@ def format_season(s):
|
||||
return s[:1] + s[2:]
|
||||
|
||||
|
||||
def write_spreadsheet(matches, subdir, catname, filename):
|
||||
def write_spreadsheet(matches, workdir, file_base):
|
||||
if not matches:
|
||||
print('write_spreadsheet: no matches. skipping.')
|
||||
return
|
||||
return None
|
||||
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
|
||||
# header row
|
||||
ws.append(['Season', 'Gender', 'Name', 'Style Number', 'Color'])
|
||||
|
||||
# TODO: uniquify and sort matches
|
||||
|
||||
for m in matches:
|
||||
# in the case of kids,
|
||||
# we might have multiple products in a match
|
||||
@ -37,14 +40,10 @@ def write_spreadsheet(matches, subdir, catname, filename):
|
||||
for s, g, n, m, c in zip_longest(seasons, genders, names, materials, colors, fillvalue=''):
|
||||
ws.append([format_season(s), g, n, m, c])
|
||||
|
||||
# # Python types will automatically be converted
|
||||
# import datetime
|
||||
# ws['A2'] = datetime.datetime.now()
|
||||
# ws['A2'].style = 'Good'
|
||||
|
||||
# save
|
||||
dir = os.path.join(WORKDIR, subdir, catname)
|
||||
ensure_dir(dir)
|
||||
path = os.path.join(dir, f"{filename}.xlsx")
|
||||
ensure_dir(workdir)
|
||||
path = os.path.join(workdir, f"{file_base}.xlsx")
|
||||
wb.save(path)
|
||||
set_file_perms(path)
|
||||
|
||||
return path
|
||||
|
||||
Reference in New Issue
Block a user