Skip to content

Commit 881aa83

Browse files
sync with cpython 5df76528
1 parent 03eb81e commit 881aa83

File tree

1 file changed

+100
-66
lines changed

1 file changed

+100
-66
lines changed

library/pkgutil.po

Lines changed: 100 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: Python 3.14\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-09-08 15:25+0800\n"
10+
"POT-Creation-Date: 2026-04-08 00:24+0000\n"
1111
"PO-Revision-Date: 2024-03-08 16:07+0000\n"
1212
"Last-Translator: Matt Wang <mattwang44@gmail.com>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -41,8 +41,8 @@ msgid ""
4141
"Extend the search path for the modules which comprise a package. Intended "
4242
"use is to place the following code in a package's :file:`__init__.py`::"
4343
msgstr ""
44-
"擴充組成一個套件之模組的搜尋路徑。預期用法是將以下程式碼放入套件"
45-
"的 :file:`__init__.py`: ::"
44+
"擴充組成一個套件之模組的搜尋路徑。預期用法是將以下程式碼放入套件的 :file:"
45+
"`__init__.py`: ::"
4646

4747
#: ../../library/pkgutil.rst:25
4848
msgid ""
@@ -55,10 +55,9 @@ msgstr ""
5555
#: ../../library/pkgutil.rst:28
5656
msgid ""
5757
"For each directory on :data:`sys.path` that has a subdirectory that matches "
58-
"the package name, add the subdirectory to the "
59-
"package's :attr:`~module.__path__`. This is useful if one wants to "
60-
"distribute different parts of a single logical package as multiple "
61-
"directories."
58+
"the package name, add the subdirectory to the package's :attr:`~module."
59+
"__path__`. This is useful if one wants to distribute different parts of a "
60+
"single logical package as multiple directories."
6261
msgstr ""
6362
"對於 :data:`sys.path` 上具有與套件名稱相符的子目錄的每個目錄,將該子目錄新增"
6463
"至套件的 :attr:`~module.__path__` 中。如果想要將單一邏輯套件的不同部分給分配"
@@ -67,12 +66,12 @@ msgstr ""
6766
#: ../../library/pkgutil.rst:34
6867
msgid ""
6968
"It also looks for :file:`\\*.pkg` files beginning where ``*`` matches the "
70-
"*name* argument. This feature is similar to :file:`\\*.pth` files (see "
71-
"the :mod:`site` module for more information), except that it doesn't special-"
72-
"case lines starting with ``import``. A :file:`\\*.pkg` file is trusted at "
73-
"face value: apart from skipping blank lines and ignoring comments, all "
74-
"entries found in a :file:`\\*.pkg` file are added to the path, regardless of "
75-
"whether they exist on the filesystem (this is a feature)."
69+
"*name* argument. This feature is similar to :file:`\\*.pth` files (see the :"
70+
"mod:`site` module for more information), except that it doesn't special-case "
71+
"lines starting with ``import``. A :file:`\\*.pkg` file is trusted at face "
72+
"value: apart from skipping blank lines and ignoring comments, all entries "
73+
"found in a :file:`\\*.pkg` file are added to the path, regardless of whether "
74+
"they exist on the filesystem (this is a feature)."
7675
msgstr ""
7776
"它還會尋找 :file:`\\*.pkg` 檔案,其中開頭的 ``*`` 與 *name* 引數相符。此功能"
7877
"類似於 :file:`\\*.pth` 檔案(更多資訊請參閱 :mod:`site` 模組),但他不特別處"
@@ -91,11 +90,11 @@ msgstr ""
9190

9291
#: ../../library/pkgutil.rst:46
9392
msgid ""
94-
"It is assumed that :data:`sys.path` is a sequence. Items "
95-
"of :data:`sys.path` that are not strings referring to existing directories "
96-
"are ignored. Unicode items on :data:`sys.path` that cause errors when used "
97-
"as filenames may cause this function to raise an exception (in line "
98-
"with :func:`os.path.isdir` behavior)."
93+
"It is assumed that :data:`sys.path` is a sequence. Items of :data:`sys."
94+
"path` that are not strings referring to existing directories are ignored. "
95+
"Unicode items on :data:`sys.path` that cause errors when used as filenames "
96+
"may cause this function to raise an exception (in line with :func:`os.path."
97+
"isdir` behavior)."
9998
msgstr ""
10099
":data:`sys.path` 被假設是一個序列,:data:`sys.path` 中的項目裡,若不是代表現"
101100
"存目錄的字串則將被忽略。:data:`sys.path` 上用作檔案名稱時導致錯誤的 Unicode "
@@ -115,8 +114,8 @@ msgstr ""
115114

116115
#: ../../library/pkgutil.rst:60
117116
msgid ""
118-
"The cache (or part of it) can be cleared manually if a rescan "
119-
"of :data:`sys.path_hooks` is necessary."
117+
"The cache (or part of it) can be cleared manually if a rescan of :data:`sys."
118+
"path_hooks` is necessary."
120119
msgstr ""
121120
"如果需要重新掃描 :data:`sys.path_hooks`,可以手動清除快取(或部分快取)。"
122121

@@ -137,12 +136,12 @@ msgstr "yield 給定模組名稱的 :term:`finder` 物件。"
137136
msgid ""
138137
"If *fullname* contains a ``'.'``, the finders will be for the package "
139138
"containing *fullname*, otherwise they will be all registered top level "
140-
"finders (i.e. those on both :data:`sys.meta_path` "
141-
"and :data:`sys.path_hooks`)."
139+
"finders (i.e. those on both :data:`sys.meta_path` and :data:`sys."
140+
"path_hooks`)."
142141
msgstr ""
143142
"如果 *fullname* 包含 ``'.'``,則尋檢器將針對包含 *fullname* 的套件,否則它們"
144-
"全部會是在頂層被註冊的尋檢器(即 :data:`sys.meta_path` "
145-
"和 :data:`sys.path_hooks` 上的尋檢器)。"
143+
"全部會是在頂層被註冊的尋檢器(即 :data:`sys.meta_path` 和 :data:`sys."
144+
"path_hooks` 上的尋檢器)。"
146145

147146
#: ../../library/pkgutil.rst:76
148147
msgid ""
@@ -178,12 +177,12 @@ msgstr "*prefix* 是在輸出的每個模組名稱前面的輸出字串。"
178177
msgid ""
179178
"Only works for a :term:`finder` which defines an ``iter_modules()`` method. "
180179
"This interface is non-standard, so the module also provides implementations "
181-
"for :class:`importlib.machinery.FileFinder` "
182-
"and :class:`zipimport.zipimporter`."
180+
"for :class:`importlib.machinery.FileFinder` and :class:`zipimport."
181+
"zipimporter`."
183182
msgstr ""
184183
"僅適用於有定義 ``iter_modules()`` 方法的 :term:`finder`。此介面並非是標準的,"
185-
"因此該模組還提供了 :class:`importlib.machinery.FileFinder` "
186-
"和 :class:`zipimport.zipimporter` 的實作。"
184+
"因此該模組還提供了 :class:`importlib.machinery.FileFinder` 和 :class:"
185+
"`zipimport.zipimporter` 的實作。"
187186

188187
#: ../../library/pkgutil.rst:109
189188
msgid ""
@@ -206,13 +205,13 @@ msgstr ""
206205
msgid ""
207206
"*onerror* is a function which gets called with one argument (the name of the "
208207
"package which was being imported) if any exception occurs while trying to "
209-
"import a package. If no *onerror* function is "
210-
"supplied, :exc:`ImportError`\\s are caught and ignored, while all other "
211-
"exceptions are propagated, terminating the search."
208+
"import a package. If no *onerror* function is supplied, :exc:"
209+
"`ImportError`\\s are caught and ignored, while all other exceptions are "
210+
"propagated, terminating the search."
212211
msgstr ""
213212
"*onerror* 是一個函式,如果在嘗試引入套件時發生任何例外,則使用一個引數(正在"
214-
"引入之套件的名稱)來呼叫函式。如果未提供 *onerror* 函式,則會捕獲並忽"
215-
"略 :exc:`ImportError`,同時傳播所有其他例外並終止搜尋。"
213+
"引入之套件的名稱)來呼叫函式。如果未提供 *onerror* 函式,則會捕獲並忽略 :exc:"
214+
"`ImportError`,同時傳播所有其他例外並終止搜尋。"
216215

217216
#: ../../library/pkgutil.rst:126
218217
msgid "Examples::"
@@ -237,67 +236,102 @@ msgid "Get a resource from a package."
237236
msgstr "從套件中取得資源。"
238237

239238
#: ../../library/pkgutil.rst:150
239+
#, fuzzy
240240
msgid ""
241-
"This is a wrapper for the :term:`loader` :meth:`get_data "
242-
"<importlib.abc.ResourceLoader.get_data>` API. The *package* argument should "
243-
"be the name of a package, in standard module format (``foo.bar``). The "
244-
"*resource* argument should be in the form of a relative filename, using ``/"
245-
"`` as the path separator. The parent directory name ``..`` is not allowed, "
246-
"and nor is a rooted name (starting with a ``/``)."
241+
"This is a wrapper for the :term:`loader` :meth:`get_data <importlib.abc."
242+
"ResourceLoader.get_data>` API. The *package* argument should be the name of "
243+
"a package, in standard module format (``foo.bar``). The *resource* argument "
244+
"should be in the form of a relative filename, using ``/`` as the path "
245+
"separator."
247246
msgstr ""
248247
"這是 :term:`loader` :meth:`get_data <importlib.abc.ResourceLoader.get_data>` "
249248
"API 的包裝器。*package* 引數應該是採用標準模組格式 (``foo.bar``) 的套件名稱。"
250249
"*resource* 引數應為相對檔案名稱的形式,並使用 ``/`` 作為路徑分隔符號。不允許"
251250
"使用父目錄名稱 ``..``,也不允許使用根目錄名稱(以 ``/`` 開頭)。"
252251

253-
#: ../../library/pkgutil.rst:157
252+
#: ../../library/pkgutil.rst:156
254253
msgid ""
255254
"The function returns a binary string that is the contents of the specified "
256255
"resource."
257256
msgstr "該函式回傳一個二進位字串,它是指定資源的內容。"
258257

259-
#: ../../library/pkgutil.rst:160
258+
#: ../../library/pkgutil.rst:159
259+
msgid ""
260+
"This function uses the :term:`loader` method :func:`~importlib.abc."
261+
"FileLoader.get_data` to support modules installed in the filesystem, but "
262+
"also in zip files, databases, or elsewhere."
263+
msgstr ""
264+
265+
#: ../../library/pkgutil.rst:164
260266
msgid ""
261267
"For packages located in the filesystem, which have already been imported, "
262268
"this is the rough equivalent of::"
263269
msgstr "對於位於檔案系統中且已被引入過的套件,這大致相當於: ::"
264270

265-
#: ../../library/pkgutil.rst:163
271+
#: ../../library/pkgutil.rst:167
266272
msgid ""
267273
"d = os.path.dirname(sys.modules[package].__file__)\n"
268274
"data = open(os.path.join(d, resource), 'rb').read()"
269275
msgstr ""
270276
"d = os.path.dirname(sys.modules[package].__file__)\n"
271277
"data = open(os.path.join(d, resource), 'rb').read()"
272278

273-
#: ../../library/pkgutil.rst:166
279+
#: ../../library/pkgutil.rst:170
280+
msgid ""
281+
"Like the :func:`open` function, :func:`!get_data` can follow parent "
282+
"directories (``../``) and absolute paths (starting with ``/`` or ``C:/``, "
283+
"for example). It can open compilation/installation artifacts like ``.py`` "
284+
"and ``.pyc`` files or files with :func:`reserved filenames <os.path."
285+
"isreserved>`. To be compatible with non-filesystem loaders, avoid using "
286+
"these features."
287+
msgstr ""
288+
289+
#: ../../library/pkgutil.rst:179
290+
msgid ""
291+
"This function is intended for trusted input. It does not verify that "
292+
"*resource* \"belongs\" to *package*."
293+
msgstr ""
294+
295+
#: ../../library/pkgutil.rst:182
296+
msgid ""
297+
"If you use a user-provided *resource* path, consider verifying it. For "
298+
"example, require an alphanumeric filename with a known extension, or install "
299+
"and check a list of known resources."
300+
msgstr ""
301+
302+
#: ../../library/pkgutil.rst:186
274303
msgid ""
275304
"If the package cannot be located or loaded, or it uses a :term:`loader` "
276-
"which does not support :meth:`get_data "
277-
"<importlib.abc.ResourceLoader.get_data>`, then ``None`` is returned. In "
278-
"particular, the :term:`loader` for :term:`namespace packages <namespace "
279-
"package>` does not support :meth:`get_data "
280-
"<importlib.abc.ResourceLoader.get_data>`."
305+
"which does not support :meth:`get_data <importlib.abc.ResourceLoader."
306+
"get_data>`, then ``None`` is returned. In particular, the :term:`loader` "
307+
"for :term:`namespace packages <namespace package>` does not support :meth:"
308+
"`get_data <importlib.abc.ResourceLoader.get_data>`."
281309
msgstr ""
282-
"如果無法定位或載入套件,或者它使用不支援 :meth:`get_data "
283-
"<importlib.abc.ResourceLoader.get_data>` 的 :term:`loader` 則回傳 ``None``。"
284-
"特別是\\ :term:`命名空間套件 <namespace package>`\\ 的 :term:`loader` 不支"
285-
"援 :meth:`get_data <importlib.abc.ResourceLoader.get_data>`。"
310+
"如果無法定位或載入套件,或者它使用不支援 :meth:`get_data <importlib.abc."
311+
"ResourceLoader.get_data>` 的 :term:`loader` 則回傳 ``None``。特別是\\ :term:`"
312+
"命名空間套件 <namespace package>`\\ 的 :term:`loader` 不支援 :meth:`get_data "
313+
"<importlib.abc.ResourceLoader.get_data>`。"
286314

287-
#: ../../library/pkgutil.rst:175
315+
#: ../../library/pkgutil.rst:194
316+
msgid ""
317+
"The :mod:`importlib.resources` module provides structured access to module "
318+
"resources."
319+
msgstr ""
320+
321+
#: ../../library/pkgutil.rst:199
288322
msgid "Resolve a name to an object."
289323
msgstr "將名稱解析為物件。"
290324

291-
#: ../../library/pkgutil.rst:177
325+
#: ../../library/pkgutil.rst:201
292326
msgid ""
293-
"This functionality is used in numerous places in the standard library "
294-
"(see :issue:`12915`) - and equivalent functionality is also in widely used "
295-
"third-party packages such as setuptools, Django and Pyramid."
327+
"This functionality is used in numerous places in the standard library (see :"
328+
"issue:`12915`) - and equivalent functionality is also in widely used third-"
329+
"party packages such as setuptools, Django and Pyramid."
296330
msgstr ""
297331
"標準函式庫中的許多地方都使用了此功能(請參閱 :issue:`12915`),且相同功能也被"
298332
"用於擁有廣大使用者的第三方套件,如 setuptools、Django 和 Pyramid。"
299333

300-
#: ../../library/pkgutil.rst:181
334+
#: ../../library/pkgutil.rst:205
301335
msgid ""
302336
"It is expected that *name* will be a string in one of the following formats, "
303337
"where W is shorthand for a valid Python identifier and dot stands for a "
@@ -306,15 +340,15 @@ msgstr ""
306340
"*name* 預期要是以下格式之一的字串,其中 W 是有效 Python 識別字的簡寫,而點 "
307341
"(dot) 代表這些偽正規表示式 (pseudo-regex) 中的字面句點 (literal period):"
308342

309-
#: ../../library/pkgutil.rst:185
343+
#: ../../library/pkgutil.rst:209
310344
msgid "``W(.W)*``"
311345
msgstr "``W(.W)*``"
312346

313-
#: ../../library/pkgutil.rst:186
347+
#: ../../library/pkgutil.rst:210
314348
msgid "``W(.W)*:(W(.W)*)?``"
315349
msgstr "``W(.W)*:(W(.W)*)?``"
316350

317-
#: ../../library/pkgutil.rst:188
351+
#: ../../library/pkgutil.rst:212
318352
msgid ""
319353
"The first form is intended for backward compatibility only. It assumes that "
320354
"some part of the dotted name is a package, and the rest is an object "
@@ -328,7 +362,7 @@ msgstr ""
328362
"於無法透過檢查 (inspection) 來推斷出套件停止的位置和物件層次結構的開始位置,"
329363
"因此必須使用此形式來重複嘗試引入。"
330364

331-
#: ../../library/pkgutil.rst:195
365+
#: ../../library/pkgutil.rst:219
332366
msgid ""
333367
"In the second form, the caller makes the division point clear through the "
334368
"provision of a single colon: the dotted name to the left of the colon is a "
@@ -340,21 +374,21 @@ msgstr ""
340374
"引入的套件,右側的點名稱是該套件內的物件層次結構。這種形式只需要一次引入。如"
341375
"果它以冒號結尾,則回傳一個模組物件。"
342376

343-
#: ../../library/pkgutil.rst:201
377+
#: ../../library/pkgutil.rst:225
344378
msgid ""
345379
"The function will return an object (which might be a module), or raise one "
346380
"of the following exceptions:"
347381
msgstr "此函式會回傳一個物件(可能是一個模組),或引發以下其中一個例外:"
348382

349-
#: ../../library/pkgutil.rst:204
383+
#: ../../library/pkgutil.rst:228
350384
msgid ":exc:`ValueError` -- if *name* isn't in a recognised format."
351385
msgstr ":exc:`ValueError` -- 如果 *name* 不是可辨識的格式。"
352386

353-
#: ../../library/pkgutil.rst:206
387+
#: ../../library/pkgutil.rst:230
354388
msgid ":exc:`ImportError` -- if an import failed when it shouldn't have."
355389
msgstr ":exc:`ImportError` -- 如果在不應該失敗的情況下引入失敗。"
356390

357-
#: ../../library/pkgutil.rst:208
391+
#: ../../library/pkgutil.rst:232
358392
msgid ""
359393
":exc:`AttributeError` -- If a failure occurred when traversing the object "
360394
"hierarchy within the imported package to get to the desired object."

0 commit comments

Comments
 (0)