@@ -33,6 +33,9 @@ msgid ""
33
33
"list functions executed during a program run. It can be used in another "
34
34
"program or from the command line."
35
35
msgstr ""
36
+ ":mod:`trace` 模組可用來追蹤程式執行過程、產生帶註解的陳述式涵蓋範圍串列、輸出"
37
+ "呼叫者/被呼叫者的關係,以及在程式執行期間被執行的函式串列。它可以在其他程式"
38
+ "中使用,也可以從命令列啟動。"
36
39
37
40
#: ../../library/trace.rst:18
38
41
msgid "`Coverage.py <https://coverage.readthedocs.io/>`_"
@@ -42,17 +45,17 @@ msgstr "`Coverage.py <https://coverage.readthedocs.io/>`_"
42
45
msgid ""
43
46
"A popular third-party coverage tool that provides HTML output along with "
44
47
"advanced features such as branch coverage."
45
- msgstr ""
48
+ msgstr "一款受歡迎的第三方涵蓋範圍工具,提供 HTML 輸出與分支涵蓋等進階功能。 "
46
49
47
50
#: ../../library/trace.rst:25
48
51
msgid "Command-Line Usage"
49
- msgstr ""
52
+ msgstr "命令列用法 "
50
53
51
54
#: ../../library/trace.rst:27
52
55
msgid ""
53
56
"The :mod:`trace` module can be invoked from the command line. It can be as "
54
57
"simple as ::"
55
- msgstr ""
58
+ msgstr ":mod:`trace` 模組可從命令列執行,用法可以非常簡單,如::: "
56
59
57
60
#: ../../library/trace.rst:30
58
61
msgid "python -m trace --count -C . somefile.py ..."
@@ -64,22 +67,24 @@ msgid ""
64
67
"of all Python modules imported during the execution into the current "
65
68
"directory."
66
69
msgstr ""
70
+ "上述命令會執行 :file:`somefile.py`,並將產生執行期間所引入的所有 Python 模組"
71
+ "的帶註解串列,輸出至目前目錄。"
67
72
68
73
#: ../../library/trace.rst:39
69
74
msgid "Display usage and exit."
70
- msgstr ""
75
+ msgstr "顯示用法並結束程式。 "
71
76
72
77
#: ../../library/trace.rst:43
73
78
msgid "Display the version of the module and exit."
74
- msgstr ""
79
+ msgstr "顯示模組版本並結束程式。 "
75
80
76
81
#: ../../library/trace.rst:45
77
82
msgid "Added ``--module`` option that allows to run an executable module."
78
- msgstr ""
83
+ msgstr "新增 ``--module`` 選項,允許執行可執行模組。 "
79
84
80
85
#: ../../library/trace.rst:49
81
86
msgid "Main options"
82
- msgstr ""
87
+ msgstr "主要選項 "
83
88
84
89
#: ../../library/trace.rst:51
85
90
msgid ""
@@ -89,97 +94,117 @@ msgid ""
89
94
"`--listfuncs <-l>` is provided, neither :option:`--count <-c>` nor :option:"
90
95
"`--trace <-t>` are accepted, and vice versa."
91
96
msgstr ""
97
+ "執行 :mod:`trace` 時,至少必須指定以下選項之一。:option:`--listfuncs <-l>` 選"
98
+ "項與 :option:`--trace <-t>` 及 :option:`--count <-c>` 選項互斥。當提供 :"
99
+ "option:`--listfuncs <-l>` 時,將不接受 :option:`--count <-c>` 或 :option:`--"
100
+ "trace <-t>`,反之亦然。"
92
101
93
102
#: ../../library/trace.rst:61
94
103
msgid ""
95
104
"Produce a set of annotated listing files upon program completion that shows "
96
105
"how many times each statement was executed. See also :option:`--coverdir <-"
97
106
"C>`, :option:`--file <-f>` and :option:`--no-report <-R>` below."
98
107
msgstr ""
108
+ "在程式執行結束時產生一組帶註解串列檔案,顯示每個陳述式被執行的次數。參見下方"
109
+ "的 :option:`--coverdir <-C>`、:option:`--file <-f>` 及 :option:`--no-report "
110
+ "<-R>`。"
99
111
100
112
#: ../../library/trace.rst:68
101
113
msgid "Display lines as they are executed."
102
- msgstr ""
114
+ msgstr "執行時即時顯示每一行。 "
103
115
104
116
#: ../../library/trace.rst:72
105
117
msgid "Display the functions executed by running the program."
106
- msgstr ""
118
+ msgstr "顯示程式執行過程中被呼叫的函式。 "
107
119
108
120
#: ../../library/trace.rst:76
109
121
msgid ""
110
122
"Produce an annotated list from an earlier program run that used the :option:"
111
123
"`--count <-c>` and :option:`--file <-f>` option. This does not execute any "
112
124
"code."
113
125
msgstr ""
126
+ "從先前使用 :option:`--count <-c>` 與 :option:`--file <-f>` 選項執行過的程式生"
127
+ "成帶註解的串列,不會執行任何程式碼。"
114
128
115
129
#: ../../library/trace.rst:82
116
130
msgid "Display the calling relationships exposed by running the program."
117
- msgstr ""
131
+ msgstr "顯示程式執行時產生的呼叫關係。 "
118
132
119
133
#: ../../library/trace.rst:85
120
134
msgid "Modifiers"
121
- msgstr ""
135
+ msgstr "修飾子 "
122
136
123
137
#: ../../library/trace.rst:91
124
138
msgid ""
125
139
"Name of a file to accumulate counts over several tracing runs. Should be "
126
140
"used with the :option:`--count <-c>` option."
127
141
msgstr ""
142
+ "指定用來累積多次追蹤結果的檔案名稱。應與 :option:`--count <-c>` 選項搭配使"
143
+ "用。"
128
144
129
145
#: ../../library/trace.rst:96
130
146
msgid ""
131
147
"Directory where the report files go. The coverage report for ``package."
132
148
"module`` is written to file :file:`{dir}/{package}/{module}.cover`."
133
149
msgstr ""
150
+ "報告檔案的輸出目錄。``package.module`` 的涵蓋範圍報告將寫入檔案::file:"
151
+ "`{dir}/{package}/{module}.cover`。"
134
152
135
153
#: ../../library/trace.rst:101
136
154
msgid ""
137
155
"When generating annotated listings, mark lines which were not executed with "
138
156
"``>>>>>>``."
139
- msgstr ""
157
+ msgstr "在產生帶註解的串列時,使用 ``>>>>>>`` 標記未被執行的程式碼行。 "
140
158
141
159
#: ../../library/trace.rst:106
142
160
msgid ""
143
161
"When using :option:`--count <-c>` or :option:`--report <-r>`, write a brief "
144
162
"summary to stdout for each file processed."
145
163
msgstr ""
164
+ "使用 :option:`--count <-c>` 或 :option:`--report <-r>` 時,會將每個處理過的檔"
165
+ "案摘要輸出至 stdout。"
146
166
147
167
#: ../../library/trace.rst:111
148
168
msgid ""
149
169
"Do not generate annotated listings. This is useful if you intend to make "
150
170
"several runs with :option:`--count <-c>`, and then produce a single set of "
151
171
"annotated listings at the end."
152
172
msgstr ""
173
+ "不產生帶註解的串列。若你打算多次使用 :option:`--count <-c>` 執行程式,並在最"
174
+ "後再統一產生串列,這會很有幫助。"
153
175
154
176
#: ../../library/trace.rst:117
155
177
msgid ""
156
178
"Prefix each line with the time since the program started. Only used while "
157
179
"tracing."
158
- msgstr ""
180
+ msgstr "在每一行前加上自程式啟動以來的經過時間。僅在追蹤時使用。 "
159
181
160
182
#: ../../library/trace.rst:121
161
183
msgid "Filters"
162
- msgstr ""
184
+ msgstr "篩選子 "
163
185
164
186
#: ../../library/trace.rst:123
165
187
msgid "These options may be repeated multiple times."
166
- msgstr ""
188
+ msgstr "這些選項可以重複使用多次。 "
167
189
168
190
#: ../../library/trace.rst:129
169
191
msgid ""
170
192
"Ignore each of the given module names and its submodules (if it is a "
171
193
"package). The argument can be a list of names separated by a comma."
172
194
msgstr ""
195
+ "忽略所指定的模組名稱及其子模組(若為套件)。引數可以是以逗號分隔的名稱串列。"
173
196
174
197
#: ../../library/trace.rst:134
175
198
msgid ""
176
199
"Ignore all modules and packages in the named directory and subdirectories. "
177
200
"The argument can be a list of directories separated by :data:`os.pathsep`."
178
201
msgstr ""
202
+ "忽略指定目錄及其子目錄中的所有模組與套件。引數可以是以 :data:`os.pathsep` 分"
203
+ "隔的目錄串列。"
179
204
180
205
#: ../../library/trace.rst:140
181
206
msgid "Programmatic Interface"
182
- msgstr ""
207
+ msgstr "程式介面 "
183
208
184
209
#: ../../library/trace.rst:145
185
210
msgid ""
@@ -194,43 +219,60 @@ msgid ""
194
219
"count information. *timing* enables a timestamp relative to when tracing "
195
220
"was started to be displayed."
196
221
msgstr ""
222
+ "建立一個物件以追蹤單一陳述式或運算式的執行。所有參數皆為可選的。*count* 啟用"
223
+ "行數統計,*trace* 啟用逐行追蹤執行,*countfuncs* 可列出執行期間呼叫的函式,"
224
+ "*countcallers* 追蹤呼叫關係,*ignoremods* 是要忽略的模組或套件名稱串列,"
225
+ "*ignoredirs* 是其模組或套件應被忽略的目錄串列,*infile* 是讀取儲存計數資料的"
226
+ "檔案名稱,*outfile* 是要寫入更新後計數資料的檔案名稱,*timing* 則會顯示自開始"
227
+ "追蹤以來的時間戳記。"
197
228
198
229
#: ../../library/trace.rst:158
199
230
msgid ""
200
231
"Execute the command and gather statistics from the execution with the "
201
232
"current tracing parameters. *cmd* must be a string or code object, suitable "
202
233
"for passing into :func:`exec`."
203
234
msgstr ""
235
+ "執行指令,並依目前追蹤參數收集執行統計資料。*cmd* 必須是可傳入 :func:`exec` "
236
+ "的字串或程式碼物件。"
204
237
205
238
#: ../../library/trace.rst:164
206
239
msgid ""
207
240
"Execute the command and gather statistics from the execution with the "
208
241
"current tracing parameters, in the defined global and local environments. "
209
242
"If not defined, *globals* and *locals* default to empty dictionaries."
210
243
msgstr ""
244
+ "在指定的全域與區域命名空間中,根據目前的追蹤參數執行指令並收集統計資料。若未"
245
+ "指定,*globals* 與 *locals* 預設為空字典。"
211
246
212
247
#: ../../library/trace.rst:171
213
248
msgid ""
214
249
"Call *func* with the given arguments under control of the :class:`Trace` "
215
250
"object with the current tracing parameters."
216
251
msgstr ""
252
+ "在目前的追蹤參數下,使用 :class:`Trace` 物件控制呼叫 *func*,並傳入指定的引"
253
+ "數。"
217
254
218
255
#: ../../library/trace.rst:176
219
256
msgid ""
220
257
"Return a :class:`CoverageResults` object that contains the cumulative "
221
258
"results of all previous calls to ``run``, ``runctx`` and ``runfunc`` for the "
222
259
"given :class:`Trace` instance. Does not reset the accumulated trace results."
223
260
msgstr ""
261
+ "回傳一個 :class:`CoverageResults` 物件,包含指定 :class:`Trace` 實例中所有先"
262
+ "前對 ``run``、``runctx`` 與 ``runfunc`` 呼叫的累積結果。不會重設累積的追蹤結"
263
+ "果。"
224
264
225
265
#: ../../library/trace.rst:183
226
266
msgid ""
227
267
"A container for coverage results, created by :meth:`Trace.results`. Should "
228
268
"not be created directly by the user."
229
269
msgstr ""
270
+ "一個用來儲存涵蓋範圍結果的容器,由 :meth:`Trace.results` 建立。不應由使用者直"
271
+ "接建立。"
230
272
231
273
#: ../../library/trace.rst:188
232
274
msgid "Merge in data from another :class:`CoverageResults` object."
233
- msgstr ""
275
+ msgstr "合併來自另一個 :class:`CoverageResults` 物件的資料。 "
234
276
235
277
#: ../../library/trace.rst:193
236
278
msgid ""
@@ -240,21 +282,27 @@ msgid ""
240
282
"be output. If ``None``, the results for each source file are placed in its "
241
283
"directory."
242
284
msgstr ""
285
+ "寫入涵蓋範圍結果。將 *show_missing* 設為真可顯示未被執行的程式碼行;將 "
286
+ "*summary* 設為真則會在輸出中加入每個模組的涵蓋範圍摘要。*coverdir* 指定輸出涵"
287
+ "蓋範圍結果檔案的目錄,若為 ``None``,則每個原始檔案的結果會輸出至其所在目錄"
288
+ "中。"
243
289
244
290
#: ../../library/trace.rst:199
245
291
msgid ""
246
292
"If *ignore_missing_files* is ``True``, coverage counts for files that no "
247
293
"longer exist are silently ignored. Otherwise, a missing file will raise a :"
248
294
"exc:`FileNotFoundError`."
249
295
msgstr ""
296
+ "若 *ignore_missing_files* 為 ``True``,則會忽略那些已不存在的檔案的涵蓋範圍資"
297
+ "料,不會顯示任何錯誤。否則,缺少的檔案將會引發 :exc:`FileNotFoundError`。"
250
298
251
299
#: ../../library/trace.rst:203
252
300
msgid "Added *ignore_missing_files* parameter."
253
- msgstr ""
301
+ msgstr "新增 *ignore_missing_files* 參數。 "
254
302
255
303
#: ../../library/trace.rst:206
256
304
msgid "A simple example demonstrating the use of the programmatic interface::"
257
- msgstr ""
305
+ msgstr "以下是一個簡單範例,展示如何使用程式介面: "
258
306
259
307
#: ../../library/trace.rst:208
260
308
msgid ""
@@ -275,3 +323,19 @@ msgid ""
275
323
"r = tracer.results()\n"
276
324
"r.write_results(show_missing=True, coverdir=\" .\" )"
277
325
msgstr ""
326
+ "import sys\n"
327
+ "import trace\n"
328
+ "\n"
329
+ "# 建立一個 Trace 物件,指定要忽略的目錄,\n"
330
+ "# 並設定是否進行追蹤、行數統計或兩者皆做。\n"
331
+ "tracer = trace.Trace(\n"
332
+ " ignoredirs=[sys.prefix, sys.exec_prefix],\n"
333
+ " trace=0,\n"
334
+ " count=1)\n"
335
+ "\n"
336
+ "# 使用該 tracer 執行新的指令\n"
337
+ "tracer.run('main()')\n"
338
+ "\n"
339
+ "# 建立報告,將輸出放在目前目錄中\n"
340
+ "r = tracer.results()\n"
341
+ "r.write_results(show_missing=True, coverdir=\" .\" )"