修改py文件中路径处理相关
This commit is contained in:
parent
6b857e041a
commit
5614d7b87f
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
# 原始字符串
|
# 原始字符串
|
||||||
text = "全副武装的样子。\n即使是极巨化宝可梦的\n攻击也能轻易抵挡。"
|
text = "全副武装的样子。\n即使是极巨化宝可梦的\n攻击也能轻易抵挡。"
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,19 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
|
import os
|
||||||
import openpyxl
|
import openpyxl
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
# 获取py文件所在文件夹绝对路径
|
||||||
|
pydir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
#获取excel相对py文件路径
|
||||||
|
excel_path = os.path.join(pydir, "src", "精灵跟随.xlsx")
|
||||||
|
|
||||||
|
# 获取C文件所在文件夹相对py文件路径
|
||||||
|
cdir = os.path.join(os.path.dirname(pydir), "src")
|
||||||
|
|
||||||
# 文件路径
|
# 文件路径
|
||||||
excel_path = r"c:\Users\Nox\Documents\GitHub\pokeemerald-expansion-Chinese\python_tools\src\精灵跟随.xlsx"
|
c_file_path = os.path.join(cdir, "follower_helper.c")
|
||||||
c_file_path = r"c:\Users\Nox\Documents\GitHub\pokeemerald-expansion-Chinese\src\follower_helper.c"
|
|
||||||
|
|
||||||
# 读取 Excel 文件
|
# 读取 Excel 文件
|
||||||
wb = openpyxl.load_workbook(excel_path)
|
wb = openpyxl.load_workbook(excel_path)
|
||||||
|
|||||||
@ -1,8 +1,16 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
# 获取py文件所在文件夹绝对路径
|
||||||
|
pydir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
# 获取C文件所在文件夹相对py文件路径
|
||||||
|
cdir = os.path.join(os.path.dirname(pydir), "src")
|
||||||
|
|
||||||
# 文件路径
|
# 文件路径
|
||||||
input_file = r"c:\Users\Nox\Documents\GitHub\pokeemerald-expansion-Chinese\src\strings.c"
|
input_file = os.path.join(cdir, "strings.c")
|
||||||
output_file = r"c:\Users\Nox\Documents\GitHub\pokeemerald-expansion-Chinese\extracted_strings.txt"
|
output_file = os.path.join(os.path.dirname(pydir), "extracted_strings.txt")
|
||||||
|
|
||||||
# 正则表达式匹配变量名和 _("...") 之间的内容
|
# 正则表达式匹配变量名和 _("...") 之间的内容
|
||||||
pattern = re.compile(r'const\s+u8\s+(\w+)\[\]\s*=\s*_\("([^"]*)"\)')
|
pattern = re.compile(r'const\s+u8\s+(\w+)\[\]\s*=\s*_\("([^"]*)"\)')
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
from openpyxl import load_workbook
|
from openpyxl import load_workbook
|
||||||
|
|
||||||
|
pydir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
# 文件路径
|
# 文件路径
|
||||||
c_file_path = os.path.dirname(os.path.abspath(__file__))+"/../src/battle_message.c"
|
c_file_path = os.path.join(os.path.dirname(pydir), "src", "battle_message.c")
|
||||||
xlsx_file_path = os.path.dirname(os.path.abspath(__file__))+"/src/战斗文本.xlsx"
|
xlsx_file_path = os.path.join(pydir, "src", "战斗文本.xlsx")
|
||||||
|
|
||||||
# 读取 xlsx 文件并解析为字典
|
# 读取 xlsx 文件并解析为字典
|
||||||
def load_translations(xlsx_file_path):
|
def load_translations(xlsx_file_path):
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
import re
|
import re
|
||||||
import openpyxl
|
import openpyxl
|
||||||
import os
|
import os
|
||||||
@ -45,8 +46,8 @@ def replace_in_c_file(c_file, replacement_dict):
|
|||||||
# 主函数
|
# 主函数
|
||||||
def main():
|
def main():
|
||||||
current_folder = os.path.dirname(os.path.abspath(__file__))
|
current_folder = os.path.dirname(os.path.abspath(__file__))
|
||||||
xlsx_file = current_folder+"/src/debug文本.xlsx" # Excel 文件路径
|
xlsx_file = os.path.join(current_folder, "src", "debug文本.xlsx") # Excel 文件路径
|
||||||
c_file = current_folder+"/../src/battle_debug.c" # C 文件路径
|
c_file = os.path.join(os.path.dirname(current_folder), "src", "battle_debug.c") # C 文件路径
|
||||||
|
|
||||||
# 加载替换字典
|
# 加载替换字典
|
||||||
replacement_dict = load_replacement_dict(xlsx_file)
|
replacement_dict = load_replacement_dict(xlsx_file)
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
import openpyxl
|
import openpyxl
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# 文件路径
|
# 文件路径
|
||||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
h_file_path = os.path.join(base_dir, "../src/data/decoration/header.h")
|
h_file_path = os.path.join(os.path.dirname(base_dir), "src", "data", "decoration", "header.h")
|
||||||
xlsx_path = os.path.join(base_dir, "src/装饰物品.xlsx")
|
xlsx_path = os.path.join(base_dir, "src", "装饰物品.xlsx")
|
||||||
|
|
||||||
# 加载Excel文件
|
# 加载Excel文件
|
||||||
wb = openpyxl.load_workbook(xlsx_path)
|
wb = openpyxl.load_workbook(xlsx_path)
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
import openpyxl
|
import openpyxl
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# 文件路径
|
# 文件路径
|
||||||
h_file_path = os.path.dirname(os.path.abspath(__file__))+"/../src/data/decoration/description.h"
|
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
xlsx_path = os.path.dirname(os.path.abspath(__file__))+"/src/装饰物品.xlsx"
|
h_file_path = os.path.join(os.path.dirname(base_dir), "src", "data", "decoration", "description.h")
|
||||||
|
xlsx_path = os.path.join(base_dir, "src", "装饰物品.xlsx")
|
||||||
|
|
||||||
# 加载Excel文件
|
# 加载Excel文件
|
||||||
wb = openpyxl.load_workbook(xlsx_path)
|
wb = openpyxl.load_workbook(xlsx_path)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@ -60,13 +61,13 @@ def replace_item_info(content, df):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
def log(message):
|
def log(message):
|
||||||
with open(current_folder+"\log.txt", "a", encoding="utf-8") as log_file:
|
with open(os.path.join(current_folder, "log.txt"), "a", encoding="utf-8") as log_file:
|
||||||
log_file.write(message + "\n")
|
log_file.write(message + "\n")
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
work_file = current_folder +"\..\src\data\items.h"
|
work_file = os.path.join(os.path.dirname(current_folder), "src", "data", "items.h")
|
||||||
df = pd.read_excel(current_folder +r'\src\道具.xlsx')
|
df = pd.read_excel(os.path.join(current_folder, "src", "道具.xlsx"))
|
||||||
df.set_index('道具', inplace=True)
|
df.set_index('道具', inplace=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@ -56,14 +57,13 @@ def replace_species_info(content, df):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
def log(message):
|
def log(message):
|
||||||
with open(current_folder+"\log.txt", "a", encoding="utf-8") as log_file:
|
with open(os.path.join(current_folder, "log.txt"), "a", encoding="utf-8") as log_file:
|
||||||
log_file.write(message + "\n")
|
log_file.write(message + "\n")
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
work_folder = os.path.join(os.path.dirname(current_folder), "src", "data", "pokemon", "species_info")
|
||||||
work_folder = current_folder +"\..\src\data\pokemon\species_info"
|
df = pd.read_excel(os.path.join(current_folder, "src", "图鉴.xlsx"))
|
||||||
df = pd.read_excel(current_folder +r'\src\图鉴.xlsx')
|
|
||||||
df.set_index('name', inplace=True)
|
df.set_index('name', inplace=True)
|
||||||
|
|
||||||
for filename in os.listdir(work_folder):
|
for filename in os.listdir(work_folder):
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@ -60,14 +61,13 @@ def replace_move_info(content, df):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
def log(message):
|
def log(message):
|
||||||
with open(current_folder+"\log.txt", "a", encoding="utf-8") as log_file:
|
with open(os.path.join(current_folder, "log.txt"), "a", encoding="utf-8") as log_file:
|
||||||
log_file.write(message + "\n")
|
log_file.write(message + "\n")
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
work_file = os.path.join(os.path.dirname(current_folder), "src", "data", "moves_info.h")
|
||||||
work_file = current_folder +"\..\src\data\moves_info.h"
|
df = pd.read_excel(os.path.join(current_folder, "src", "招式.xlsx"))
|
||||||
df = pd.read_excel(current_folder +r'\src\招式.xlsx')
|
|
||||||
df.set_index('招式', inplace=True)
|
df.set_index('招式', inplace=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
|
#!/usr/bin/python python3
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@ -44,13 +44,12 @@ def replace_move_info(content, df):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
def log(message):
|
def log(message):
|
||||||
with open(current_folder+"\log.txt", "a", encoding="utf-8") as log_file:
|
with open(os.path.join(current_folder, "log.txt"), "a", encoding="utf-8") as log_file:
|
||||||
log_file.write(message + "\n")
|
log_file.write(message + "\n")
|
||||||
print(message)
|
print(message)
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
work_file = os.path.join(os.path.dirname(current_folder), "src", "strings.c")
|
||||||
work_file = current_folder +"\..\src\strings.c"
|
df = pd.read_excel(os.path.join(current_folder, "src", "文本.xlsx"))
|
||||||
df = pd.read_excel(current_folder + r'\src\文本.xlsx')
|
|
||||||
|
|
||||||
# 检查并清理重复的“变量名”
|
# 检查并清理重复的“变量名”
|
||||||
df = df.drop_duplicates(subset='变量名', keep='first')
|
df = df.drop_duplicates(subset='变量名', keep='first')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user