Skip to content

Commit

Permalink
Update v0.16 ❄
Browse files Browse the repository at this point in the history
  • Loading branch information
NightFurySL2001 committed Dec 25, 2021
1 parent 6acfc3e commit 24a2424
Show file tree
Hide file tree
Showing 9 changed files with 4,965 additions and 87 deletions.
34 changes: 22 additions & 12 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
@ECHO OFF
ECHO Start building...
ECHO Building English version......
pyinstaller main.spec
ECHO Building Chinese (Simp) version......
pyinstaller main-zhs.spec
CD dist
xcopy /s .\main-zhs\main-zhs.exe .\main
xcopy /s .\main-zhs\main-zhs.exe.manifest .\main
RMDIR /S /Q .\main-zhs
REN "main" "CJK-character-count-v0.10"
ECHO Build done!
@ECHO OFF
ECHO Start building...
ECHO Building English version......
pyinstaller main.spec
ECHO Building Chinese (Simp) version......
pyinstaller main-zhs.spec
ECHO Building Chinese (Trad) version......
pyinstaller main-zht.spec
CD dist
ECHO Combining files......
:: copy everything into zht folder as zht need extra GUI font
xcopy /s .\main\main.exe .\main-zht
xcopy /s .\main\main.exe.manifest .\main-zht
xcopy /s .\main-zhs\main-zhs.exe .\main-zht
xcopy /s .\main-zhs\main-zhs.exe.manifest .\main-zht
ECHO Deleting redundant file......
RMDIR /S /Q .\main
RMDIR /S /Q .\main-zhs
REN "main-zht" "CJK-character-count-vX.XX"
ECHO Build done!
ECHO Press Enter to exit.
PAUSE >nul
EXIT
4 changes: 3 additions & 1 deletion count_char.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from tkinter import ttk
from itertools import tee
import global_var
import os

#special cjk compatibility for gbk, defined at end
global gbk_compatibility_deci_list
Expand Down Expand Up @@ -124,7 +125,8 @@ def count_char(char_list, master, lang="en"):
#load encoding file
def load_sample_file(filename):
font_list = []
for line in open(filename, "r", encoding="utf-8"):
full_path = os.path.join(global_var.main_directory, filename)
for line in open(full_path, "r", encoding="utf-8"):
font_list.append(line.strip("\r\n").strip(" "))
return font_list

Expand Down
25 changes: 25 additions & 0 deletions global_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@
global cjk_count
global unicode_count

import os, sys
global main_directory

#if packaged by pyinstaller
#ref: https://stackoverflow.com/questions/404744/determining-application-path-in-a-python-exe-generated-by-pyinstaller
if getattr(sys, 'frozen', False):
#change from loading same folder to full folder, --onedir
main_directory = os.path.dirname(sys.executable)
#`pyinstaller --onefile` change to use the following code
#if '_MEIPASS2' in os.environ:
# main_directory = os.environ['_MEIPASS2']
#ref: https://stackoverflow.com/questions/9553262/pyinstaller-ioerror-errno-2-no-such-file-or-directory
else:
#dev mode
try: #py xx.py
app_full_path = os.path.realpath(__file__)
main_directory = os.path.dirname(app_full_path)
except NameError: #py then run code
main_directory = os.getcwd()


#english name
#old list for compatibility
Expand All @@ -25,6 +45,7 @@
"6343cichangyong":"Chart of Standard Forms of Less-Than-Common National Characters", #次常用国字标准字体表
"big5changyong":"BIG5 Common Character Set",
"big5":"BIG5",
"hkchangyong":"List of Graphemes of Commonly-Used Chinese Characters", #常用字字形表
"hkscs":"Hong Kong Supplementary Character Set",
"suppchara":"Common Supplementary Characters in Hong Kong (Level 1-6)"
}
Expand All @@ -43,6 +64,7 @@
"6343cichangyong":"Chart of Standard Forms of Less-Than-Common National Characters",
"big5changyong":"BIG5 Common Character Set",
"big5":"BIG5",
"hkchangyong":"List of Graphemes of Commonly-Used Chinese Characters",
"hkscs":"Hong Kong Supplementary Character Set",
"suppchara":"Common Supplementary Characters in Hong Kong (Level 1-6)",
"gb12345":"GB/T 12345"
Expand Down Expand Up @@ -80,6 +102,7 @@
"6343cichangyong":"次常用国字标准字体表",
"big5changyong":"五大码 (Big5) 常用汉字表",
"big5":"五大码 (Big5)",
"hkchangyong":"常用字字形表",
"hkscs":"香港增补字符集 (HKSCS)",
"suppchara":"常用香港外字表 (1-6级)",
"gb12345":"GB/T 12345"
Expand All @@ -106,6 +129,7 @@
"6343cichangyong":"次常用國字標準字體表",
"big5changyong":"五大碼 (Big5) 常用漢字表",
"big5":"五大碼 (Big5)",
"hkchangyong":"常用字字形表",
"hkscs":"香港增補字符集 (HKSCS)",
"suppchara":"常用香港外字表 (1-6級)",
"gb12345":"GB/T 12345"
Expand Down Expand Up @@ -154,6 +178,7 @@
"6343cichangyong":6343,
"big5changyong":5401,
"big5":13060,
"hkchangyong":4825,
"hkscs":4603,
"suppchara":1097
}
Expand Down
Loading

0 comments on commit 24a2424

Please sign in to comment.