THAI: Added v3 support banner from sheet

This commit is contained in:
Kenta420 2025-04-09 10:39:43 +07:00
parent 1ce7b3239c
commit 69360a7519
3 changed files with 360 additions and 280 deletions

View file

@ -310,6 +310,33 @@
out_xml('\t\t</EventOnClick>\n')
out_xml('\t\t</Menu>\n\n')
def GenBanner(type, thai_media, eng_media, event_on_click_script, start_date_time, end_date_time, state_var):
str_con = []
if re.match(r'(\d{4})/(\d{2})/(\d{2})T(\d{2}):(\d{2}):(\d{2})', start_date_time.strip()):
str_con.append(f'DateTimeStart="{start_date_time.strip()}"')
if re.match(r'(\d{4})/(\d{2})/(\d{2})T(\d{2}):(\d{2}):(\d{2})', end_date_time.strip()):
str_con.append(f'DateTimeEnd="{end_date_time.strip()}"')
if re.match(r'^\w.*', state_var.strip()):
str_con.append(f'Var={state_var.strip()},')
out_xml('\t\t<Banner>\n')
out_xml('\t\t\t<State> Flag( '+ ",".join(str_con) + ' ) </State>\n')
out_xml('\t\t\t<Type> ' + type + ' </Type>\n')
out_xml('\t\t\t<Media>\n')
out_xml('\t\t\t\teval(\n')
out_xml('\t\t\t\t\tIf show_eng = "true" Then\n')
out_xml('\t\t\t\t\t\tVar return = ' + eng_media + '\n')
out_xml('\t\t\t\t\tElse\n')
out_xml('\t\t\t\t\t\tVar return = ' + thai_media + '\n')
out_xml('\t\t\t\t\tEndIf\n')
out_xml('\t\t\t\t)\n')
out_xml('\t\t\t</Media>\n')
out_xml('\t\t\t<EventOnClick>\n')
out_xml('\t\t\t\t' + event_on_click_script.replace('\\n', '\n').replace('\\t', '\t') + '\n')
out_xml('\t\t\t</EventOnClick>\n')
out_xml('\t\t</Banner>\n')
idx_lang_myanmar = 6
idx_lang_malay = 5
idx_lang_japan = 4
@ -409,26 +436,38 @@
out_xml( '\t;' + spl[0] + '\r\n')
continue
[hot_pd_v1, hot_pd_v2] = spl[ idx_name][ idx_hot_product_code].split(',')
[cold_pd_v1, cold_pd_v2] = spl[ idx_name][ idx_cold_product_code].split(',')
[blend_pd_v1, blend_pd_v2] = spl[ idx_name][ idx_blend_product_code].split(',')
if spl[idx_desc][idx_lang_eng].startswith("BANNER"):
date_time_start = spl[idx_name][idx_date_time_start]
date_time_end = spl[idx_name][idx_date_time_end]
state_var = spl[idx_name][idx_product_var]
date_time_start = spl[idx_name][idx_date_time_start]
date_time_end = spl[idx_name][idx_date_time_end]
product_var = spl[idx_name][idx_product_var]
try:
default_topping = spl[idx_name][idx_of_default_toppimg]
except:
default_topping = "0"
print(f"spl[{idx_name}] =", spl[idx_name])
print(f"Expected indices: date_time_start:{date_time_start}, date_time_end:{date_time_end}, product_var:{product_var} , default_topping={default_topping}")
type = spl[idx_desc][idx_lang_thai]
eng_media = spl[idx_img][idx_lang_eng]
thai_media = spl[idx_img][idx_lang_thai]
on_click_script = spl[idx_name][idx_lang_thai]
for [hot_pd, cold_pd, blend_pd] in [[hot_pd_v1, cold_pd_v1, blend_pd_v1], [hot_pd_v2, cold_pd_v2, blend_pd_v2]]:
if hot_pd == '-' and cold_pd == '-' and blend_pd == '-':
continue
else:
print(f"Gen ==> hot={hot_pd}, cold={cold_pd}, blend={blend_pd}")
GenMenuV3(hot_pd, cold_pd, blend_pd, date_time_start, date_time_end, product_var, default_topping)
GenBanner(type, thai_media, eng_media, on_click_script, date_time_start, date_time_end, state_var)
else:
[hot_pd_v1, hot_pd_v2] = spl[ idx_name][ idx_hot_product_code].split(',')
[cold_pd_v1, cold_pd_v2] = spl[ idx_name][ idx_cold_product_code].split(',')
[blend_pd_v1, blend_pd_v2] = spl[ idx_name][ idx_blend_product_code].split(',')
date_time_start = spl[idx_name][idx_date_time_start]
date_time_end = spl[idx_name][idx_date_time_end]
product_var = spl[idx_name][idx_product_var]
try:
default_topping = spl[idx_name][idx_of_default_toppimg]
except:
default_topping = "0"
print(f"spl[{idx_name}] =", spl[idx_name])
print(f"Expected indices: date_time_start:{date_time_start}, date_time_end:{date_time_end}, product_var:{product_var} , default_topping={default_topping}")
for [hot_pd, cold_pd, blend_pd] in [[hot_pd_v1, cold_pd_v1, blend_pd_v1], [hot_pd_v2, cold_pd_v2, blend_pd_v2]]:
if hot_pd == '-' and cold_pd == '-' and blend_pd == '-':
continue
else:
print(f"Gen ==> hot={hot_pd}, cold={cold_pd}, blend={blend_pd}")
GenMenuV3(hot_pd, cold_pd, blend_pd, date_time_start, date_time_end, product_var, default_topping)
out_xml('\t\t</Menus>\n\n')
out_xml('</ScrollableCatalog>\n')