HK => HKG
This commit is contained in:
parent
4387f7a8c2
commit
634ea4b77a
2420 changed files with 1814 additions and 1842 deletions
|
|
@ -1,575 +0,0 @@
|
|||
from pathlib import Path
|
||||
import json
|
||||
|
||||
print("params=" + param)
|
||||
print( "dir= " + directory_to_process + "/page_catalog_group_recommend.lxml");
|
||||
file_xml = open(directory_to_process + "/page_catalog_group_recommend.lxml", 'r')
|
||||
file_content_main = file_xml.read()
|
||||
#print(file_xml.read())
|
||||
# ; include-file=dummy_layout.inc
|
||||
file_inc = open(directory_to_process + "/dummy_layout.inc", 'r')
|
||||
file_inc_content = file_inc.read()
|
||||
|
||||
|
||||
file_xml.close()
|
||||
|
||||
if "template1" in param:
|
||||
file_inc2 = open(directory_to_process + "/event/promotion_template1.inc", 'r')
|
||||
file_inc2_content = file_inc2.read()
|
||||
file_inc_img = open(directory_to_process + "/../image/event/image_template1", 'r')
|
||||
file_inc2_img_content = file_inc_img.read()
|
||||
|
||||
# replace key.
|
||||
|
||||
sp_key = file_inc2_img_content.split("\n")
|
||||
print("sp_key = " + str(len( sp_key)))
|
||||
for sp_line in sp_key:
|
||||
sp_line = sp_line.strip()
|
||||
key_val = sp_line.split("=")
|
||||
if len( key_val) == 2:
|
||||
print("k = " + key_val[0] + " val=" + key_val[1])
|
||||
file_inc2_content = file_inc2_content.replace( "###" + key_val[0], '"' + key_val[1].strip() + '"')
|
||||
|
||||
|
||||
file_inc_event_click = open(directory_to_process + "/event/promotion_onclick1.inc", 'r')
|
||||
file_inc_event_click_content = file_inc_event_click.read()
|
||||
|
||||
file_inc2_content = file_inc2_content.replace("###EventOnClick", file_inc_event_click_content)
|
||||
|
||||
|
||||
print(file_inc2_content)
|
||||
|
||||
#print( file_inc_content)
|
||||
content_data_was_repack = file_content_main.replace(";dummy_layout.inc", file_inc_content)
|
||||
content_data = content_data_was_repack.replace(";BigLogoLayout", file_inc2_content)
|
||||
|
||||
begin_text = content_data.index(";TAGESP")
|
||||
end_text = content_data.index(";TAGESP", begin_text + 7)
|
||||
print("TAGESP sub text = " + str(begin_text) + " end = " + str(end_text))
|
||||
tmp1 = content_data[: begin_text - 7]
|
||||
|
||||
tmp2 = content_data[ end_text:-1]
|
||||
#print("tmp1=" + tmp1)
|
||||
#print("tmp2=" + tmp2)
|
||||
|
||||
content_data = tmp1 + tmp2
|
||||
|
||||
file_xml3_out = open(directory_to_process + "/event/out_put_file1.txt", 'r')
|
||||
file_xml3_out_content = file_xml3_out.read()
|
||||
file_xml3_out_content = file_xml3_out_content.strip()
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\r", "")
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\n", "")
|
||||
|
||||
file_xml3 = open(directory_to_process + file_xml3_out_content, 'w')
|
||||
file_xml3.write( content_data)
|
||||
file_xml3.close()
|
||||
|
||||
if "template2" in param:
|
||||
file_inc2 = open(directory_to_process + "/event/promotion_template2.inc", 'r')
|
||||
file_inc2_content = file_inc2.read()
|
||||
file_inc_img = open(directory_to_process + "/../image/event/image_template2", 'r')
|
||||
file_inc2_img_content = file_inc_img.read()
|
||||
|
||||
# replace key.
|
||||
|
||||
sp_key = file_inc2_img_content.split("\n")
|
||||
print("sp_key = " + str(len( sp_key)))
|
||||
for sp_line in sp_key:
|
||||
sp_line = sp_line.strip()
|
||||
key_val = sp_line.split("=")
|
||||
if len( key_val) == 2:
|
||||
print("k = " + key_val[0] + " val=" + key_val[1])
|
||||
file_inc2_content = file_inc2_content.replace( "###" + key_val[0], '"' + key_val[1].strip() + '"')
|
||||
|
||||
|
||||
file_inc_event_click = open(directory_to_process + "/event/promotion_onclick2.inc", 'r')
|
||||
file_inc_event_click_content = file_inc_event_click.read()
|
||||
|
||||
file_inc2_content = file_inc2_content.replace("###EventOnClick", file_inc_event_click_content)
|
||||
|
||||
|
||||
print(file_inc2_content)
|
||||
|
||||
#print( file_inc_content)
|
||||
content_data_was_repack = file_content_main.replace(";dummy_layout.inc", file_inc_content)
|
||||
content_data = content_data_was_repack.replace(";BigLogoLayout", file_inc2_content)
|
||||
|
||||
begin_text = content_data.index(";TAGESP")
|
||||
end_text = content_data.index(";TAGESP", begin_text + 7)
|
||||
#print("sub text = " + str(begin_text) + " end = " + str(end_text))
|
||||
tmp1 = content_data[: begin_text - 7]
|
||||
|
||||
tmp2 = content_data[ end_text:-1]
|
||||
#print("tmp1=" + tmp1)
|
||||
#print("tmp2=" + tmp2)
|
||||
|
||||
content_data = tmp1 + tmp2
|
||||
|
||||
file_xml3_out = open(directory_to_process + "/event/out_put_file2.txt", 'r')
|
||||
file_xml3_out_content = file_xml3_out.read()
|
||||
file_xml3_out_content = file_xml3_out_content.strip()
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\r", "")
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\n", "")
|
||||
|
||||
file_xml3 = open(directory_to_process + file_xml3_out_content, 'w')
|
||||
file_xml3.write( content_data)
|
||||
file_xml3.close()
|
||||
|
||||
if "template3" in param:
|
||||
file_inc3 = open(directory_to_process + "/event/promotion_template3.inc", 'r')
|
||||
file_inc3_content = file_inc3.read()
|
||||
file_inc_img = open(directory_to_process + "/../image/event/image_template3", 'r')
|
||||
file_inc3_img_content = file_inc_img.read()
|
||||
|
||||
# replace key.
|
||||
|
||||
sp_key = file_inc3_img_content.split("\n")
|
||||
print("sp_key = " + str(len( sp_key)))
|
||||
for sp_line in sp_key:
|
||||
sp_line = sp_line.strip()
|
||||
key_val = sp_line.split("=")
|
||||
print("Kenta420:", key_val)
|
||||
if len( key_val) == 2:
|
||||
print("k = " + key_val[0] + " val=" + key_val[1])
|
||||
file_inc3_content = file_inc3_content.replace( "###" + key_val[0], '"' + key_val[1].strip() + '"')
|
||||
|
||||
|
||||
file_inc_event_click = open(directory_to_process + "/event/promotion_onclick3.inc", 'r')
|
||||
file_inc_event_click_content = file_inc_event_click.read()
|
||||
|
||||
file_inc3_content = file_inc3_content.replace("###EventOnClick", file_inc_event_click_content)
|
||||
|
||||
|
||||
print(file_inc3_content)
|
||||
|
||||
#print( file_inc_content)
|
||||
content_data_was_repack = file_content_main.replace(";dummy_layout.inc", file_inc_content)
|
||||
content_data = content_data_was_repack.replace(";BigLogoLayout", file_inc3_content)
|
||||
|
||||
begin_text = content_data.index(";TAGESP")
|
||||
end_text = content_data.index(";TAGESP", begin_text + 7)
|
||||
#print("sub text = " + str(begin_text) + " end = " + str(end_text))
|
||||
tmp1 = content_data[: begin_text - 7]
|
||||
|
||||
tmp3 = content_data[ end_text:-1]
|
||||
#print("tmp1=" + tmp1)
|
||||
#print("tmp3=" + tmp3)
|
||||
|
||||
content_data = tmp1 + tmp3
|
||||
|
||||
file_xml3_out = open(directory_to_process + "/event/out_put_file3.txt", 'r')
|
||||
file_xml3_out_content = file_xml3_out.read()
|
||||
file_xml3_out_content = file_xml3_out_content.strip()
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\r", "")
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\n", "")
|
||||
|
||||
file_xml3 = open(directory_to_process + file_xml3_out_content, 'w')
|
||||
file_xml3.write( content_data)
|
||||
file_xml3.close()
|
||||
|
||||
|
||||
if "template4" in param:
|
||||
# NOTE: promotion_template4.inc, image_template4, promotion_onclick4.inc, out_put_file4.txt
|
||||
|
||||
# promotion 4
|
||||
file_inc3 = open(directory_to_process + "/event/promotion_template4.inc", 'r')
|
||||
file_inc3_content = file_inc3.read()
|
||||
file_inc_img = open(directory_to_process + "/../image/event/image_template4", 'r')
|
||||
file_inc3_img_content = file_inc_img.read()
|
||||
|
||||
# replace key.
|
||||
|
||||
sp_key = file_inc3_img_content.split("\n")
|
||||
print("sp_key = " + str(len( sp_key)))
|
||||
for sp_line in sp_key:
|
||||
sp_line = sp_line.strip()
|
||||
key_val = sp_line.split("=")
|
||||
print("Kenta420:", key_val)
|
||||
if len( key_val) == 2:
|
||||
print("k = " + key_val[0] + " val=" + key_val[1])
|
||||
file_inc3_content = file_inc3_content.replace( "###" + key_val[0], '"' + key_val[1].strip() + '"')
|
||||
|
||||
|
||||
file_inc_event_click = open(directory_to_process + "/event/promotion_onclick4.inc", 'r')
|
||||
file_inc_event_click_content = file_inc_event_click.read()
|
||||
|
||||
file_inc3_content = file_inc3_content.replace("###EventOnClick", file_inc_event_click_content)
|
||||
|
||||
|
||||
print(file_inc3_content)
|
||||
|
||||
#print( file_inc_content)
|
||||
content_data_was_repack = file_content_main.replace(";dummy_layout.inc", file_inc_content)
|
||||
content_data = content_data_was_repack.replace(";BigLogoLayout", file_inc3_content)
|
||||
|
||||
begin_text = content_data.index(";TAGESP")
|
||||
end_text = content_data.index(";TAGESP", begin_text + 7)
|
||||
#print("sub text = " + str(begin_text) + " end = " + str(end_text))
|
||||
tmp1 = content_data[: begin_text - 7]
|
||||
|
||||
tmp3 = content_data[ end_text:-1]
|
||||
#print("tmp1=" + tmp1)
|
||||
#print("tmp3=" + tmp3)
|
||||
|
||||
content_data = tmp1 + tmp3
|
||||
|
||||
file_xml3_out = open(directory_to_process + "/event/out_put_file4.txt", 'r')
|
||||
file_xml3_out_content = file_xml3_out.read()
|
||||
file_xml3_out_content = file_xml3_out_content.strip()
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\r", "")
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\n", "")
|
||||
|
||||
file_xml3 = open(directory_to_process + file_xml3_out_content, 'w')
|
||||
file_xml3.write( content_data)
|
||||
file_xml3.close()
|
||||
|
||||
|
||||
|
||||
if "template5" in param:
|
||||
|
||||
# promotion thai tea
|
||||
file_inc3 = open(directory_to_process + "/event/promotion_template5.inc", 'r')
|
||||
file_inc3_content = file_inc3.read()
|
||||
file_inc_img = open(directory_to_process + "/../image/event/image_template5", 'r')
|
||||
file_inc3_img_content = file_inc_img.read()
|
||||
|
||||
# replace key.
|
||||
|
||||
sp_key = file_inc3_img_content.split("\n")
|
||||
print("sp_key = " + str(len( sp_key)))
|
||||
for sp_line in sp_key:
|
||||
sp_line = sp_line.strip()
|
||||
key_val = sp_line.split("=")
|
||||
print("Kenta420:", key_val)
|
||||
if len( key_val) == 2:
|
||||
print("k = " + key_val[0] + " val=" + key_val[1])
|
||||
file_inc3_content = file_inc3_content.replace( "###" + key_val[0], '"' + key_val[1].strip() + '"')
|
||||
|
||||
|
||||
file_inc_event_click = open(directory_to_process + "/event/promotion_onclick5.inc", 'r')
|
||||
file_inc_event_click_content = file_inc_event_click.read()
|
||||
|
||||
file_inc3_content = file_inc3_content.replace("###EventOnClick", file_inc_event_click_content)
|
||||
|
||||
|
||||
print(file_inc3_content)
|
||||
|
||||
#print( file_inc_content)
|
||||
content_data_was_repack = file_content_main.replace(";dummy_layout.inc", file_inc_content)
|
||||
content_data = content_data_was_repack.replace(";BigLogoLayout", file_inc3_content)
|
||||
|
||||
begin_text = content_data.index(";TAGESP")
|
||||
end_text = content_data.index(";TAGESP", begin_text + 7)
|
||||
#print("sub text = " + str(begin_text) + " end = " + str(end_text))
|
||||
tmp1 = content_data[: begin_text - 7]
|
||||
|
||||
tmp3 = content_data[ end_text:-1]
|
||||
#print("tmp1=" + tmp1)
|
||||
#print("tmp3=" + tmp3)
|
||||
|
||||
content_data = tmp1 + tmp3
|
||||
|
||||
file_xml3_out = open(directory_to_process + "/event/out_put_file5.txt", 'r')
|
||||
file_xml3_out_content = file_xml3_out.read()
|
||||
file_xml3_out_content = file_xml3_out_content.strip()
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\r", "")
|
||||
file_xml3_out_content = file_xml3_out_content.replace("\n", "")
|
||||
|
||||
file_xml3 = open(directory_to_process + file_xml3_out_content, 'w')
|
||||
file_xml3.write( content_data)
|
||||
file_xml3.close()
|
||||
|
||||
|
||||
|
||||
|
||||
###############################################################
|
||||
# MULTI PRO
|
||||
###############################################################
|
||||
print("dummy.current_file_name=", current_file_name)
|
||||
if "multi_promotion" in param:
|
||||
|
||||
print("Should gen multi")
|
||||
|
||||
files = os.listdir(directory_to_process + "/event/")
|
||||
files = [f for f in files if f.startswith("multi_promotion_config")]
|
||||
for filename in files:
|
||||
recommend_multi_pro_buff = Path(directory_to_process + "/page_catalog_group_recommend_multi_pro.lxml").read_text()
|
||||
# print("pre-regex multi pro buff = ", recommend_multi_pro_buff)
|
||||
|
||||
|
||||
# print("test split", json.dumps(recommend_multi_pro_buff.splitlines(), indent=2))
|
||||
temp = []
|
||||
for buffer in recommend_multi_pro_buff.splitlines():
|
||||
# print("buffer:"+buffer)
|
||||
if "\\n" in buffer:
|
||||
# print("found")
|
||||
buffer = buffer.replace("\\n", "\\\\n")
|
||||
temp.append(buffer)
|
||||
|
||||
recommend_multi_pro_buff = "\n".join(temp)
|
||||
# print("after-splitlines multi pro buff = ", recommend_multi_pro_buff)
|
||||
|
||||
# recommend_multi_pro_buff = recommend_multi_pro.read()
|
||||
# recommend_multi_pro.close()
|
||||
|
||||
#read config
|
||||
multi_pro_config_file = open(directory_to_process + "/event/"+ filename)
|
||||
multi_pro_config = json.load(multi_pro_config_file)
|
||||
|
||||
# if has any 'reorder'
|
||||
order_list: list = []
|
||||
|
||||
index = 0
|
||||
promotion_name = []
|
||||
while index < len(multi_pro_config):
|
||||
promotion_config = multi_pro_config[index]
|
||||
index += 1
|
||||
|
||||
# add promotion name for create filename later
|
||||
promotion_name.append(promotion_config["name"])
|
||||
|
||||
#load template
|
||||
template_file = open(directory_to_process + promotion_config["template"])
|
||||
template = template_file.read()
|
||||
template_file.close()
|
||||
|
||||
# TODO: get script and replace ###event_on_click
|
||||
if gen_season_pass and promotion_config["name"].startswith("s") and "product_code_key" in promotion_config.keys():
|
||||
product_code = promotion_config["product_code_key"]
|
||||
script = None
|
||||
print("try find script for ", product_code)
|
||||
try:
|
||||
script = season_pass_menu_script[product_code]
|
||||
if "\\n" in script:
|
||||
script = script.replace("\\n", "\\\\n")
|
||||
except:
|
||||
pass
|
||||
|
||||
# print("script=", script)
|
||||
|
||||
if script != None:
|
||||
template = template.replace("###on_click_script", script.strip())
|
||||
|
||||
# replace state
|
||||
product_code_state = "$Sum" + ''.join(product_code.split('.')[1:]).replace("-","").replace("#","")
|
||||
product_code_list = product_code.split('.')[1:]
|
||||
pd_dot_btn = [pd +".Button" for pd in product_code_list if "#" not in pd]
|
||||
print("gen state", product_code_state)
|
||||
|
||||
# template = template.replace("BigButtonEnable", f"Flag( {','.join(pd_dot_btn)},Disable=Invisible,{product_code_state})")
|
||||
if "dev" in param:
|
||||
template = template.replace("BigButtonEnable", f"\"Enable\"")
|
||||
else:
|
||||
|
||||
template = template.replace("BigButtonEnable", f"{product_code_state}")
|
||||
|
||||
template = template.replace("###on_click_script", "")
|
||||
|
||||
for key, value in promotion_config["config"].items():
|
||||
template = template.replace("###"+key, '"' + value.strip() + '"')
|
||||
|
||||
promotion_block_str = '\r\n<Block>\r\n\t<State> PromotionState{0} </State>\r\n\t<MarginLeft> 33 </MarginLeft>\r\n\t<MarginTop> 22 </MarginTop>\r\n\t<Width> 484 </Width>\r\n\t<Height> 602 </Height>\r\n'.format(index)
|
||||
if gen_season_pass and promotion_config["name"].startswith("s") and "product_code_key" in promotion_config.keys():
|
||||
promotion_block_str = f"\r\n<Block>\r\n\t<State> Flag( {','.join(pd_dot_btn)},Disable=Invisible,{product_code_state}) </State>\r\n\t<MarginLeft> 33 </MarginLeft>\r\n\t<MarginTop> 22 </MarginTop>\r\n\t<Width> 484 </Width>\r\n\t<Height> 602 </Height>\r\n"
|
||||
|
||||
# insert overlay tag
|
||||
# promotion_block_str += season_pass_menu_big_btn_ui[f"{product_code}.overlay"].replace("menu_overlay_set", "event/menu_overlay_set")
|
||||
try:
|
||||
template = template.replace(";#Overlay", season_pass_menu_big_btn_ui[f"{product_code}.overlay"].replace("menu_overlay_set", "event/menu_overlay_set"))
|
||||
except:
|
||||
print("Overlay not found for "+product_code)
|
||||
pass
|
||||
|
||||
|
||||
if "dev" in param:
|
||||
promotion_block_str = f"\r\n<Block>\r\n\t<State> \"Enable\" </State>\r\n\t<MarginLeft> 33 </MarginLeft>\r\n\t<MarginTop> 22 </MarginTop>\r\n\t<Width> 484 </Width>\r\n\t<Height> 602 </Height>\r\n"
|
||||
|
||||
# Add text for price and name
|
||||
# season_pass_menu_big_btn_ui
|
||||
if gen_season_pass and promotion_config["name"].startswith("s") and "product_code_key" in promotion_config.keys():
|
||||
price_name_ui = season_pass_menu_big_btn_ui[product_code]
|
||||
if price_name_ui != None:
|
||||
print("get cloned ui OK")
|
||||
# print("preview\n", price_name_ui)
|
||||
template += "\r\n" + price_name_ui.replace("\\n", "\\\\n")
|
||||
|
||||
# <Image>
|
||||
# <X> 10 </X>
|
||||
# <Y> 10 </Y>
|
||||
# <Filename> "ROOT/taobin_project/inter/sgp/image/event/menu_overlay_set/gradeB/button_overlay_catalog_3_posi1.png" </Filename>
|
||||
# </Image>
|
||||
# print("after replace\n", template)
|
||||
|
||||
# try:
|
||||
# # get overlay
|
||||
# overlay_original_tag = season_pass_menu_big_btn_ui[f"{product_code}.overlay"]
|
||||
# # print(f"[OverlayClone] {product_code} --- "+overlay_original_tag+".")
|
||||
# overlay_new_path = " ".join(overlay_original_tag.split(' ')[3:-1]).replace("menu_overlay_set", "event/menu_overlay_set").replace(")","")
|
||||
# template += f"\t<Image>\r\n\t<X> 10 </X>\r\n\t<Y> 10 </Y>\r\n\t<Filename> {overlay_new_path} </Filename>\r\n\t</Image>\r\n"
|
||||
# except:
|
||||
# print("\t\t> Overlay not found for "+product_code+"\n")
|
||||
|
||||
|
||||
|
||||
promotion_block_str += template
|
||||
|
||||
|
||||
|
||||
promotion_block_str += '\r\n</Block>\r\n'
|
||||
|
||||
recommend_multi_pro_buff = re.sub(r'(?is)(;block{0}).*(;endblock{0})'.format(index), r'\1{0}\2'.format(promotion_block_str), recommend_multi_pro_buff)
|
||||
# print("before idx cond check", recommend_multi_pro_buff)
|
||||
# Path("./before_idx_cond_check."+str(index)).write_text(recommend_multi_pro_buff, encoding="utf-8")
|
||||
|
||||
if gen_season_pass and promotion_config["name"].startswith("s") and "product_code_key" in promotion_config.keys():
|
||||
current_season = int([ s for s in product_code.split('.')[0]][1])
|
||||
print("[REPL] season ", current_season)
|
||||
filter_sm = [ pd for pd in season_pass_menu[current_season] if pd.endswith("sm")]
|
||||
print("[SM] expect at least 4, ", len(filter_sm))
|
||||
|
||||
has_reorder = "reorder" in promotion_config.keys()
|
||||
# interact_idx = (-1, -1)
|
||||
# do load list
|
||||
if has_reorder:
|
||||
print("reorder mode")
|
||||
order_list = promotion_config["reorder"]
|
||||
print(json.dumps(order_list, indent=2), " while ", json.dumps(filter_sm, indent=2))
|
||||
# buffer_key = ""
|
||||
|
||||
# new_sorted_list = [
|
||||
# "",
|
||||
# "",
|
||||
# "",
|
||||
# ""
|
||||
# ]
|
||||
|
||||
filter_sm = order_list
|
||||
|
||||
# sort by has_order
|
||||
# for filtered in filter_sm:
|
||||
# print("try reorder", filtered, order_list)
|
||||
# # get index from order
|
||||
# expect_index = order_list.index(filtered)
|
||||
# # interact_idx[0] = expect_index
|
||||
# print("get expect = ", expect_index)
|
||||
# current_index = filter_sm.index(filtered)
|
||||
# # interact_idx[1] = current_index
|
||||
# print("get current = ", current_index)
|
||||
# is_matched_index = expect_index != -1 and expect_index == current_index
|
||||
# print(f"check match {filtered}: ", not is_matched_index)
|
||||
|
||||
|
||||
# # apply to new list
|
||||
# new_sorted_list[expect_index] = filtered
|
||||
|
||||
|
||||
|
||||
# if not is_matched_index:
|
||||
# print(f"swap current={filtered}@{current_index} to position@{expect_index} was {filter_sm[expect_index]}")
|
||||
# buffer_key = filter_sm[expect_index]
|
||||
# filter_sm[expect_index] = filtered
|
||||
# filter_sm[current_index] = buffer_key
|
||||
# buffer_key = ""
|
||||
|
||||
# print("final reorder \n\n",filter_sm,order_list,"\n\n", new_sorted_list ,"\n\n")
|
||||
# try get block
|
||||
generated_block_buffer = ""
|
||||
for sm_menu in filter_sm:
|
||||
|
||||
if ";season-sm-block" not in recommend_multi_pro_buff:
|
||||
print("expect already generated")
|
||||
break
|
||||
|
||||
try:
|
||||
sm_menu = ".".join(sm_menu.split(".")[:-1])
|
||||
print("sm_menu", sm_menu)
|
||||
|
||||
curr_sm_block = store_block_list[sm_menu]
|
||||
curr_sm_block = curr_sm_block.replace(",$Sum", ",Disable=Invisible,$Sum").replace("\\n", "\\\\n")
|
||||
generated_block_buffer += curr_sm_block
|
||||
|
||||
# if "52-05-02-0076" in sm_menu:
|
||||
# print("52-05-02-0076", generated_block_buffer)
|
||||
except:
|
||||
print("Cannot find store block for ", sm_menu)
|
||||
pass
|
||||
|
||||
|
||||
# replace by set of season menus
|
||||
if generated_block_buffer != "" and ";season-sm-block" in recommend_multi_pro_buff:
|
||||
print("init replace block")
|
||||
recommend_multi_pro_buff = re.sub(r'(?is);season-sm-block.*?;end-season-sm-block', generated_block_buffer, recommend_multi_pro_buff)
|
||||
# print(recommend_multi_pro_buff)
|
||||
# recommend_multi_pro_buff = recommend_multi_pro_buff.replace("\\n", "\\n")
|
||||
|
||||
|
||||
|
||||
# Path("./generated_buffer_sm."+str(index)).write_text(recommend_multi_pro_buff, encoding="utf-8")
|
||||
|
||||
if index == 2:
|
||||
# expend block3 to full width bottom
|
||||
inner_block = re.search(r'(?is);block{0}(.*);endblock{0}'.format(index+1), recommend_multi_pro_buff).group(1)
|
||||
inner_block = inner_block.replace("<Width> 516 </Width>", "<Width> 1032 </Width>", 2)
|
||||
inner_block = inner_block.replace("<Max> 4 </Max>", "<Max> 8 </Max>", 1)
|
||||
inner_block = inner_block.replace("<Column> 2 </Column>", "<Column> 4 </Column>", 1)
|
||||
recommend_multi_pro_buff = re.sub(r'(?is)(;block{0}).*(;endblock{0})'.format(index+1), r'\1{0}\2'.format(inner_block), recommend_multi_pro_buff)
|
||||
|
||||
# remove block4
|
||||
recommend_multi_pro_buff = re.sub(r'(?is)(;block{0}).*(;endblock{0})'.format(index+2), r'\1\2', recommend_multi_pro_buff)
|
||||
# print("after idx 2 cond check", recommend_multi_pro_buff)
|
||||
|
||||
if index == 3:
|
||||
# create expand block
|
||||
# print("inner block2. Is buffer contain ;block?", ";block" in recommend_multi_pro_buff, re.search(r'(?is)(;block{0}.*;endblock{0})'.format(index+1), recommend_multi_pro_buff))
|
||||
inner_block2 = re.search(r'(?is)(;block{0}.*;endblock{0})'.format(index+1), recommend_multi_pro_buff).group(1)
|
||||
|
||||
# print("inner_block2 = ", inner_block2)
|
||||
# Path("./inner_block2."+str(index)).write_text(inner_block2, encoding="utf-8")
|
||||
# Path("./inner_block2_buffer."+str(index)).write_text(recommend_multi_pro_buff, encoding="utf-8")
|
||||
|
||||
|
||||
inner_block2 = inner_block2.replace(";block{0}".format(index+1), ";block{0}-expand".format(index+1))
|
||||
# print("inner_block2_1 = ", inner_block2)
|
||||
# Path("./inner_block2_1."+str(index)).write_text(inner_block2, encoding="utf-8")
|
||||
# Path("./inner_block2_1_buffer."+str(index)).write_text(recommend_multi_pro_buff, encoding="utf-8")
|
||||
|
||||
|
||||
inner_block2 = inner_block2.replace(";endblock{0}".format(index+1), ";endblock{0}-expand".format(index+1))
|
||||
# print("inner_block2_2 = ", inner_block2)
|
||||
# Path("./inner_block2_2."+str(index)).write_text(inner_block2, encoding="utf-8")
|
||||
# Path("./inner_block2_2_buffer."+str(index)).write_text(recommend_multi_pro_buff, encoding="utf-8")
|
||||
# print(f"inner_block2_2.buffer {index} = ", recommend_multi_pro_buff)
|
||||
|
||||
inner_block2 = inner_block2.replace("<Width> 516 </Width>", "<Width> 1032 </Width>", 2)
|
||||
|
||||
# inner_block2 = inner_block2.replace("<State> \"Enable\" </State> ", "<State>\r\n\teval(\r\n\tIf PromotionState{0} = \"Enable\" Then\r\n\t\tVar block_expend_show = \"Invisible\"\r\n\tElse\r\n\t\tVar block_expend_show = \"Enable\"\r\n\tEndIf\r\n\tVar return = block_expend_show\r\n\t)\r\n</State>".format(index), 1)
|
||||
inner_block2 = inner_block2.replace("<Max> 4 </Max>", "<Max>\r\neval(\r\n\tIf CountEnablePromotion > 2 Then\r\n\t\tVar max_count = 4\r\n\tElse\r\n\t\tVar max_count = 8\r\n\tEndIf\r\n\tVar return = max_count\r\n)\r\n</Max>", 1)
|
||||
inner_block2 = inner_block2.replace("<Column> 2 </Column>", "<Column>\r\neval(\r\n\tIf CountEnablePromotion > 2 Then\r\n\t\tVar column_count = 2\r\n\tElse\r\n\t\tVar column_count = 4\r\n\tEndIf\r\n\tVar return = column_count\r\n)\r\n</Column>", 1)
|
||||
# print("inner_block2_3 = ", inner_block2)
|
||||
if "\\n" in inner_block2:
|
||||
inner_block2 = inner_block2.replace("\\n", "\\\\n")
|
||||
recommend_multi_pro_buff = re.sub(r'(?is);block{0}.*;endblock{0}'.format(index+1), inner_block2, recommend_multi_pro_buff)
|
||||
|
||||
# print("after idx 3 cond check", recommend_multi_pro_buff)
|
||||
# print("index = ", index)
|
||||
|
||||
|
||||
# create promotion file
|
||||
count_name_dict = {
|
||||
2: "double_",
|
||||
3: "triple_"
|
||||
}
|
||||
|
||||
# print("write buffer encode: ", str(recommend_multi_pro_buff))
|
||||
|
||||
# test
|
||||
# print("test pathlib", Path(directory_to_process + "/page_catalog_group_recommend_multi_pro.lxml").read_text())
|
||||
|
||||
|
||||
# promo_file = open(directory_to_process + "/event/" + count_name_dict[len(multi_pro_config)]+ "promotion_" + "_and_".join(promotion_name) + ".lxml", "w")
|
||||
Path(directory_to_process + "/event/" + count_name_dict[len(multi_pro_config)]+ "promotion_" + "_and_".join(promotion_name) + ".lxml").write_text(recommend_multi_pro_buff, encoding="utf-8")
|
||||
|
||||
|
||||
# promo_file.write(recommend_multi_pro_buff)
|
||||
# # promo_file.writelines(recommend_multi_pro_buff.split("\r\n"))
|
||||
# promo_file.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue