je-editor 0.0.104__py3-none-any.whl → 0.0.228__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. je_editor/__init__.py +26 -21
  2. je_editor/__main__.py +1 -1
  3. je_editor/code_scan/ruff_thread.py +58 -0
  4. je_editor/code_scan/watchdog_implement.py +56 -0
  5. je_editor/code_scan/watchdog_thread.py +78 -0
  6. je_editor/git_client/commit_graph.py +77 -0
  7. je_editor/git_client/git_action.py +175 -0
  8. je_editor/git_client/git_cli.py +66 -0
  9. je_editor/pyside_ui/browser/browser_download_window.py +75 -0
  10. je_editor/pyside_ui/browser/browser_serach_lineedit.py +51 -0
  11. je_editor/pyside_ui/browser/browser_view.py +87 -0
  12. je_editor/pyside_ui/browser/browser_widget.py +103 -0
  13. je_editor/pyside_ui/browser/main_browser_widget.py +85 -0
  14. je_editor/pyside_ui/code/auto_save/auto_save_manager.py +60 -0
  15. je_editor/pyside_ui/code/auto_save/auto_save_thread.py +59 -0
  16. je_editor/pyside_ui/code/code_format/pep8_format.py +130 -0
  17. je_editor/pyside_ui/code/code_process/code_exec.py +267 -0
  18. je_editor/pyside_ui/code/plaintext_code_edit/code_edit_plaintext.py +412 -0
  19. je_editor/pyside_ui/code/running_process_manager.py +48 -0
  20. je_editor/pyside_ui/code/shell_process/shell_exec.py +236 -0
  21. je_editor/pyside_ui/code/syntax/python_syntax.py +99 -0
  22. je_editor/pyside_ui/code/syntax/syntax_setting.py +95 -0
  23. je_editor/pyside_ui/code/textedit_code_result/code_record.py +75 -0
  24. je_editor/pyside_ui/code/variable_inspector/inspector_gui.py +172 -0
  25. je_editor/pyside_ui/dialog/ai_dialog/set_ai_dialog.py +71 -0
  26. je_editor/pyside_ui/dialog/file_dialog/create_file_dialog.py +68 -0
  27. je_editor/pyside_ui/dialog/file_dialog/open_file_dialog.py +111 -0
  28. je_editor/pyside_ui/dialog/file_dialog/save_file_dialog.py +67 -0
  29. je_editor/pyside_ui/dialog/search_ui/search_error_box.py +49 -0
  30. je_editor/pyside_ui/dialog/search_ui/search_text_box.py +49 -0
  31. je_editor/pyside_ui/git_ui/code_diff_compare/code_diff_viewer_widget.py +90 -0
  32. je_editor/pyside_ui/git_ui/code_diff_compare/line_number_code_viewer.py +141 -0
  33. je_editor/pyside_ui/git_ui/code_diff_compare/multi_file_diff_viewer.py +88 -0
  34. je_editor/pyside_ui/git_ui/code_diff_compare/side_by_side_diff_widget.py +284 -0
  35. je_editor/pyside_ui/git_ui/git_client/commit_table.py +65 -0
  36. je_editor/pyside_ui/git_ui/git_client/git_branch_tree_widget.py +156 -0
  37. je_editor/pyside_ui/git_ui/git_client/git_client_gui.py +799 -0
  38. je_editor/pyside_ui/git_ui/git_client/graph_view.py +218 -0
  39. je_editor/pyside_ui/main_ui/ai_widget/ai_config.py +34 -0
  40. je_editor/pyside_ui/main_ui/ai_widget/ask_thread.py +36 -0
  41. je_editor/pyside_ui/main_ui/ai_widget/chat_ui.py +147 -0
  42. je_editor/pyside_ui/main_ui/ai_widget/langchain_interface.py +84 -0
  43. je_editor/pyside_ui/main_ui/console_widget/console_gui.py +162 -0
  44. je_editor/pyside_ui/main_ui/console_widget/qprocess_adapter.py +84 -0
  45. je_editor/pyside_ui/main_ui/dock/__init__.py +0 -0
  46. je_editor/pyside_ui/main_ui/dock/destroy_dock.py +50 -0
  47. je_editor/pyside_ui/main_ui/editor/__init__.py +0 -0
  48. je_editor/pyside_ui/main_ui/editor/editor_widget.py +301 -0
  49. je_editor/pyside_ui/main_ui/editor/editor_widget_dock.py +70 -0
  50. je_editor/pyside_ui/main_ui/editor/process_input.py +101 -0
  51. je_editor/pyside_ui/main_ui/ipython_widget/__init__.py +0 -0
  52. je_editor/pyside_ui/main_ui/ipython_widget/rich_jupyter.py +78 -0
  53. je_editor/pyside_ui/main_ui/main_editor.py +369 -0
  54. je_editor/pyside_ui/main_ui/menu/__init__.py +0 -0
  55. je_editor/pyside_ui/main_ui/menu/check_style_menu/__init__.py +0 -0
  56. je_editor/pyside_ui/main_ui/menu/check_style_menu/build_check_style_menu.py +104 -0
  57. je_editor/pyside_ui/main_ui/menu/dock_menu/__init__.py +0 -0
  58. je_editor/pyside_ui/main_ui/menu/dock_menu/build_dock_menu.py +208 -0
  59. je_editor/pyside_ui/main_ui/menu/file_menu/__init__.py +0 -0
  60. je_editor/pyside_ui/main_ui/menu/file_menu/build_file_menu.py +186 -0
  61. je_editor/pyside_ui/main_ui/menu/help_menu/__init__.py +0 -0
  62. je_editor/pyside_ui/main_ui/menu/help_menu/build_help_menu.py +100 -0
  63. je_editor/pyside_ui/main_ui/menu/language_menu/__init__.py +0 -0
  64. je_editor/pyside_ui/main_ui/menu/language_menu/build_language_server.py +89 -0
  65. je_editor/pyside_ui/main_ui/menu/python_env_menu/__init__.py +0 -0
  66. je_editor/pyside_ui/main_ui/menu/python_env_menu/build_venv_menu.py +238 -0
  67. je_editor/pyside_ui/main_ui/menu/run_menu/__init__.py +0 -0
  68. je_editor/pyside_ui/main_ui/menu/run_menu/build_run_menu.py +160 -0
  69. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/__init__.py +0 -0
  70. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_debug_menu.py +109 -0
  71. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_program_menu.py +101 -0
  72. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_shell_menu.py +98 -0
  73. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/utils.py +41 -0
  74. je_editor/pyside_ui/main_ui/menu/set_menu_bar.py +63 -0
  75. je_editor/pyside_ui/main_ui/menu/style_menu/__init__.py +0 -0
  76. je_editor/pyside_ui/main_ui/menu/style_menu/build_style_menu.py +73 -0
  77. je_editor/pyside_ui/main_ui/menu/tab_menu/__init__.py +0 -0
  78. je_editor/pyside_ui/main_ui/menu/tab_menu/build_tab_menu.py +275 -0
  79. je_editor/pyside_ui/main_ui/menu/text_menu/__init__.py +0 -0
  80. je_editor/pyside_ui/main_ui/menu/text_menu/build_text_menu.py +135 -0
  81. je_editor/pyside_ui/main_ui/save_settings/__init__.py +0 -0
  82. je_editor/pyside_ui/main_ui/save_settings/setting_utils.py +33 -0
  83. je_editor/pyside_ui/main_ui/save_settings/user_color_setting_file.py +103 -0
  84. je_editor/pyside_ui/main_ui/save_settings/user_setting_file.py +58 -0
  85. je_editor/pyside_ui/main_ui/system_tray/__init__.py +0 -0
  86. je_editor/pyside_ui/main_ui/system_tray/extend_system_tray.py +90 -0
  87. je_editor/start_editor.py +32 -8
  88. je_editor/utils/encodings/python_encodings.py +100 -97
  89. je_editor/utils/exception/exception_tags.py +11 -11
  90. je_editor/utils/file/open/open_file.py +38 -22
  91. je_editor/utils/file/save/save_file.py +40 -16
  92. je_editor/utils/json/json_file.py +36 -15
  93. je_editor/utils/json_format/json_process.py +38 -2
  94. je_editor/utils/logging/__init__.py +0 -0
  95. je_editor/utils/logging/loggin_instance.py +57 -0
  96. je_editor/utils/multi_language/__init__.py +0 -0
  97. je_editor/utils/multi_language/english.py +221 -0
  98. je_editor/utils/multi_language/multi_language_wrapper.py +54 -0
  99. je_editor/utils/multi_language/traditional_chinese.py +214 -0
  100. je_editor/utils/redirect_manager/redirect_manager_class.py +67 -25
  101. je_editor/utils/venv_check/__init__.py +0 -0
  102. je_editor/utils/venv_check/check_venv.py +51 -0
  103. je_editor-0.0.228.dist-info/METADATA +99 -0
  104. je_editor-0.0.228.dist-info/RECORD +140 -0
  105. {je_editor-0.0.104.dist-info → je_editor-0.0.228.dist-info}/WHEEL +1 -1
  106. {je_editor-0.0.104.dist-info → je_editor-0.0.228.dist-info/licenses}/LICENSE +1 -1
  107. je_editor/pyside_ui/auto_save/auto_save_thread.py +0 -34
  108. je_editor/pyside_ui/code_editor/code_edit_plaintext.py +0 -143
  109. je_editor/pyside_ui/code_process/code_exec.py +0 -190
  110. je_editor/pyside_ui/code_result/code_record.py +0 -39
  111. je_editor/pyside_ui/colors/global_color.py +0 -4
  112. je_editor/pyside_ui/file_dialog/open_file_dialog.py +0 -27
  113. je_editor/pyside_ui/file_dialog/save_file_dialog.py +0 -24
  114. je_editor/pyside_ui/main_ui/editor_main_ui/main_editor.py +0 -183
  115. je_editor/pyside_ui/main_ui_setting/ui_setting.py +0 -36
  116. je_editor/pyside_ui/menu/menu_bar/check_style_menu/build_check_style_menu.py +0 -44
  117. je_editor/pyside_ui/menu/menu_bar/file_menu/build_file_menu.py +0 -30
  118. je_editor/pyside_ui/menu/menu_bar/help_menu/build_help_menu.py +0 -39
  119. je_editor/pyside_ui/menu/menu_bar/run_menu/build_run_menu.py +0 -102
  120. je_editor/pyside_ui/menu/menu_bar/set_menu_bar.py +0 -24
  121. je_editor/pyside_ui/menu/menu_bar/venv_menu/build_venv_menu.py +0 -74
  122. je_editor/pyside_ui/search_ui/search_error_box.py +0 -20
  123. je_editor/pyside_ui/search_ui/search_text_box.py +0 -20
  124. je_editor/pyside_ui/shell_process/shell_exec.py +0 -157
  125. je_editor/pyside_ui/syntax/python_syntax.py +0 -99
  126. je_editor/pyside_ui/treeview/project_treeview/set_project_treeview.py +0 -47
  127. je_editor/pyside_ui/user_setting/user_setting_file.py +0 -23
  128. je_editor-0.0.104.dist-info/METADATA +0 -84
  129. je_editor-0.0.104.dist-info/RECORD +0 -69
  130. /je_editor/{pyside_ui/auto_save → code_scan}/__init__.py +0 -0
  131. /je_editor/{pyside_ui/code_editor → git_client}/__init__.py +0 -0
  132. /je_editor/pyside_ui/{code_process → browser}/__init__.py +0 -0
  133. /je_editor/pyside_ui/{code_result → code}/__init__.py +0 -0
  134. /je_editor/pyside_ui/{colors → code/auto_save}/__init__.py +0 -0
  135. /je_editor/pyside_ui/{file_dialog → code/code_format}/__init__.py +0 -0
  136. /je_editor/pyside_ui/{main_ui/editor_main_ui → code/code_process}/__init__.py +0 -0
  137. /je_editor/pyside_ui/{main_ui_setting → code/plaintext_code_edit}/__init__.py +0 -0
  138. /je_editor/pyside_ui/{menu → code/shell_process}/__init__.py +0 -0
  139. /je_editor/pyside_ui/{menu/menu_bar → code/syntax}/__init__.py +0 -0
  140. /je_editor/pyside_ui/{menu/menu_bar/check_style_menu → code/textedit_code_result}/__init__.py +0 -0
  141. /je_editor/pyside_ui/{menu/menu_bar/file_menu → code/variable_inspector}/__init__.py +0 -0
  142. /je_editor/pyside_ui/{menu/menu_bar/help_menu → dialog}/__init__.py +0 -0
  143. /je_editor/pyside_ui/{menu/menu_bar/run_menu → dialog/ai_dialog}/__init__.py +0 -0
  144. /je_editor/pyside_ui/{menu/menu_bar/venv_menu → dialog/file_dialog}/__init__.py +0 -0
  145. /je_editor/pyside_ui/{search_ui → dialog/search_ui}/__init__.py +0 -0
  146. /je_editor/pyside_ui/{shell_process → git_ui}/__init__.py +0 -0
  147. /je_editor/pyside_ui/{syntax → git_ui/code_diff_compare}/__init__.py +0 -0
  148. /je_editor/pyside_ui/{treeview → git_ui/git_client}/__init__.py +0 -0
  149. /je_editor/pyside_ui/{treeview/project_treeview → main_ui/ai_widget}/__init__.py +0 -0
  150. /je_editor/pyside_ui/{user_setting → main_ui/console_widget}/__init__.py +0 -0
  151. {je_editor-0.0.104.dist-info → je_editor-0.0.228.dist-info}/top_level.txt +0 -0
@@ -1,99 +1,102 @@
1
+ # 定義一個 Python 支援的文字編碼清單
2
+ # Define a list of text encodings supported by Python
3
+
1
4
  python_encodings_list = [
2
- 'ascii',
3
- 'big5',
4
- 'big5hkscs',
5
- 'cp037',
6
- 'cp273',
7
- 'cp424',
8
- 'cp437',
9
- 'cp500',
10
- 'cp720',
11
- 'cp737',
12
- 'cp775',
13
- 'cp850',
14
- 'cp852',
15
- 'cp855',
16
- 'cp856',
17
- 'cp857',
18
- 'cp858',
19
- 'cp860',
20
- 'cp861',
21
- 'cp862',
22
- 'cp863',
23
- 'cp864',
24
- 'cp865',
25
- 'cp866',
26
- 'cp869',
27
- 'cp874',
28
- 'cp875',
29
- 'cp932',
30
- 'cp949',
31
- 'cp950',
32
- 'cp1006',
33
- 'cp1026',
34
- 'cp1125',
35
- 'cp1140',
36
- 'cp1250',
37
- 'cp1251',
38
- 'cp1252',
39
- 'cp1253',
40
- 'cp1254',
41
- 'cp1255',
42
- 'cp1256',
43
- 'cp1257',
44
- 'cp1258',
45
- 'euc_jp',
46
- 'euc_jis_2004',
47
- 'euc_jisx0213',
48
- 'euc_kr',
49
- 'gb2312',
50
- 'gbk',
51
- 'gb18030',
52
- 'hz',
53
- 'iso2022_jp',
54
- 'iso2022_jp_1',
55
- 'iso2022_jp_2',
56
- 'iso2022_jp_2004',
57
- 'iso2022_jp_3',
58
- 'iso2022_jp_ext',
59
- 'iso2022_kr',
60
- 'latin_1',
61
- 'iso8859_2',
62
- 'iso8859_3',
63
- 'iso8859_4',
64
- 'iso8859_5',
65
- 'iso8859_6',
66
- 'iso8859_7',
67
- 'iso8859_8',
68
- 'iso8859_9',
69
- 'iso8859_10',
70
- 'iso8859_11',
71
- 'iso8859_13',
72
- 'iso8859_14',
73
- 'iso8859_15',
74
- 'iso8859_16',
75
- 'johab',
76
- 'koi8_r',
77
- 'koi8_t',
78
- 'koi8_u',
79
- 'kz1048',
80
- 'mac_cyrillic',
81
- 'mac_greek',
82
- 'mac_iceland',
83
- 'mac_latin2',
84
- 'mac_roman',
85
- 'mac_turkish',
86
- 'ptcp154',
87
- 'shift_jis',
88
- 'shift_jis_2004',
89
- 'shift_jisx0213',
90
- 'utf_32',
91
- 'utf_32_be',
92
- 'utf_32_le',
93
- 'utf_16',
94
- 'utf_16_be',
95
- 'utf_16_le',
96
- 'utf_7',
97
- 'utf_8',
98
- 'utf_8_sig'
5
+ 'ascii', # ASCII 編碼 (基本的英文字符集, 7-bit) / Basic English character set
6
+ 'big5', # Big5 編碼 (繁體中文常用, 台灣/香港) / Traditional Chinese encoding (Taiwan/HK)
7
+ 'big5hkscs', # Big5-HKSCS (香港增補字集) / Big5 with Hong Kong Supplementary Character Set
8
+ 'cp037', # IBM EBCDIC US/Canada / IBM mainframe encoding
9
+ 'cp273', # IBM EBCDIC Germany / 德國 EBCDIC 編碼
10
+ 'cp424', # IBM EBCDIC Hebrew / 希伯來文編碼
11
+ 'cp437', # 原始 IBM PC 編碼 (DOS Latin US) / Original IBM PC encoding
12
+ 'cp500', # IBM EBCDIC International / 國際版 EBCDIC
13
+ 'cp720', # 阿拉伯文 (DOS) / Arabic (DOS)
14
+ 'cp737', # 希臘文 (DOS) / Greek (DOS)
15
+ 'cp775', # 波羅的海語系 (DOS) / Baltic languages (DOS)
16
+ 'cp850', # 西歐語系 (DOS) / Western Europe (DOS)
17
+ 'cp852', # 中歐語系 (DOS) / Central Europe (DOS)
18
+ 'cp855', # 西里爾字母 (DOS) / Cyrillic (DOS)
19
+ 'cp856', # 希伯來文 (DOS) / Hebrew (DOS)
20
+ 'cp857', # 土耳其文 (DOS) / Turkish (DOS)
21
+ 'cp858', # 西歐語系 (含歐元符號) / Western Europe with Euro sign
22
+ 'cp860', # 葡萄牙文 (DOS) / Portuguese (DOS)
23
+ 'cp861', # 冰島文 (DOS) / Icelandic (DOS)
24
+ 'cp862', # 希伯來文 (DOS) / Hebrew (DOS)
25
+ 'cp863', # 加拿大法文 (DOS) / Canadian French (DOS)
26
+ 'cp864', # 阿拉伯文 (DOS) / Arabic (DOS)
27
+ 'cp865', # 北歐語系 (DOS) / Nordic languages (DOS)
28
+ 'cp866', # 俄文 (DOS) / Russian (DOS)
29
+ 'cp869', # 希臘文 (DOS) / Greek (DOS)
30
+ 'cp874', # 泰文 (Windows) / Thai (Windows)
31
+ 'cp875', # IBM EBCDIC Greek / 希臘文 EBCDIC
32
+ 'cp932', # 日文 Shift_JIS (Windows) / Japanese Shift_JIS (Windows)
33
+ 'cp949', # 韓文 (Windows) / Korean (Windows)
34
+ 'cp950', # 繁體中文 Big5 (Windows) / Traditional Chinese Big5 (Windows)
35
+ 'cp1006', # 烏爾都文 (Urdu) / Urdu
36
+ 'cp1026', # IBM EBCDIC Turkish / 土耳其文 EBCDIC
37
+ 'cp1125', # 烏克蘭文 (DOS) / Ukrainian (DOS)
38
+ 'cp1140', # EBCDIC with Euro / EBCDIC 含歐元符號
39
+ 'cp1250', # 中歐語系 (Windows) / Central Europe (Windows)
40
+ 'cp1251', # 西里爾字母 (Windows) / Cyrillic (Windows)
41
+ 'cp1252', # 西歐語系 (Windows, 常見) / Western Europe (Windows, very common)
42
+ 'cp1253', # 希臘文 (Windows) / Greek (Windows)
43
+ 'cp1254', # 土耳其文 (Windows) / Turkish (Windows)
44
+ 'cp1255', # 希伯來文 (Windows) / Hebrew (Windows)
45
+ 'cp1256', # 阿拉伯文 (Windows) / Arabic (Windows)
46
+ 'cp1257', # 波羅的海語系 (Windows) / Baltic (Windows)
47
+ 'cp1258', # 越南文 (Windows) / Vietnamese (Windows)
48
+ 'euc_jp', # 日文 EUC 編碼 / Japanese EUC encoding
49
+ 'euc_jis_2004', # 日文 EUC (JIS 2004) / Japanese EUC (JIS 2004)
50
+ 'euc_jisx0213', # 日文 EUC (JIS X 0213) / Japanese EUC (JIS X 0213)
51
+ 'euc_kr', # 韓文 EUC 編碼 / Korean EUC encoding
52
+ 'gb2312', # 簡體中文 (舊標準) / Simplified Chinese (older standard)
53
+ 'gbk', # 簡體中文 (擴展) / Simplified Chinese (extended)
54
+ 'gb18030', # 簡體中文 (最新國標) / Simplified Chinese (latest national standard)
55
+ 'hz', # HZ-GB-2312 (簡體中文, 郵件常用) / Simplified Chinese (email encoding)
56
+ 'iso2022_jp', # 日文 ISO-2022-JP / Japanese ISO-2022-JP
57
+ 'iso2022_jp_1', # 日文 ISO-2022-JP-1 / Japanese ISO-2022-JP-1
58
+ 'iso2022_jp_2', # 日文 ISO-2022-JP-2 / Japanese ISO-2022-JP-2
59
+ 'iso2022_jp_2004', # 日文 ISO-2022-JP-2004 / Japanese ISO-2022-JP-2004
60
+ 'iso2022_jp_3', # 日文 ISO-2022-JP-3 / Japanese ISO-2022-JP-3
61
+ 'iso2022_jp_ext', # 日文 ISO-2022-JP-EXT / Japanese ISO-2022-JP-EXT
62
+ 'iso2022_kr', # 韓文 ISO-2022-KR / Korean ISO-2022-KR
63
+ 'latin_1', # ISO-8859-1 (西歐語系, 常見) / Western Europe (very common)
64
+ 'iso8859_2', # 中歐語系 / Central Europe
65
+ 'iso8859_3', # 南歐語系 / South Europe
66
+ 'iso8859_4', # 北歐語系 / North Europe
67
+ 'iso8859_5', # 西里爾字母 / Cyrillic
68
+ 'iso8859_6', # 阿拉伯文 / Arabic
69
+ 'iso8859_7', # 希臘文 / Greek
70
+ 'iso8859_8', # 希伯來文 / Hebrew
71
+ 'iso8859_9', # 土耳其文 / Turkish
72
+ 'iso8859_10', # 北歐語系 / Nordic
73
+ 'iso8859_11', # 泰文 / Thai
74
+ 'iso8859_13', # 波羅的海語系 / Baltic
75
+ 'iso8859_14', # 凱爾特語 / Celtic
76
+ 'iso8859_15', # 西歐語系 (含歐元) / Western Europe with Euro
77
+ 'iso8859_16', # 東歐語系 / Eastern Europe
78
+ 'johab', # 韓文 Johab 編碼 / Korean Johab encoding
79
+ 'koi8_r', # 俄文 KOI8-R / Russian KOI8-R
80
+ 'koi8_t', # 塔吉克文 KOI8-T / Tajik KOI8-T
81
+ 'koi8_u', # 烏克蘭文 KOI8-U / Ukrainian KOI8-U
82
+ 'kz1048', # 哈薩克文 / Kazakh
83
+ 'mac_cyrillic', # Mac OS 西里爾字母 / Mac Cyrillic
84
+ 'mac_greek', # Mac OS 希臘文 / Mac Greek
85
+ 'mac_iceland', # Mac OS 冰島文 / Mac Icelandic
86
+ 'mac_latin2', # Mac OS 中歐語系 / Mac Central Europe
87
+ 'mac_roman', # Mac OS 西歐語系 / Mac Roman
88
+ 'mac_turkish', # Mac OS 土耳其文 / Mac Turkish
89
+ 'ptcp154', # 中亞語系 (西里爾字母) / Central Asian Cyrillic
90
+ 'shift_jis', # 日文 Shift JIS 編碼 (常見於 Windows 與網頁) / Japanese Shift JIS encoding (commonly used in Windows & web)
91
+ 'shift_jis_2004', # 日文 Shift JIS (JIS 2004 標準) / Japanese Shift JIS (JIS 2004 standard)
92
+ 'shift_jisx0213', # 日文 Shift JIS (JIS X 0213 擴展) / Japanese Shift JIS (JIS X 0213 extension)
93
+ 'utf_32', # UTF-32 (依平台大小端序, 4 bytes per char) / UTF-32 (platform-dependent endianness, 4 bytes per char)
94
+ 'utf_32_be', # UTF-32 Big Endian / UTF-32 大端序
95
+ 'utf_32_le', # UTF-32 Little Endian / UTF-32 小端序
96
+ 'utf_16', # UTF-16 (依平台大小端序, 2 or 4 bytes per char) / UTF-16 (platform-dependent endianness)
97
+ 'utf_16_be', # UTF-16 Big Endian / UTF-16 大端序
98
+ 'utf_16_le', # UTF-16 Little Endian / UTF-16 小端序
99
+ 'utf_7', # UTF-7 (為電子郵件設計, 已過時) / UTF-7 (designed for email, obsolete)
100
+ 'utf_8', # UTF-8 (最常用, 網頁與跨平台標準) / UTF-8 (most common, web & cross-platform standard)
101
+ 'utf_8_sig' # UTF-8 with BOM (Byte Order Mark) / UTF-8 含 BOM 標記
99
102
  ]
@@ -5,32 +5,32 @@ je_editor_error: str = "JEditor error"
5
5
  """
6
6
  init exception
7
7
  """
8
- je_editor_init_error: str = "JEditor can't init"
9
- je_editor_init_exec_manager_exception: str = "JEditor can't init program manager"
8
+ je_editor_init_error: str = "JEditor failed to initialize"
9
+ je_editor_init_exec_manager_exception: str = "JEditor failed to initialize the program manager"
10
10
  """
11
11
  exec exception
12
12
  """
13
- je_editor_exec_error: str = "JEditor exec error"
13
+ je_editor_exec_error: str = "JEditor execution error"
14
14
  file_not_fond_error: str = "File not found"
15
15
  compiler_not_found_error: str = "Compiler not found"
16
16
  """
17
17
  shell exception
18
18
  """
19
- je_editor_shell_error: str = "JEditor run on shell error"
19
+ je_editor_shell_error: str = "JEditor shell execution error"
20
20
  """
21
21
  file exception
22
22
  """
23
- je_editor_save_file_error: str = "JEditor save file error"
24
- je_editor_open_file_error: str = "JEditor open file error"
23
+ je_editor_save_file_error: str = "JEditor failed to save file"
24
+ je_editor_open_file_error: str = "JEditor failed to open file"
25
25
  """
26
26
  json exception
27
27
  """
28
- cant_reformat_json_error: str = "Can't reformat json is type right?"
29
- wrong_json_data_error: str = "Can't parser json"
30
- cant_find_json_error: str = "cant find json file"
31
- cant_save_json_error: str = "cant save json file"
28
+ cant_reformat_json_error: str = "Cannot reformat JSON: is the type correct?"
29
+ wrong_json_data_error: str = "Failed to parse JSON"
30
+ cant_find_json_error: str = "Can't find JSON file"
31
+ cant_save_json_error: str = "Can't save JSON file"
32
32
  """
33
33
  content data error
34
34
  """
35
- content_set_compiler_error: str = "When set compiler using content make an error"
35
+ content_set_compiler_error: str = "Error setting compiler using content"
36
36
  je_editor_content_file_error: str = "JEditor content file error"
@@ -1,35 +1,51 @@
1
1
  from pathlib import Path
2
2
  from threading import Lock
3
3
 
4
+ # 匯入自訂例外與日誌工具
5
+ # Import custom exception and logging utility
4
6
  from je_editor.utils.exception.exceptions import JEditorOpenFileException
7
+ from je_editor.utils.logging.loggin_instance import jeditor_logger
5
8
 
6
9
 
7
- def read_file(file):
10
+ def read_file(file_path: str) -> list[Path | str] | None:
8
11
  """
9
- use to check file is exist and open
10
- :param file: the file we want to read its whole file path
11
- :return: read's file and file content
12
- try
13
- lock thread
14
- find file is exist ? and is file ?
15
- if both is true
16
- try to open it and read
17
- return file and content
18
- finally
19
- release lock
12
+ 功能說明 (Function Description):
13
+ 用來檢查檔案是否存在並嘗試開啟,讀取其內容。
14
+ Used to check if a file exists and open it to read its content.
15
+
16
+ :param file_path: 檔案完整路徑 / the full path of the file to read
17
+ :return: [檔案路徑, 檔案內容] / [file path, file content]
18
+
19
+ 流程 (Logic):
20
+ 1. 嘗試鎖定執行緒 (避免多執行緒同時存取)
21
+ Try to lock the thread (prevent concurrent access).
22
+ 2. 檢查檔案路徑是否為空,並確認檔案存在且為檔案。
23
+ Check if file path is not empty, exists, and is a file.
24
+ 3. 若條件成立,嘗試以 UTF-8 編碼開啟檔案並讀取內容。
25
+ If true, open the file with UTF-8 encoding and read content.
26
+ 4. 最後釋放鎖。
27
+ Finally, release the lock.
20
28
  """
21
- lock = Lock()
29
+
30
+ # 記錄日誌,方便除錯與追蹤
31
+ # Log the file path for debugging and tracking
32
+ jeditor_logger.info(f"open_file.py read_file file_path: {file_path}")
33
+
34
+ lock = Lock() # 建立一個執行緒鎖 / Create a thread lock
22
35
  try:
23
- lock.acquire()
24
- if file != "" and file is not None:
25
- file_path = Path(file)
26
- if file_path.exists() and file_path.is_file():
27
- with open(file, "r+") as open_read_file:
28
- return [file, open_read_file.read()]
36
+ lock.acquire() # 嘗試鎖定資源 / Acquire the lock
37
+ if file_path != "" and file_path is not None: # 確認路徑不為空 / Ensure path is not empty
38
+ file_path = Path(file_path) # 轉換為 Path 物件 / Convert to Path object
39
+ if file_path.exists() and file_path.is_file(): # 檢查檔案存在且為檔案 / Check file existence
40
+ # 以讀寫模式開啟檔案 (UTF-8 編碼)
41
+ # Open file in read+write mode with UTF-8 encoding
42
+ with open(file_path, "r+", encoding="utf-8") as open_read_file:
43
+ return [file_path, open_read_file.read()] # 回傳檔案路徑與內容 / Return file path and content
29
44
  except JEditorOpenFileException:
45
+ # 捕捉自訂例外並重新拋出
46
+ # Catch custom exception and re-raise
30
47
  raise JEditorOpenFileException
31
48
  finally:
49
+ # 確保鎖一定會被釋放
50
+ # Ensure the lock is always released
32
51
  lock.release()
33
-
34
-
35
-
@@ -1,28 +1,52 @@
1
1
  from threading import Lock
2
2
 
3
+ # 匯入自訂例外與日誌工具
4
+ # Import custom exception and logging utility
3
5
  from je_editor.utils.exception.exceptions import JEditorSaveFileException
6
+ from je_editor.utils.logging.loggin_instance import jeditor_logger
4
7
 
5
8
 
6
- def write_file(file, content):
9
+ def write_file(file_path: str, content: str) -> None:
7
10
  """
8
- :param file: file we want to write
9
- :param content: content write in file
10
- try
11
- lock thread
12
- if file not empty string
13
- write content to file
14
- finally
15
- release lock
11
+ 功能說明 (Function Description):
12
+ 將指定內容寫入檔案,並確保在多執行緒環境下安全操作。
13
+ Write the given content into a file, ensuring thread safety.
14
+
15
+ :param file_path: 要寫入的檔案路徑 / the file path to write
16
+ :param content: 要寫入的內容 / the content to write
17
+
18
+ 流程 (Logic):
19
+ 1. 嘗試鎖定執行緒 (避免多執行緒同時存取檔案)
20
+ Try to lock the thread (prevent concurrent file access).
21
+ 2. 檢查檔案路徑是否為空字串或 None。
22
+ Check if file path is not empty or None.
23
+ 3. 若條件成立,開啟檔案並以 UTF-8 編碼寫入內容。
24
+ If valid, open the file and write content with UTF-8 encoding.
25
+ 4. 最後釋放鎖。
26
+ Finally, release the lock.
16
27
  """
17
- lock = Lock()
18
- content = str(content)
28
+
29
+ # 記錄日誌,方便除錯與追蹤
30
+ # Log the file path and content for debugging and tracking
31
+ jeditor_logger.info("save_file.py write_file "
32
+ f"file_path: {file_path} "
33
+ f"content: {content}")
34
+
35
+ lock = Lock() # 建立一個執行緒鎖 / Create a thread lock
36
+ content = str(content) # 確保內容為字串 / Ensure content is a string
37
+
19
38
  try:
20
- lock.acquire()
21
- if file != "" and file is not None:
22
- with open(file, "w+") as file_to_write:
23
- file_to_write.write(content)
39
+ lock.acquire() # 嘗試鎖定資源 / Acquire the lock
40
+ if file_path != "" and file_path is not None: # 確認路徑有效 / Ensure path is valid
41
+ # 以寫入模式開啟檔案 (UTF-8 編碼)
42
+ # Open file in write+read mode with UTF-8 encoding
43
+ with open(file_path, "w+", encoding="utf-8") as file_to_write:
44
+ file_to_write.write(content) # 寫入內容 / Write content
24
45
  except JEditorSaveFileException:
46
+ # 捕捉自訂例外並重新拋出
47
+ # Catch custom exception and re-raise
25
48
  raise JEditorSaveFileException
26
49
  finally:
50
+ # 確保鎖一定會被釋放
51
+ # Ensure the lock is always released
27
52
  lock.release()
28
-
@@ -1,42 +1,63 @@
1
1
  import json
2
2
  from pathlib import Path
3
3
  from threading import Lock
4
+ from typing import Union, Any
4
5
 
6
+ # 匯入自訂錯誤訊息與例外類別
7
+ # Import custom error messages and exception class
5
8
  from je_editor.utils.exception.exception_tags import cant_find_json_error
6
9
  from je_editor.utils.exception.exception_tags import cant_save_json_error
7
10
  from je_editor.utils.exception.exceptions import JEditorJsonException
11
+ from je_editor.utils.logging.loggin_instance import jeditor_logger
8
12
 
13
+ # 全域鎖,確保多執行緒存取 JSON 檔案時的安全性
14
+ # Global lock to ensure thread safety when accessing JSON files
9
15
  _lock = Lock()
10
16
 
11
17
 
12
- def read_json(json_file_path: str) -> list:
18
+ def read_json(json_file_path: str) -> Any | None:
13
19
  """
14
- use to read action file
15
- :param json_file_path json file's path to read
20
+ 功能說明 (Function Description):
21
+ 讀取 JSON 檔案並回傳其內容。
22
+ Read a JSON file and return its content.
23
+
24
+ :param json_file_path: JSON 檔案路徑 / path to the JSON file
25
+ :return: list 或 dict,取決於 JSON 結構 / list or dict depending on JSON structure
16
26
  """
17
- _lock.acquire()
27
+ jeditor_logger.info(f"json_file.py read_json json_file_path: {json_file_path}")
28
+ _lock.acquire() # 嘗試鎖定資源 / Acquire the lock
18
29
  try:
19
30
  file_path = Path(json_file_path)
20
- if file_path.exists() and file_path.is_file():
21
- with open(json_file_path) as read_file:
22
- return json.loads(read_file.read())
31
+ if file_path.exists() and file_path.is_file(): # 確認檔案存在且為檔案 / Ensure file exists
32
+ with open(json_file_path) as read_file: # 開啟檔案 (預設 UTF-8)
33
+ return json.loads(read_file.read()) # 載入 JSON 並回傳 / Load JSON and return
23
34
  except JEditorJsonException:
35
+ # 捕捉自訂例外並重新拋出
36
+ # Catch custom exception and re-raise
24
37
  raise JEditorJsonException(cant_find_json_error)
25
38
  finally:
26
- _lock.release()
39
+ _lock.release() # 確保鎖一定會被釋放 / Ensure the lock is always released
27
40
 
28
41
 
29
- def write_json(json_save_path: str, user_setting_dict: dict) -> None:
42
+ def write_json(json_save_path: str, data_to_output: Union[list, dict]) -> None:
30
43
  """
31
- use to save action file
32
- :param json_save_path json save path
33
- :param user_setting_dict dict include user setting
44
+ 功能說明 (Function Description):
45
+ 將資料寫入 JSON 檔案。
46
+ Write data into a JSON file.
47
+
48
+ :param json_save_path: JSON 檔案儲存路徑 / path to save the JSON file
49
+ :param data_to_output: 要輸出的資料 (list 或 dict) / data to output (list or dict)
34
50
  """
35
- _lock.acquire()
51
+ jeditor_logger.info("json_file.py write_json "
52
+ f"json_save_path: {json_save_path} "
53
+ f"data_to_output: {data_to_output}")
54
+ _lock.acquire() # 嘗試鎖定資源 / Acquire the lock
36
55
  try:
56
+ # 以寫入模式開啟檔案,並將資料轉換為 JSON 格式 (縮排 4 格)
57
+ # Open file in write mode and dump data as JSON (indent=4)
37
58
  with open(json_save_path, "w+") as file_to_write:
38
- file_to_write.write(json.dumps(user_setting_dict, indent=4))
59
+ file_to_write.write(json.dumps(data_to_output, indent=4))
39
60
  except JEditorJsonException:
40
61
  raise JEditorJsonException(cant_save_json_error)
41
62
  finally:
42
- _lock.release()
63
+ _lock.release() # 確保鎖一定會被釋放 / Ensure the lock is always released
@@ -3,26 +3,62 @@ import sys
3
3
  from json import dumps
4
4
  from json import loads
5
5
 
6
+ # 匯入自訂錯誤訊息與例外類別
7
+ # Import custom error messages and exception class
6
8
  from je_editor.utils.exception.exception_tags import cant_reformat_json_error
7
9
  from je_editor.utils.exception.exception_tags import wrong_json_data_error
8
10
  from je_editor.utils.exception.exceptions import JEditorJsonException
11
+ from je_editor.utils.logging.loggin_instance import jeditor_logger
9
12
 
10
13
 
11
- def __process_json(json_string: str, **kwargs):
14
+ def __process_json(json_string: str, **kwargs) -> str:
15
+ """
16
+ 功能說明 (Function Description):
17
+ 嘗試將輸入的 JSON 字串重新格式化 (pretty print)。
18
+ Try to reformat the input JSON string (pretty print).
19
+
20
+ :param json_string: JSON 格式字串 / JSON formatted string
21
+ :param kwargs: 額外參數傳給 json.dumps / extra arguments for json.dumps
22
+ :return: 格式化後的 JSON 字串 / formatted JSON string
23
+ """
12
24
  try:
25
+ # 嘗試先將字串解析為 JSON,再重新輸出為縮排格式
26
+ # Try to parse string into JSON, then dump with indentation
13
27
  return dumps(loads(json_string), indent=4, sort_keys=True, **kwargs)
14
28
  except json.JSONDecodeError as error:
29
+ # 如果 JSON 格式錯誤,輸出錯誤訊息到 stderr 並拋出例外
30
+ # If JSON format is invalid, print error to stderr and raise exception
15
31
  print(wrong_json_data_error, file=sys.stderr)
16
32
  raise error
17
33
  except TypeError:
34
+ # 如果輸入不是合法 JSON 字串,嘗試直接將物件轉為 JSON
35
+ # If input is not a valid JSON string, try dumping the object directly
18
36
  try:
19
37
  return dumps(json_string, indent=4, sort_keys=True, **kwargs)
20
38
  except TypeError:
39
+ # 若仍失敗,拋出自訂例外
40
+ # If still fails, raise custom exception
21
41
  raise JEditorJsonException(wrong_json_data_error)
22
42
 
23
43
 
24
- def reformat_json(json_string: str, **kwargs):
44
+ def reformat_json(json_string: str, **kwargs) -> str:
45
+ """
46
+ 功能說明 (Function Description):
47
+ 對外提供的 JSON 格式化函式,會呼叫內部的 __process_json。
48
+ Public function to reformat JSON string, calls __process_json internally.
49
+
50
+ :param json_string: JSON 格式字串 / JSON formatted string
51
+ :param kwargs: 額外參數傳給 json.dumps / extra arguments for json.dumps
52
+ :return: 格式化後的 JSON 字串 / formatted JSON string
53
+ """
54
+ # 記錄日誌,方便除錯與追蹤
55
+ # Log the input string and kwargs for debugging and tracking
56
+ jeditor_logger.info(f"json_process.py reformat_json "
57
+ f"json_string: {json_string} "
58
+ f"kwargs: {kwargs}")
25
59
  try:
26
60
  return __process_json(json_string, **kwargs)
27
61
  except JEditorJsonException:
62
+ # 捕捉自訂例外並重新拋出
63
+ # Catch custom exception and re-raise
28
64
  raise JEditorJsonException(cant_reformat_json_error)
File without changes
@@ -0,0 +1,57 @@
1
+ import logging
2
+ from logging.handlers import RotatingFileHandler
3
+
4
+ # 設定 root logger 的最低層級為 DEBUG
5
+ # Set the root logger level to DEBUG
6
+ logging.root.setLevel(logging.DEBUG)
7
+
8
+ # 建立一個名為 "JEditor" 的 logger
9
+ # Create a logger named "JEditor"
10
+ jeditor_logger = logging.getLogger("JEditor")
11
+
12
+ # 設定 JEditor logger 的層級為 WARNING (只會輸出 WARNING 以上的訊息)
13
+ # Set the JEditor logger level to WARNING (only WARNING and above will be logged)
14
+ jeditor_logger.setLevel(logging.WARNING)
15
+
16
+ # 定義日誌格式:時間 | logger 名稱 | 等級 | 訊息
17
+ # Define log format: time | logger name | level | message
18
+ formatter = logging.Formatter('%(asctime)s | %(name)s | %(levelname)s | %(message)s')
19
+
20
+
21
+ class JEditorLoggingHandler(RotatingFileHandler):
22
+ """
23
+ 自訂的 Logging Handler,繼承自 RotatingFileHandler
24
+ Custom Logging Handler, inherits from RotatingFileHandler
25
+
26
+ 功能:
27
+ - 將日誌輸出到檔案 (支援檔案大小輪替)
28
+ - 預設檔名為 JEditor.log
29
+ """
30
+
31
+ # redirect logging stderr output to queue (註解說明,但目前未實作)
32
+ # 註解提到要將 stderr 輸出導向 queue,但目前程式碼僅繼承 RotatingFileHandler
33
+
34
+ def __init__(self, filename: str = "JEditor.log", mode="w",
35
+ maxBytes: int = 1073741824, backupCount: int = 0):
36
+ """
37
+ :param filename: 日誌檔案名稱 / log file name
38
+ :param mode: 檔案開啟模式 (預設 w 覆寫) / file open mode (default "w" overwrite)
39
+ :param maxBytes: 單一檔案最大大小 (預設 1GB) / max file size (default 1GB)
40
+ :param backupCount: 保留的備份檔案數量 / number of backup files to keep
41
+ """
42
+ super().__init__(filename=filename, mode=mode, maxBytes=maxBytes, backupCount=backupCount)
43
+ self.formatter = formatter # 設定日誌格式 / set log formatter
44
+ self.setLevel(logging.DEBUG) # 設定 handler 層級為 DEBUG / set handler level to DEBUG
45
+
46
+ def emit(self, record: logging.LogRecord) -> None:
47
+ """
48
+ 實際輸出日誌的方法,這裡直接呼叫父類別的 emit
49
+ Method to emit log records, here just call parent emit
50
+ """
51
+ super().emit(record)
52
+
53
+
54
+ # 建立檔案處理器並加入到 JEditor logger
55
+ # Create file handler and add it to JEditor logger
56
+ file_handler = JEditorLoggingHandler()
57
+ jeditor_logger.addHandler(file_handler)
File without changes