Skip to content

Commit

Permalink
新增 a700 ,以 Batch 方式執行 a730, a740, a750
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJui committed Sep 28, 2024
1 parent d646654 commit 67eef89
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 192 deletions.
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
"program": "a720_待注音漢字填入標音用方格.py",
"console": "integratedTerminal",
},
{
"name": "a700_Iong_Excel_Piau_Zu_Im",
"type": "debugpy",
"request": "launch",
"program": "a700_Iong_Excel_Piau_Zu_Im.py",
"console": "integratedTerminal",
},
{
"name": "a730_將漢字注音填入",
"type": "debugpy",
Expand Down
Binary file modified Tai_Gi_Zu_Im_Bun.xlsx
Binary file not shown.
108 changes: 17 additions & 91 deletions a700_Iong_Excel_Piau_Zu_Im.py
Original file line number Diff line number Diff line change
@@ -1,98 +1,24 @@
import getopt
import math
# =========================================================================
# 當 Tai_Gi_Zu_Im_Bun.xlsx 檔案已完成人工手動注音後,執行此程式可完成以下工作:
# (1) A730: 將人工填入之拼音及注音,抄寫到漢字的上方(拼音)及下方(注音)。
# (2) A740: 將【漢字注音】工作表的內容,轉成 HTML 網頁檔案。
# (3) A750: 將 Tai_Gi_Zu_Im_Bun.xlsx 檔案,依 env 工作表的設定,另存新檔到指定目錄。
# =========================================================================
import os
import subprocess
import sys

import xlwings as xw
# 指定虛擬環境的 Python 路徑
venv_python = os.path.join(".venv", "Scripts", "python.exe") if sys.platform == "win32" else os.path.join(".venv", "bin", "python")

import settings
from a730_將漢字注音填入 import thiam_zu_im
from p730_Tng_Sing_Bang_Iah import tng_sing_bang_iah
# 依次執行三個 Python 檔案

# (1) A730: 將人工填入之拼音及注音,抄寫到漢字的上方(拼音)及下方(注音)。
subprocess.run([venv_python, "a730_將漢字注音填入.py"])

def get_input_and_output_options(argv):
arg_input = ""
arg_output = ""
arg_user = ""
arg_help = "{0} -i <input> -u <user> -o <output>".format(argv[0])
# (2) A740: 將【漢字注音】工作表的內容,轉成 HTML 網頁檔案。
subprocess.run([venv_python, "a740_漢字注音轉網頁.py"])

try:
opts, args = getopt.getopt( # pyright: ignore
argv[1:], "hi:u:o:", ["help", "input=", "user=", "output="]
)
except Exception as e:
print(e)
print(arg_help)
sys.exit(2)

for opt, arg in opts:
if opt in ("-h", "--help"):
print(arg_help) # print the help message
sys.exit(2)
elif opt in ("-i", "--input"):
arg_input = arg
elif opt in ("-u", "--user"):
arg_user = arg
elif opt in ("-o", "--output"):
arg_output = arg

print("input:", arg_input)
print("user:", arg_user)
print("output:", arg_output)

return {
"input": arg_input,
"user": arg_user,
"output": arg_output,
}

if __name__ == "__main__":
# =========================================================================
# (1) 取得需要注音的「檔案名稱」及其「目錄路徑」。
# =========================================================================
# 取得 Input 檔案名稱
file_path = settings.get_tai_gi_zu_im_bun_path()
if not file_path:
print("未設定 .env 檔案")
# sys.exit(2)
opts = get_input_and_output_options(sys.argv)
if opts["input"] != "":
CONVERT_FILE_NAME = opts["input"]
else:
CONVERT_FILE_NAME = "Tai_Gi_Zu_Im_Bun.xlsx"
else:
CONVERT_FILE_NAME = file_path
print(f"CONVERT_FILE_NAME = {CONVERT_FILE_NAME}")

# 打開 Excel 檔案
wb = xw.Book(CONVERT_FILE_NAME)

# =========================================================================
# (2) 分析已輸入的【台語音標】及【台語注音符號】,將之各別填入漢字之上、下方。
# - 上方:台語音標
# - 下方:台語注音符號
# =========================================================================
thiam_zu_im(wb, '漢字注音', 'V3')

# =========================================================================
# (3) 將已注音之「漢字注音表」,製作成 HTML 格式之「注音/拼音/標音」網頁。
# =========================================================================
tng_sing_bang_iah(wb, '漢字注音', 'V3')

# =========================================================================
# (4) 依據《文章標題》另存新檔。
# =========================================================================
wb = xw.Book(CONVERT_FILE_NAME)
setting_sheet = wb.sheets["env"]
new_file_name = str(
setting_sheet.range("C4").value
).strip()
new_file_path = os.path.join(
".\\output",
f"【河洛話注音】{new_file_name}" + ".xlsx")

# 儲存新建立的工作簿
wb.save(new_file_path)

# 保存 Excel 檔案
wb.close()
# (3) A750: 將 Tai_Gi_Zu_Im_Bun.xlsx 檔案,依 env 工作表的設定,另存新檔到指定目錄。
# subprocess.run([venv_python, "a750_漢字注音存檔.py"])
subprocess.run([venv_python, "a750_漢字注音存檔.py", "-i", "Tai_Gi_Zu_Im_Bun.xlsx"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@

<!DOCTYPE html>
<html lang="zh-TW">
<head>
<title>《金剛般若波羅蜜經。無為福勝分第十一》【漢字注音】</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="assets/styles/styles.css">
</head>
<body>
《金剛般若波羅蜜經。無為福勝分第十一》【漢字注音】
<div class='separator' style='clear: both'>
<a href='圖片' style='display: block; padding: 1em 0; text-align: center'>
<img alt='金剛般若波羅蜜經。無為福勝分第十一' border='0' width='400' data-original-height='630' data-original-width='1200'
src='https://shoplineimg.com/5db585d59db3cb0012a18bce/5f2a9d3f30cc6200455c1c25/1296x.webp?source_format=jpg' />
</a>
</div>

<div class='Siang_Pai'><p>
<ruby><rb></rb><rt>bo⁵</rt><rtc>ㆠㄜˊ</rtc></ruby>
<ruby><rb></rb><rt>ui⁵</rt><rtc>ㄨㄧˊ</rtc></ruby>
<ruby><rb></rb><rt>hok⁴</rt><rtc>ㄏㆦ</rtc></ruby>
<ruby><rb></rb><rt>sin³</rt><rtc>ㄒㄧㄣ˪</rtc></ruby>
<ruby><rb></rb><rt>hun¹</rt><rtc>ㄏㄨㄣˉ</rtc></ruby>
<ruby><rb></rb><rt>te⁷</rt><rtc>ㄉㆤ˫</rtc></ruby>
<ruby><rb></rb><rt>zap⁸</rt><rtc>ㄗㄚㆴ˙</rtc></ruby>
<ruby><rb></rb><rt>zit⁸</rt><rtc>ㄐㄧㆵ˙</rtc></ruby>
</p><p>
<span></span>
<ruby><rb></rb><rt>su¹</rt><rtc>ㄙㄨˉ</rtc></ruby>
<ruby><rb></rb><rt>phoo⁵</rt><rtc>ㄆㆦˊ</rtc></ruby>
<ruby><rb></rb><rt>theh⁸</rt><rtc>ㄊㆤㆷ˙</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>ju⁵</rt><rtc>ㆡㄨˊ</rtc></ruby>
<ruby><rb></rb><rt>hing⁵</rt><rtc>ㄏㄧㄥˊ</rtc></ruby>
<ruby><rb></rb><rt>ho⁵</rt><rtc>ㄏㄜˊ</rtc></ruby>
<ruby><rb></rb><rt>tiong¹</rt><rtc>ㄉㄧㆲˉ</rtc></ruby>
<ruby><rb></rb><rt>soo²</rt><rtc>ㄙㆦˋ</rtc></ruby>
<ruby><rb></rb><rt>u⁷</rt><rtc>ㄨ˫</rtc></ruby>
<ruby><rb></rb><rt>sua¹</rt><rtc>ㄙㄨㄚˉ</rtc></ruby>
<ruby><rb></rb><rt>soo³</rt><rtc>ㄙㆦ˪</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>ju⁵</rt><rtc>ㆡㄨˊ</rtc></ruby>
<ruby><rb></rb><rt>si⁷</rt><rtc>ㄒㄧ˫</rtc></ruby>
<ruby><rb></rb><rt>sua¹</rt><rtc>ㄙㄨㄚˉ</rtc></ruby>
<ruby><rb></rb><rt>tan²</rt><rtc>ㄉㄢˋ</rtc></ruby>
<ruby><rb></rb><rt>hing⁵</rt><rtc>ㄏㄧㄥˊ</rtc></ruby>
<ruby><rb></rb><rt>ho⁵</rt><rtc>ㄏㄜˊ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>u⁵</rt><rtc>ㄨˊ</rtc></ruby>
<ruby><rb></rb><rt></rt><rtc>ㄧ˪</rtc></ruby>
<ruby><rb></rb><rt>un⁵</rt><rtc>ㄨㄣˊ</rtc></ruby>
<ruby><rb></rb><rt>ho⁵</rt><rtc>ㄏㄜˊ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>si⁷</rt><rtc>ㄒㄧ˫</rtc></ruby>
<ruby><rb></rb><rt>zu¹</rt><rtc>ㄗㄨˉ</rtc></ruby>
<ruby><rb></rb><rt>hing⁵</rt><rtc>ㄏㄧㄥˊ</rtc></ruby>
<ruby><rb></rb><rt>ho⁵</rt><rtc>ㄏㄜˊ</rtc></ruby>
<ruby><rb></rb><rt>sua¹</rt><rtc>ㄙㄨㄚˉ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>ling⁵</rt><rtc>ㄌㄧㄥˊ</rtc></ruby>
<ruby><rb></rb><rt>ui⁵</rt><rtc>ㄨㄧˊ</rtc></ruby>
<ruby><rb></rb><rt>to¹</rt><rtc>ㄉㄜˉ</rtc></ruby>
<ruby><rb></rb><rt>put⁴</rt><rtc>ㄅㄨㆵ</rtc></ruby>
<span></span>
<span></span>
<ruby><rb></rb><rt>su¹</rt><rtc>ㄙㄨˉ</rtc></ruby>
<ruby><rb></rb><rt>phoo⁵</rt><rtc>ㄆㆦˊ</rtc></ruby>
<ruby><rb></rb><rt>theh⁸</rt><rtc>ㄊㆤㆷ˙</rtc></ruby>
<ruby><rb></rb><rt>gian⁵</rt><rtc>ㆣㄧㄢˊ</rtc></ruby>
<span></span>
<span></span>
<ruby><rb></rb><rt>sⁿia²</rt><rtc>ㄒㄧㆩˋ</rtc></ruby>
<ruby><rb></rb><rt>to¹</rt><rtc>ㄉㄜˉ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>se³</rt><rtc>ㄙㆤ˪</rtc></ruby>
<ruby><rb></rb><rt>zun¹</rt><rtc>ㄗㄨㄣˉ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>tan⁷</rt><rtc>ㄉㄢ˫</rtc></ruby>
<ruby><rb></rb><rt>zu¹</rt><rtc>ㄗㄨˉ</rtc></ruby>
<ruby><rb></rb><rt>hing⁵</rt><rtc>ㄏㄧㄥˊ</rtc></ruby>
<ruby><rb></rb><rt>ho⁵</rt><rtc>ㄏㄜˊ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>siong⁷</rt><rtc>ㄒㄧㆲ˫</rtc></ruby>
<ruby><rb></rb><rt>to¹</rt><rtc>ㄉㄜˉ</rtc></ruby>
<ruby><rb></rb><rt>bo⁵</rt><rtc>ㆠㄜˊ</rtc></ruby>
<ruby><rb></rb><rt>soo³</rt><rtc>ㄙㆦ˪</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>ho⁵</rt><rtc>ㄏㄜˊ</rtc></ruby>
<ruby><rb></rb><rt>hong²</rt><rtc>ㄏㆲˋ</rtc></ruby>
<ruby><rb></rb><rt>ki⁵</rt><rtc>ㄍㄧˊ</rtc></ruby>
<ruby><rb></rb><rt>sua¹</rt><rtc>ㄙㄨㄚˉ</rtc></ruby>
<span></span>
<span></span>
</p><p>
<span></span>
<ruby><rb></rb><rt>su¹</rt><rtc>ㄙㄨˉ</rtc></ruby>
<ruby><rb></rb><rt>phoo⁵</rt><rtc>ㄆㆦˊ</rtc></ruby>
<ruby><rb></rb><rt>theh⁸</rt><rtc>ㄊㆤㆷ˙</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>gua²</rt><rtc>ㆣㄨㄚˋ</rtc></ruby>
<ruby><rb></rb><rt>kim¹</rt><rtc>ㄍㄧㆬˉ</rtc></ruby>
<ruby><rb></rb><rt>sit⁸</rt><rtc>ㄒㄧㆵ˙</rtc></ruby>
<ruby><rb></rb><rt>gian⁵</rt><rtc>ㆣㄧㄢˊ</rtc></ruby>
<ruby><rb></rb><rt>ko³</rt><rtc>ㄍㄜ˪</rtc></ruby>
<ruby><rb></rb><rt>li²</rt><rtc>ㄌㄧˋ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>na²</rt><rtc>ㄋㄚˋ</rtc></ruby>
<ruby><rb></rb><rt>u⁷</rt><rtc>ㄨ˫</rtc></ruby>
<ruby><rb></rb><rt>sian⁷</rt><rtc>ㄒㄧㄢ˫</rtc></ruby>
<ruby><rb></rb><rt>lam⁵</rt><rtc>ㄌㆰˊ</rtc></ruby>
<ruby><rb></rb><rt>zu²</rt><rtc>ㄗㄨˋ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>sian⁷</rt><rtc>ㄒㄧㄢ˫</rtc></ruby>
<ruby><rb></rb><rt>lu²</rt><rtc>ㄌㄨˋ</rtc></ruby>
<ruby><rb></rb><rt>lang⁵</rt><rtc>ㄌㄤˊ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt></rt><rtc>ㄧˋ</rtc></ruby>
<ruby><rb></rb><rt>cit⁴</rt><rtc>ㄑㄧㆵ</rtc></ruby>
<ruby><rb></rb><rt>po²</rt><rtc>ㄅㄜˋ</rtc></ruby>
<ruby><rb>滿</rb><rt>mua²</rt><rtc>ㄇㄨㄚˋ</rtc></ruby>
<ruby><rb></rb><rt>ni²</rt><rtc>ㄋㄧˋ</rtc></ruby>
<ruby><rb></rb><rt>soo²</rt><rtc>ㄙㆦˋ</rtc></ruby>
<ruby><rb></rb><rt>hing⁵</rt><rtc>ㄏㄧㄥˊ</rtc></ruby>
<ruby><rb></rb><rt>ho⁵</rt><rtc>ㄏㄜˊ</rtc></ruby>
<ruby><rb></rb><rt>sua¹</rt><rtc>ㄙㄨㄚˉ</rtc></ruby>
<ruby><rb></rb><rt>soo³</rt><rtc>ㄙㆦ˪</rtc></ruby>
<ruby><rb></rb><rt>sⁿa¹</rt><rtc>ㄙㆩˉ</rtc></ruby>
<ruby><rb></rb><rt>cing¹</rt><rtc>ㄑㄧㄥˉ</rtc></ruby>
<ruby><rb></rb><rt>tua⁷</rt><rtc>ㄉㄨㄚ˫</rtc></ruby>
<ruby><rb></rb><rt>cing¹</rt><rtc>ㄑㄧㄥˉ</rtc></ruby>
<ruby><rb></rb><rt>se³</rt><rtc>ㄙㆤ˪</rtc></ruby>
<ruby><rb></rb><rt>kai³</rt><rtc>ㄍㄞ˪</rtc></ruby>
<span></span>
<ruby><rb></rb><rt></rt><rtc>ㄧˋ</rtc></ruby>
<ruby><rb></rb><rt>ing⁷</rt><rtc>ㄧㄥ˫</rtc></ruby>
<ruby><rb></rb><rt>poo³</rt><rtc>ㄅㆦ˪</rtc></ruby>
<ruby><rb></rb><rt>si¹</rt><rtc>ㄒㄧˉ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>tit⁴</rt><rtc>ㄉㄧㆵ</rtc></ruby>
<ruby><rb></rb><rt>hok⁴</rt><rtc>ㄏㆦ</rtc></ruby>
<ruby><rb></rb><rt>to¹</rt><rtc>ㄉㄜˉ</rtc></ruby>
<ruby><rb></rb><rt>m⁷</rt><rtc>ㄇ˫</rtc></ruby>
<span></span>
<span></span>
<ruby><rb></rb><rt>su¹</rt><rtc>ㄙㄨˉ</rtc></ruby>
<ruby><rb></rb><rt>phoo⁵</rt><rtc>ㄆㆦˊ</rtc></ruby>
<ruby><rb></rb><rt>theh⁸</rt><rtc>ㄊㆤㆷ˙</rtc></ruby>
<ruby><rb></rb><rt>gian⁵</rt><rtc>ㆣㄧㄢˊ</rtc></ruby>
<span></span>
<span></span>
<ruby><rb></rb><rt>sⁿia²</rt><rtc>ㄒㄧㆩˋ</rtc></ruby>
<ruby><rb></rb><rt>to¹</rt><rtc>ㄉㄜˉ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>se³</rt><rtc>ㄙㆤ˪</rtc></ruby>
<ruby><rb></rb><rt>zun¹</rt><rtc>ㄗㄨㄣˉ</rtc></ruby>
<span></span>
<span></span>
<ruby><rb></rb><rt>hut⁸</rt><rtc>ㄏㄨㆵ˙</rtc></ruby>
<ruby><rb></rb><rt>ko³</rt><rtc>ㄍㄜ˪</rtc></ruby>
<ruby><rb></rb><rt>su¹</rt><rtc>ㄙㄨˉ</rtc></ruby>
<ruby><rb></rb><rt>phoo⁵</rt><rtc>ㄆㆦˊ</rtc></ruby>
<ruby><rb></rb><rt>theh⁸</rt><rtc>ㄊㆤㆷ˙</rtc></ruby>
<span></span>
<span></span>
<ruby><rb></rb><rt>na²</rt><rtc>ㄋㄚˋ</rtc></ruby>
<ruby><rb></rb><rt>sian⁷</rt><rtc>ㄒㄧㄢ˫</rtc></ruby>
<ruby><rb></rb><rt>lam⁵</rt><rtc>ㄌㆰˊ</rtc></ruby>
<ruby><rb></rb><rt>zu²</rt><rtc>ㄗㄨˋ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>sian⁷</rt><rtc>ㄒㄧㄢ˫</rtc></ruby>
<ruby><rb></rb><rt>lu²</rt><rtc>ㄌㄨˋ</rtc></ruby>
<ruby><rb></rb><rt>lang⁵</rt><rtc>ㄌㄤˊ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>u⁵</rt><rtc>ㄨˊ</rtc></ruby>
<ruby><rb></rb><rt>cu³</rt><rtc>ㄘㄨ˪</rtc></ruby>
<ruby><rb></rb><rt>king¹</rt><rtc>ㄍㄧㄥˉ</rtc></ruby>
<ruby><rb></rb><rt>tiong¹</rt><rtc>ㄉㄧㆲˉ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>nai²</rt><rtc>ㄋㄞˋ</rtc></ruby>
<ruby><rb></rb><rt>zi³</rt><rtc>ㄐㄧ˪</rtc></ruby>
<ruby><rb></rb><rt>siu⁷</rt><rtc>ㄒㄧㄨ˫</rtc></ruby>
<ruby><rb></rb><rt>ci⁵</rt><rtc>ㄑㄧˊ</rtc></ruby>
<ruby><rb></rb><rt>si³</rt><rtc>ㄒㄧ˪</rtc></ruby>
<ruby><rb></rb><rt>ku³</rt><rtc>ㄍㄨ˪</rtc></ruby>
<ruby><rb></rb><rt>kiat⁴</rt><rtc>ㄍㄧㄚㆵ</rtc></ruby>
<ruby><rb></rb><rt>tan²</rt><rtc>ㄉㄢˋ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>ui⁵</rt><rtc>ㄨㄧˊ</rtc></ruby>
<ruby><rb></rb><rt>tha¹</rt><rtc>ㄊㄚˉ</rtc></ruby>
<ruby><rb></rb><rt>lang⁵</rt><rtc>ㄌㄤˊ</rtc></ruby>
<ruby><rb></rb><rt>suat⁴</rt><rtc>ㄙㄨㄚㆵ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>li⁵</rt><rtc>ㄌㄧˊ</rtc></ruby>
<ruby><rb></rb><rt>cu³</rt><rtc>ㄘㄨ˪</rtc></ruby>
<ruby><rb></rb><rt>hok⁴</rt><rtc>ㄏㆦ</rtc></ruby>
<ruby><rb></rb><rt>tiek⁴</rt><rtc>ㄉㄧㆤ</rtc></ruby>
<span></span>
<ruby><rb></rb><rt>sing¹</rt><rtc>ㄒㄧㄥˉ</rtc></ruby>
<ruby><rb></rb><rt>zing⁵</rt><rtc>ㄐㄧㄥˊ</rtc></ruby>
<ruby><rb></rb><rt>hok⁴</rt><rtc>ㄏㆦ</rtc></ruby>
<ruby><rb></rb><rt>tiek⁴</rt><rtc>ㄉㄧㆤ</rtc></ruby>
<span></span>
<span></span>
</p></div>
</body>
</html>

Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 67eef89

Please sign in to comment.