markup: spreadsheet handle multiple materials in a match

This commit is contained in:
2019-10-19 17:02:28 -07:00
parent 4cde2233cd
commit ed5236c618

View File

@ -1,4 +1,5 @@
import os import os
from itertools import zip_longest
from openpyxl import Workbook from openpyxl import Workbook
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
@ -10,7 +11,7 @@ def format_season(s):
if not s or len(s) < 4: if not s or len(s) < 4:
return s return s
# 'SS20' -> 'S20' # 'FW20' -> 'F20'
return s[:1] + s[2:] return s[:1] + s[2:]
@ -25,7 +26,16 @@ def write_spreadsheet(matches, subdir, catname, filename):
ws.append(['Season', 'Gender', 'Name', 'Style Number', 'Color']) ws.append(['Season', 'Gender', 'Name', 'Style Number', 'Color'])
for m in matches: for m in matches:
ws.append([format_season(m['season']), m['gender'], m['name'], m['material'], m['color']]) # in the case of kids,
# we might have multiple products in a match
seasons = m['season'].split('\n')
genders = m['gender'].split('\n')
names = m['name'].split('\n')
materials = m['material'].split('\n')
colors = m['color'].split('\n')
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 # # Python types will automatically be converted
# import datetime # import datetime