diff --git a/library/tarfile.po b/library/tarfile.po index b62237dea7..3d7e0cb949 100644 --- a/library/tarfile.po +++ b/library/tarfile.po @@ -3,6 +3,7 @@ # # Translators: # Adrian Liaw , 2018 +# Matt Wang , 2025 msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" @@ -33,16 +34,21 @@ msgid "" "module to read or write :file:`.zip` files, or the higher-level functions " "in :ref:`shutil `." msgstr "" +":mod:`tarfile` 模組用於讀取與寫入 tar 封存檔案,包括使用 gzip、bz2 和 lzma " +"壓縮的檔案。使用 :mod:`zipfile` 模組來讀取或寫入 :file:`.zip` 檔案,或使用 " +":ref:`shutil ` 中的更高階函式。" #: ../../library/tarfile.rst:19 msgid "Some facts and figures:" -msgstr "" +msgstr "一些事實和數據:" #: ../../library/tarfile.rst:21 msgid "" "reads and writes :mod:`gzip`, :mod:`bz2`, :mod:`compression.zstd`, and :mod:" "`lzma` compressed archives if the respective modules are available." msgstr "" +"若相對應的模組可用,則可讀取與寫入 :mod:`gzip`、:mod:`bz2`、:mod:`compression.zstd` 和 " +":mod:`lzma` 壓縮的封存檔。" #: ../../library/tarfile.rst:27 msgid "" @@ -51,10 +57,13 @@ msgid "" "whoever provided Python to you). If you are the distributor, see :ref:" "`optional-module-requirements`." msgstr "" +"如果你的 CPython 副本中缺少這些\\ :term:`選用模組 (optional modules) `," +"請查閱你的發行者(即提供 Python 給你的人)的文件。如果你就是發行者,請參閱 " +":ref:`optional-module-requirements`。" #: ../../library/tarfile.rst:32 msgid "read/write support for the POSIX.1-1988 (ustar) format." -msgstr "" +msgstr "支援 POSIX.1-1988 (ustar) 格式的讀取與寫入。" #: ../../library/tarfile.rst:34 msgid "" @@ -62,10 +71,12 @@ msgid "" "*longlink* extensions, read-only support for all variants of the *sparse* " "extension including restoration of sparse files." msgstr "" +"支援 GNU tar 格式的讀取與寫入,包括 *longname* 和 *longlink* 擴充功能,以及所有 *sparse* " +"擴充功能變體的唯讀支援,包括還原稀疏檔案 (sparse files)。" #: ../../library/tarfile.rst:38 msgid "read/write support for the POSIX.1-2001 (pax) format." -msgstr "" +msgstr "支援 POSIX.1-2001 (pax) 格式的讀取與寫入。" #: ../../library/tarfile.rst:40 msgid "" @@ -73,6 +84,9 @@ msgid "" "character devices and block devices and is able to acquire and restore file " "information like timestamp, access permissions and owner." msgstr "" +"處理目錄、一般檔案、硬連結 (hardlinks)、符號連結 (symbolic links)、fifos、字元裝置 " +"(character devices) 和區塊裝置 (block devices),並能夠取得與還原檔案資訊,如時間戳記" +"、存取權限和擁有者。" #: ../../library/tarfile.rst:44 msgid "Added support for :mod:`lzma` compression." @@ -84,6 +98,8 @@ msgid "" "which makes it possible to either limit surprising/dangerous features, or to " "acknowledge that they are expected and the archive is fully trusted." msgstr "" +"解壓縮封存檔時會使用\\ :ref:`篩選器 (filter) `," +"你可以用它來限制一些意外或危險的功能,或是明確表示這些功能是你預期的,而且封存檔是完全可信任的。" #: ../../library/tarfile.rst:52 msgid "" @@ -92,6 +108,8 @@ msgid "" "outside of the destination. Previously, the filter strategy was equivalent " "to :func:`fully_trusted `." msgstr "" +"將預設解壓縮篩選器設為 :func:`data `,這會禁止一些危險的功能,例如指向絕對" +"路徑或目的地之外路徑的連結。在此之前,篩選器策略等同於 :func:`fully_trusted `。" #: ../../library/tarfile.rst:60 msgid "Added support for Zstandard compression using :mod:`compression.zstd`." @@ -103,6 +121,8 @@ msgid "" "information on :class:`TarFile` objects and the keyword arguments that are " "allowed, see :ref:`tarfile-objects`." msgstr "" +"回傳路徑名稱 *name* 的 :class:`TarFile` 物件。關於 :class:`TarFile` 物件與允許的" +"關鍵字引數的詳細資訊,請參閱 :ref:`tarfile-objects`。" #: ../../library/tarfile.rst:68 msgid "" @@ -126,7 +146,7 @@ msgstr "``'r'`` 或 ``'r:*'``" #: ../../library/tarfile.rst:74 msgid "Open for reading with transparent compression (recommended)." -msgstr "" +msgstr "開啟以讀取,自動偵測壓縮格式(建議使用)。" #: ../../library/tarfile.rst:77 msgid "``'r:'``" @@ -134,7 +154,7 @@ msgstr "``'r:'``" #: ../../library/tarfile.rst:77 msgid "Open for reading exclusively without compression." -msgstr "" +msgstr "開啟以讀取未壓縮的檔案。" #: ../../library/tarfile.rst:80 msgid "``'r:gz'``" @@ -142,7 +162,7 @@ msgstr "``'r:gz'``" #: ../../library/tarfile.rst:80 msgid "Open for reading with gzip compression." -msgstr "開啟以讀取 gzip 壓縮。" +msgstr "開啟以讀取 gzip 壓縮的檔案。" #: ../../library/tarfile.rst:82 msgid "``'r:bz2'``" @@ -150,7 +170,7 @@ msgstr "``'r:bz2'``" #: ../../library/tarfile.rst:82 msgid "Open for reading with bzip2 compression." -msgstr "開啟以讀取 bzip2 壓縮。" +msgstr "開啟以讀取 bzip2 壓縮的檔案。" #: ../../library/tarfile.rst:84 msgid "``'r:xz'``" @@ -158,7 +178,7 @@ msgstr "``'r:xz'``" #: ../../library/tarfile.rst:84 msgid "Open for reading with lzma compression." -msgstr "開啟以讀取 lzma 壓縮。" +msgstr "開啟以讀取 lzma 壓縮的檔案。" #: ../../library/tarfile.rst:86 msgid "``'r:zst'``" @@ -166,7 +186,7 @@ msgstr "``'r:zst'``" #: ../../library/tarfile.rst:86 msgid "Open for reading with Zstandard compression." -msgstr "開啟以讀取 Zstandard 壓縮。" +msgstr "開啟以讀取 Zstandard 壓縮的檔案。" #: ../../library/tarfile.rst:88 msgid "``'x'`` or ``'x:'``" @@ -177,6 +197,7 @@ msgid "" "Create a tarfile exclusively without compression. Raise a :exc:" "`FileExistsError` exception if it already exists." msgstr "" +"建立一個不壓縮的 tarfile(獨佔模式)。如果檔案已存在,則引發 :exc:`FileExistsError` 例外。" #: ../../library/tarfile.rst:93 msgid "``'x:gz'``" @@ -187,6 +208,7 @@ msgid "" "Create a tarfile with gzip compression. Raise a :exc:`FileExistsError` " "exception if it already exists." msgstr "" +"建立一個使用 gzip 壓縮的 tar 檔案。如果檔案已存在則引發 :exc:`FileExistsError` 例外。" #: ../../library/tarfile.rst:97 msgid "``'x:bz2'``" @@ -196,7 +218,7 @@ msgstr "``'x:bz2'``" msgid "" "Create a tarfile with bzip2 compression. Raise a :exc:`FileExistsError` " "exception if it already exists." -msgstr "" +msgstr "建立一個使用 bzip2 壓縮的 tar 檔案。如果檔案已存在,則引發 :exc:`FileExistsError` 例外。" #: ../../library/tarfile.rst:101 msgid "``'x:xz'``" @@ -207,6 +229,7 @@ msgid "" "Create a tarfile with lzma compression. Raise a :exc:`FileExistsError` " "exception if it already exists." msgstr "" +"建立一個使用 lzma 壓縮的 tar 檔案。如果檔案已存在,則引發 :exc:`FileExistsError` 例外。" #: ../../library/tarfile.rst:105 msgid "``'x:zst'``" @@ -217,6 +240,8 @@ msgid "" "Create a tarfile with Zstandard compression. Raise a :exc:`FileExistsError` " "exception if it already exists." msgstr "" +"建立一個使用 Zstandard 壓縮的 tar 檔案。如果檔案已存在,則引發 " +":exc:`FileExistsError` 例外。" #: ../../library/tarfile.rst:109 msgid "``'a'`` or ``'a:'``" @@ -226,7 +251,7 @@ msgstr "``'a'`` 或 ``'a:'``" msgid "" "Open for appending with no compression. The file is created if it does not " "exist." -msgstr "" +msgstr "開啟以附加內容且不使用壓縮。如果檔案不存在則建立它。" #: ../../library/tarfile.rst:112 msgid "``'w'`` or ``'w:'``" @@ -234,7 +259,7 @@ msgstr "``'w'`` 或 ``'w:'``" #: ../../library/tarfile.rst:112 msgid "Open for uncompressed writing." -msgstr "" +msgstr "開啟以寫入未壓縮的內容。" #: ../../library/tarfile.rst:115 msgid "``'w:gz'``" @@ -242,7 +267,7 @@ msgstr "``'w:gz'``" #: ../../library/tarfile.rst:115 msgid "Open for gzip compressed writing." -msgstr "開啟以用於 gzip 壓縮寫入。" +msgstr "開啟以進行 gzip 壓縮寫入。" #: ../../library/tarfile.rst:117 msgid "``'w:bz2'``" @@ -250,7 +275,7 @@ msgstr "``'w:bz2'``" #: ../../library/tarfile.rst:117 msgid "Open for bzip2 compressed writing." -msgstr "開啟以用於 bzip2 壓縮寫入。" +msgstr "開啟以進行 bzip2 壓縮寫入。" #: ../../library/tarfile.rst:119 msgid "``'w:xz'``" @@ -258,7 +283,7 @@ msgstr "``'w:xz'``" #: ../../library/tarfile.rst:119 msgid "Open for lzma compressed writing." -msgstr "開啟以用於 lzma 壓縮寫入。" +msgstr "開啟以進行 lzma 壓縮寫入。" #: ../../library/tarfile.rst:121 msgid "``'w:zst'``" @@ -266,7 +291,7 @@ msgstr "``'w:zst'``" #: ../../library/tarfile.rst:121 msgid "Open for Zstandard compressed writing." -msgstr "開啟以用於 Zstandard 壓縮寫入。" +msgstr "開啟以進行 Zstandard 壓縮寫入。" #: ../../library/tarfile.rst:124 msgid "" @@ -275,12 +300,17 @@ msgid "" "`ReadError` is raised. Use *mode* ``'r'`` to avoid this. If a compression " "method is not supported, :exc:`CompressionError` is raised." msgstr "" +"請注意 ``'a:gz'``、``'a:bz2'`` 或 ``'a:xz'`` 是不可能的。如果 *mode* " +"不適合開啟特定(壓縮)檔案以進行讀取,則會引發 :exc:`ReadError`。使用 *mode* ``'r'`` " +"可避免此問題。如果不支援某個壓縮方法,則會引發 :exc:`CompressionError`。" #: ../../library/tarfile.rst:129 msgid "" "If *fileobj* is specified, it is used as an alternative to a :term:`file " "object` opened in binary mode for *name*. It is supposed to be at position 0." msgstr "" +"如果指定了 *fileobj*,則它會被用作 *name* 以二進位模式開啟的\\ :term:`檔案物件 ` " +"的替代方案。它應該位於位置 0。" #: ../../library/tarfile.rst:132 msgid "" @@ -288,6 +318,8 @@ msgid "" "bz2'``, :func:`tarfile.open` accepts the keyword argument *compresslevel* " "(default ``9``) to specify the compression level of the file." msgstr "" +"對於模式 ``'w:gz'``、``'x:gz'``、``'w|gz'``、``'w:bz2'``、``'x:bz2'``、``'w|bz2'``," +":func:`tarfile.open` 接受關鍵字引數 *compresslevel*\\ (預設為 ``9``)來指定檔案的壓縮等級。" #: ../../library/tarfile.rst:136 msgid "" @@ -295,6 +327,8 @@ msgid "" "accepts the keyword argument *preset* to specify the compression level of " "the file." msgstr "" +"對於模式 ``'w:xz'``、``'x:xz'`` 和 ``'w|xz'``,:func:`tarfile.open` 接受關鍵字引數 " +"*preset* 來指定檔案的壓縮等級。" #: ../../library/tarfile.rst:139 msgid "" @@ -306,6 +340,10 @@ msgid "" "provide a :class:`~compression.zstd.ZstdDict`, a Zstandard dictionary used " "to improve compression of smaller amounts of data." msgstr "" +"對於模式 ``'w:zst'``、``'x:zst'`` 和 ``'w|zst'``,:func:`tarfile.open` 接受關鍵字引數 " +"*level* 來指定檔案的壓縮等級。也可以傳遞關鍵字引數 *options*,提供由 :class:`~compression.zstd." +"CompressionParameter` 描述的進階 Zstandard 壓縮參數。可以傳遞關鍵字引數 *zstd_dict* 以提供 " +":class:`~compression.zstd.ZstdDict`,這是一個用於改善較小資料量壓縮效果的 Zstandard 字典。" #: ../../library/tarfile.rst:148 msgid "" @@ -320,6 +358,12 @@ msgid "" "However, such a :class:`TarFile` object is limited in that it does not allow " "random access, see :ref:`tar-examples`. The currently possible modes:" msgstr "" +"對於特殊用途,*mode* 有第二種格式:``'filemode|[compression]'``。:func:`tarfile.open` 會回傳一個 " +":class:`TarFile` 物件,該物件將其資料作為區塊串流處理。不會對檔案進行隨機尋找。如果提供了 *fileobj*,它可以" +"是任何具有 :meth:`~io.RawIOBase.read` 或 :meth:`~io.RawIOBase.write` 方法(取決於 " +"*mode*)且能處理位元組的物件。*bufsize* 指定區塊大小,預設為 ``20 * 512`` 位元組。此變體可與 " +"``sys.stdin.buffer``、socket :term:`檔案物件 ` 或磁帶裝置等結合使用。但是,這樣的 " +":class:`TarFile` 物件受到限制,因為它不允許隨機存取,請參閱 :ref:`tar-examples`。目前可能的模式:" #: ../../library/tarfile.rst:162 msgid "Mode" @@ -335,7 +379,7 @@ msgstr "``'r|*'``" #: ../../library/tarfile.rst:164 msgid "Open a *stream* of tar blocks for reading with transparent compression." -msgstr "" +msgstr "開啟以讀取 tar 區塊的\\ *串流*,自動偵測壓縮格式。" #: ../../library/tarfile.rst:167 msgid "``'r|'``" @@ -343,7 +387,7 @@ msgstr "``'r|'``" #: ../../library/tarfile.rst:167 msgid "Open a *stream* of uncompressed tar blocks for reading." -msgstr "" +msgstr "開啟以讀取未壓縮的 tar 區塊\\ *串流*。" #: ../../library/tarfile.rst:170 msgid "``'r|gz'``" @@ -351,7 +395,7 @@ msgstr "``'r|gz'``" #: ../../library/tarfile.rst:170 msgid "Open a gzip compressed *stream* for reading." -msgstr "" +msgstr "開啟以讀取 gzip 壓縮的\\ *串流*。" #: ../../library/tarfile.rst:173 msgid "``'r|bz2'``" @@ -359,7 +403,7 @@ msgstr "``'r|bz2'``" #: ../../library/tarfile.rst:173 msgid "Open a bzip2 compressed *stream* for reading." -msgstr "" +msgstr "開啟以讀取 bzip2 壓縮的\\ *串流*。" #: ../../library/tarfile.rst:176 msgid "``'r|xz'``" @@ -367,7 +411,7 @@ msgstr "``'r|xz'``" #: ../../library/tarfile.rst:176 msgid "Open an lzma compressed *stream* for reading." -msgstr "" +msgstr "開啟以讀取 lzma 壓縮的\\ *串流*。" #: ../../library/tarfile.rst:179 msgid "``'r|zst'``" @@ -375,7 +419,7 @@ msgstr "``'r|zst'``" #: ../../library/tarfile.rst:179 msgid "Open a Zstandard compressed *stream* for reading." -msgstr "" +msgstr "開啟以讀取 Zstandard 壓縮的\\ *串流*。" #: ../../library/tarfile.rst:182 msgid "``'w|'``" @@ -383,7 +427,7 @@ msgstr "``'w|'``" #: ../../library/tarfile.rst:182 msgid "Open an uncompressed *stream* for writing." -msgstr "" +msgstr "開啟以寫入未壓縮的\\ *串流*。" #: ../../library/tarfile.rst:184 msgid "``'w|gz'``" @@ -391,7 +435,7 @@ msgstr "``'w|gz'``" #: ../../library/tarfile.rst:184 msgid "Open a gzip compressed *stream* for writing." -msgstr "" +msgstr "開啟以寫入 gzip 壓縮的\\ *串流*。" #: ../../library/tarfile.rst:187 msgid "``'w|bz2'``" @@ -399,7 +443,7 @@ msgstr "``'w|bz2'``" #: ../../library/tarfile.rst:187 msgid "Open a bzip2 compressed *stream* for writing." -msgstr "" +msgstr "開啟以寫入 bzip2 壓縮的\\ *串流*。" #: ../../library/tarfile.rst:190 msgid "``'w|xz'``" @@ -407,7 +451,7 @@ msgstr "``'w|xz'``" #: ../../library/tarfile.rst:190 msgid "Open an lzma compressed *stream* for writing." -msgstr "" +msgstr "開啟以寫入 lzma 壓縮的\\ *串流*。" #: ../../library/tarfile.rst:193 msgid "``'w|zst'``" @@ -415,30 +459,32 @@ msgstr "``'w|zst'``" #: ../../library/tarfile.rst:193 msgid "Open a Zstandard compressed *stream* for writing." -msgstr "開啟以用於 Zstandard 壓縮寫入。" +msgstr "開啟以寫入 Zstandard 壓縮的\\ *串流*。" #: ../../library/tarfile.rst:197 ../../library/tarfile.rst:476 msgid "The ``'x'`` (exclusive creation) mode was added." -msgstr "" +msgstr "新增了 ``'x'``\\ (獨佔建立)模式。" #: ../../library/tarfile.rst:200 ../../library/tarfile.rst:479 #: ../../library/tarfile.rst:727 msgid "The *name* parameter accepts a :term:`path-like object`." -msgstr "" +msgstr "*name* 參數接受\\ :term:`類路徑物件 `。" #: ../../library/tarfile.rst:203 msgid "The *compresslevel* keyword argument also works for streams." -msgstr "" +msgstr "*compresslevel* 關鍵字引數也適用於串流。" #: ../../library/tarfile.rst:206 msgid "The *preset* keyword argument also works for streams." -msgstr "" +msgstr "*preset* 關鍵字引數也適用於串流。" #: ../../library/tarfile.rst:213 msgid "" "Class for reading and writing tar archives. Do not use this class directly: " "use :func:`tarfile.open` instead. See :ref:`tarfile-objects`." msgstr "" +"用於讀取和寫入 tar 封存檔的類別。請勿直接使用此類別:請改用 :func:`tarfile.open`。請參閱 :ref:`tarfile-" +"objects`。" #: ../../library/tarfile.rst:219 msgid "" @@ -446,6 +492,8 @@ msgid "" "`tarfile` module can read. *name* may be a :class:`str`, file, or file-like " "object." msgstr "" +"如果 *name* 是一個 :mod:`tarfile` 模組可以讀取的 tar 封存檔,則回傳 :const:`True`。*name* 可以是 " +":class:`str`、檔案或類檔案物件。" #: ../../library/tarfile.rst:222 msgid "Support for file and file-like objects." @@ -461,64 +509,66 @@ msgstr "所有 :mod:`tarfile` 例外的基底類別。" #: ../../library/tarfile.rst:236 msgid "" -"Is raised when a tar archive is opened, that either cannot be handled by " -"the :mod:`tarfile` module or is somehow invalid." -msgstr "" +"Is raised when a tar archive is opened, that either cannot be handled by the" +" :mod:`tarfile` module or is somehow invalid." +msgstr "當開啟的 tar 封存檔無法被 :mod:`tarfile` 模組處理或以某種方式無效時引發。" #: ../../library/tarfile.rst:242 msgid "" "Is raised when a compression method is not supported or when the data cannot " "be decoded properly." -msgstr "" +msgstr "當壓縮方法不被支援或資料無法正確解碼時引發。" #: ../../library/tarfile.rst:248 msgid "" "Is raised for the limitations that are typical for stream-like :class:" "`TarFile` objects." -msgstr "" +msgstr "當遇到類似串流的 :class:`TarFile` 物件的典型限制時引發。" #: ../../library/tarfile.rst:254 msgid "" "Is raised for *non-fatal* errors when using :meth:`TarFile.extract`, but " "only if :attr:`TarFile.errorlevel`\\ ``== 2``." msgstr "" +"在使用 :meth:`TarFile.extract` 時針對\\ *非致命*\\ 錯誤引發,但僅限於 " +":attr:`TarFile.errorlevel`\\ ``== 2`` 時。" #: ../../library/tarfile.rst:260 msgid "Is raised by :meth:`TarInfo.frombuf` if the buffer it gets is invalid." -msgstr "" +msgstr "如果 :meth:`TarInfo.frombuf` 得到的緩衝區無效,則引發此例外。" #: ../../library/tarfile.rst:265 msgid "" "Base class for members :ref:`refused ` by filters." -msgstr "" +msgstr "被篩選器\\ :ref:`拒絕 `\\ 的成員的基底類別。" #: ../../library/tarfile.rst:270 msgid "" "Information about the member that the filter refused to extract, as :ref:" "`TarInfo `." -msgstr "" +msgstr "篩選器拒絕解壓縮的成員資訊,以 :ref:`TarInfo ` 表示。" #: ../../library/tarfile.rst:275 msgid "Raised to refuse extracting a member with an absolute path." -msgstr "" +msgstr "當拒絕解壓縮具有絕對路徑的成員時引發。" #: ../../library/tarfile.rst:279 msgid "Raised to refuse extracting a member outside the destination directory." -msgstr "" +msgstr "當拒絕解壓縮位於目的地目錄之外的成員時引發。" #: ../../library/tarfile.rst:283 msgid "Raised to refuse extracting a special file (e.g. a device or pipe)." -msgstr "" +msgstr "當拒絕解壓縮特殊檔案(例如裝置或管道)時引發。" #: ../../library/tarfile.rst:287 msgid "Raised to refuse extracting a symbolic link with an absolute path." -msgstr "" +msgstr "當拒絕解壓縮具有絕對路徑的符號連結時引發。" #: ../../library/tarfile.rst:291 msgid "" "Raised to refuse extracting a symbolic link pointing outside the destination " "directory." -msgstr "" +msgstr "當拒絕解壓縮指向目的地目錄之外的符號連結時引發。" #: ../../library/tarfile.rst:296 msgid "" @@ -527,16 +577,19 @@ msgid "" "The exception that was raised to reject the replacement member is available " "as :attr:`!BaseException.__context__`." msgstr "" +"當透過解壓縮另一個封存檔成員來模擬連結(硬連結或符號連結)時,如果該成員會被篩選器位置拒絕," +"則引發此例外。用於拒絕替代成員的例外可作為 :attr:`!BaseException.__context__` 取得。" #: ../../library/tarfile.rst:304 msgid "The following constants are available at the module level:" -msgstr "" +msgstr "以下常數可在模組層級使用:" #: ../../library/tarfile.rst:308 msgid "" "The default character encoding: ``'utf-8'`` on Windows, the value returned " "by :func:`sys.getfilesystemencoding` otherwise." msgstr "" +"預設字元編碼:在 Windows 上為 ``'utf-8'``,否則為 :func:`sys.getfilesystemencoding` 回傳的值。" #: ../../library/tarfile.rst:314 msgid "A regular file :attr:`~TarInfo.type`." @@ -544,43 +597,43 @@ msgstr "一個普通檔案 :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:318 msgid "A link (inside tarfile) :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個連結(在 tar 檔案內)\\ :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:322 msgid "A symbolic link :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個符號連結 :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:326 msgid "A character special device :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個字元特殊裝置 :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:330 msgid "A block special device :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個區塊特殊裝置 :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:334 msgid "A directory :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個目錄 :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:338 msgid "A FIFO special device :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個 FIFO 特殊裝置 :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:342 msgid "A contiguous file :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個連續檔案 :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:346 msgid "A GNU tar longname :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個 GNU tar longname :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:350 msgid "A GNU tar longlink :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個 GNU tar longlink :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:354 msgid "A GNU tar sparse file :attr:`~TarInfo.type`." -msgstr "" +msgstr "一個 GNU tar 稀疏檔案 :attr:`~TarInfo.type`。" #: ../../library/tarfile.rst:357 msgid "" @@ -588,6 +641,7 @@ msgid "" "`tarfile` module is able to create. See section :ref:`tar-formats` for " "details." msgstr "" +"以下每個常數定義了 :mod:`tarfile` 模組能夠建立的 tar 封存檔格式。詳細資訊請參閱 :ref:`tar-formats` 一節。" #: ../../library/tarfile.rst:364 msgid "POSIX.1-1988 (ustar) format." @@ -605,13 +659,13 @@ msgstr "POSIX.1-2001 (pax) 格式。" msgid "" "The default format for creating archives. This is currently :const:" "`PAX_FORMAT`." -msgstr "" +msgstr "建立封存檔的預設格式。目前為 :const:`PAX_FORMAT`。" #: ../../library/tarfile.rst:381 msgid "" "The default format for new archives was changed to :const:`PAX_FORMAT` from :" "const:`GNU_FORMAT`." -msgstr "" +msgstr "新封存檔的預設格式已從 :const:`GNU_FORMAT` 變更為 :const:`PAX_FORMAT`。" #: ../../library/tarfile.rst:388 msgid "Module :mod:`zipfile`" @@ -629,17 +683,19 @@ msgstr ":ref:`archiving-operations`" msgid "" "Documentation of the higher-level archiving facilities provided by the " "standard :mod:`shutil` module." -msgstr "" +msgstr "標準 :mod:`shutil` 模組所提供的更高階封存功能的文件。" #: ../../library/tarfile.rst:395 msgid "" -"`GNU tar manual, Basic Tar Format `_" +"`GNU tar manual, Basic Tar Format " +"`_" msgstr "" +"`GNU tar 手冊,基本 Tar 格式 " +"`_" #: ../../library/tarfile.rst:396 msgid "Documentation for tar archive files, including GNU tar extensions." -msgstr "" +msgstr "tar 封存檔案的文件,包括 GNU tar 擴充功能。" #: ../../library/tarfile.rst:402 msgid "TarFile Objects" @@ -653,6 +709,9 @@ msgid "" "in a tar archive several times. Each archive member is represented by a :" "class:`TarInfo` object, see :ref:`tarinfo-objects` for details." msgstr "" +":class:`TarFile` 物件提供一個 tar 封存檔的介面。tar 封存檔是一個區塊序列。" +"一個封存檔成員(一個儲存的檔案)由一個標頭區塊和後續的資料區塊組成。可以在 tar 封存檔中多次" +"儲存一個檔案。每個封存檔成員由一個 :class:`TarInfo` 物件表示,詳細資訊請參閱 :ref:`tarinfo-objects`。" #: ../../library/tarfile.rst:410 msgid "" @@ -662,6 +721,9 @@ msgid "" "for writing will not be finalized; only the internally used file object will " "be closed. See the :ref:`tar-examples` section for a use case." msgstr "" +":class:`TarFile` 物件可以在 :keyword:`with` 陳述式中用作情境管理器。當區塊完成時," +"它會自動關閉。請注意,如果發生例外,以寫入方式開啟的封存檔將不會被最終化 (finalized);只有內部使用的檔案" +"物件會被關閉。使用案例請參閱 :ref:`tar-examples` 一節。" #: ../../library/tarfile.rst:416 msgid "Added support for the context management protocol." @@ -671,7 +733,7 @@ msgstr "新增對情境管理協定的支援。" msgid "" "All following arguments are optional and can be accessed as instance " "attributes as well." -msgstr "" +msgstr "以下所有引數都是可選的,也可以作為實例屬性存取。" #: ../../library/tarfile.rst:424 msgid "" @@ -679,6 +741,8 @@ msgid "" "object`. It can be omitted if *fileobj* is given. In this case, the file " "object's :attr:`!name` attribute is used if it exists." msgstr "" +"*name* 是封存檔的路徑名稱。*name* 可以是\\ :term:`類路徑物件 `。如果提供了 " +"*fileobj* 則可以省略它。在這種情況下,如果檔案物件的 :attr:`!name` 屬性存在,則會使用該屬性。" #: ../../library/tarfile.rst:428 msgid "" @@ -687,6 +751,8 @@ msgid "" "existing one, or ``'x'`` to create a new file only if it does not already " "exist." msgstr "" +"*mode* 可以是 ``'r'`` 以從現有封存檔讀取、``'a'`` 以附加資料到現有檔案、``'w'`` 以建立新檔案覆蓋現有檔案,或 " +"``'x'`` 以僅在檔案不存在時建立新檔案。" #: ../../library/tarfile.rst:432 msgid "" @@ -694,10 +760,12 @@ msgid "" "determined, *mode* is overridden by *fileobj*'s mode. *fileobj* will be used " "from position 0." msgstr "" +"如果提供了 *fileobj*,它會被用於讀取或寫入資料。如果可以確定,*mode* 會被 *fileobj* 的模式覆蓋。*fileobj* 將從位置" +" 0 開始使用。" #: ../../library/tarfile.rst:438 msgid "*fileobj* is not closed, when :class:`TarFile` is closed." -msgstr "" +msgstr "當 :class:`TarFile` 關閉時,*fileobj* 不會被關閉。" #: ../../library/tarfile.rst:440 msgid "" @@ -706,12 +774,15 @@ msgid "" "that are defined at module level. When reading, format will be automatically " "detected, even if different formats are present in a single archive." msgstr "" +"*format* 控制寫入時的封存檔格式。它必須是在模組層級定義的常數 " +":const:`USTAR_FORMAT`、:const:`GNU_FORMAT` 或 :const:`PAX_FORMAT` " +"之一。讀取時,即使單一封存檔中存在不同格式,格式也會自動偵測。" #: ../../library/tarfile.rst:445 msgid "" "The *tarinfo* argument can be used to replace the default :class:`TarInfo` " "class with a different one." -msgstr "" +msgstr "*tarinfo* 引數可用於將預設的 :class:`TarInfo` 類別替換為不同的類別。" #: ../../library/tarfile.rst:448 msgid "" @@ -719,6 +790,8 @@ msgid "" "archive. If it is :const:`True`, add the content of the target files to the " "archive. This has no effect on systems that do not support symbolic links." msgstr "" +"如果 *dereference* 為 :const:`False`,則將符號連結和硬連結新增到封存檔。如果為 " +":const:`True`,則將目標檔案的內容新增到封存檔。這在不支援符號連結的系統上沒有效果。" #: ../../library/tarfile.rst:452 msgid "" @@ -727,18 +800,20 @@ msgid "" "get as many members as possible. This is only useful for reading " "concatenated or damaged archives." msgstr "" +"如果 *ignore_zeros* 為 :const:`False`,則將空區塊視為封存檔的結尾。如果為 " +":const:`True`,則跳過空的(和無效的)區塊並嘗試取得盡可能多的成員。這僅對讀取串聯或損壞的封存檔有用。" #: ../../library/tarfile.rst:456 msgid "" "*debug* can be set from ``0`` (no debug messages) up to ``3`` (all debug " "messages). The messages are written to ``sys.stderr``." -msgstr "" +msgstr "*debug* 可設定從 ``0``\\ (無偵錯訊息)到 ``3``\\ (所有偵錯訊息)。訊息會寫入 ``sys.stderr``。" #: ../../library/tarfile.rst:459 msgid "" "*errorlevel* controls how extraction errors are handled, see :attr:`the " "corresponding attribute `." -msgstr "" +msgstr "*errorlevel* 控制如何處理解壓縮錯誤,請參閱\\ :attr:`對應的屬性 `。" #: ../../library/tarfile.rst:462 msgid "" @@ -747,18 +822,22 @@ msgid "" "to be handled. The default settings will work for most users. See section :" "ref:`tar-unicode` for in-depth information." msgstr "" +"*encoding* 和 *errors* 引數定義用於讀取或寫入封存檔的字元編碼以及如何處理轉換錯誤。" +"預設設定適用於大多數使用者。深入資訊請參閱 :ref:`tar-unicode` 一節。" #: ../../library/tarfile.rst:467 msgid "" "The *pax_headers* argument is an optional dictionary of strings which will " "be added as a pax global header if *format* is :const:`PAX_FORMAT`." msgstr "" +"*pax_headers* 引數是一個可選的字串字典,如果 *format* 為 :const:`PAX_FORMAT`,則會作為 pax " +"全域標頭新增。" #: ../../library/tarfile.rst:470 msgid "" "If *stream* is set to :const:`True` then while reading the archive info " "about files in the archive are not cached, saving memory." -msgstr "" +msgstr "如果 *stream* 設為 :const:`True`,則讀取封存檔時不會快取封存檔中關於檔案的資訊,從而節省記憶體。" #: ../../library/tarfile.rst:473 ../../library/tarfile.rst:796 msgid "Use ``'surrogateescape'`` as the default for the *errors* argument." @@ -772,31 +851,32 @@ msgstr "新增 *stream* 參數。" msgid "" "Alternative constructor. The :func:`tarfile.open` function is actually a " "shortcut to this classmethod." -msgstr "" +msgstr "替代建構函式。:func:`tarfile.open` 函式實際上是此類別方法的捷徑。" #: ../../library/tarfile.rst:493 msgid "" "Return a :class:`TarInfo` object for member *name*. If *name* can not be " "found in the archive, :exc:`KeyError` is raised." msgstr "" +"回傳成員 *name* 的 :class:`TarInfo` 物件。如果在封存檔中找不到 *name*,則引發 :exc:`KeyError`。" #: ../../library/tarfile.rst:498 msgid "" "If a member occurs more than once in the archive, its last occurrence is " "assumed to be the most up-to-date version." -msgstr "" +msgstr "如果一個成員在封存檔中出現多次,則假定其最後一次出現是最新版本。" #: ../../library/tarfile.rst:504 msgid "" -"Return the members of the archive as a list of :class:`TarInfo` objects. The " -"list has the same order as the members in the archive." -msgstr "" +"Return the members of the archive as a list of :class:`TarInfo` objects. The" +" list has the same order as the members in the archive." +msgstr "以 :class:`TarInfo` 物件串列的形式回傳封存檔的成員。串列的順序與封存檔中成員的順序相同。" #: ../../library/tarfile.rst:510 msgid "" "Return the members as a list of their names. It has the same order as the " "list returned by :meth:`getmembers`." -msgstr "" +msgstr "以名稱串列的形式回傳成員。其順序與 :meth:`getmembers` 回傳的串列順序相同。" #: ../../library/tarfile.rst:516 msgid "" @@ -805,6 +885,9 @@ msgid "" "similar to that of :program:`ls -l` is produced. If optional *members* is " "given, it must be a subset of the list returned by :meth:`getmembers`." msgstr "" +"將內容表印出到 ``sys.stdout``。如果 *verbose* 為 :const:`False`,則只印出成員的名稱。如果為 " +":const:`True`,則產生類似於 :program:`ls -l` 的輸出。如果提供了可選的 *members*,它必須是 " +":meth:`getmembers` 回傳串列的子集合。" #: ../../library/tarfile.rst:521 msgid "Added the *members* parameter." @@ -816,6 +899,8 @@ msgid "" "class:`TarFile` is opened for reading. Return :const:`None` if there is no " "more available." msgstr "" +"當 :class:`TarFile` 以讀取方式開啟時,以 :class:`TarInfo` " +"物件的形式回傳封存檔的下一個成員。如果沒有更多成員可用,則回傳 :const:`None`。" #: ../../library/tarfile.rst:534 msgid "" @@ -828,6 +913,10 @@ msgid "" "directory's permissions do not allow writing, extracting files to it will " "fail." msgstr "" +"將所有成員從封存檔解壓縮到目前的工作目錄或目錄 *path*。如果提供了可選的 *members*," +"它必須是 :meth:`getmembers` 回傳串列的子集合。目錄資訊(如擁有者、修改時間和權限)" +"會在所有成員都被解壓縮後設定。這樣做是為了解決兩個問題:每次在目錄中建立檔案時,目錄的修改" +"時間都會被重設。而且,如果目錄的權限不允許寫入,則無法將檔案解壓縮到其中。" #: ../../library/tarfile.rst:542 msgid "" @@ -835,6 +924,8 @@ msgid "" "tarfile are used to set the owner/group for the extracted files. Otherwise, " "the named values from the tarfile are used." msgstr "" +"如果 *numeric_owner* 為 :const:`True`,則使用 tar 檔案中的 uid 和 gid " +"數字來設定解壓縮檔案的擁有者/群組。否則,使用 tar 檔案中的名稱值。" #: ../../library/tarfile.rst:546 msgid "" @@ -844,10 +935,13 @@ msgid "" "required, or as ``filter='data'`` to support Python versions with a less " "secure default (3.13 and lower)." msgstr "" +"*filter* 引數指定在解壓縮之前如何修改或拒絕 ``members``。詳細資訊請參閱 :ref:`tarfile-extraction-" +"filter`。建議僅在需要特定 *tar* 功能時或作為 ``filter='data'`` 以支援預設安全性較低的 Python 版本(3.13 " +"及更低版本)時明確設定此項。" #: ../../library/tarfile.rst:555 msgid "Never extract archives from untrusted sources without prior inspection." -msgstr "" +msgstr "切勿在未事先檢查的情況下解壓縮來自不受信任來源的封存檔。" #: ../../library/tarfile.rst:557 msgid "" @@ -856,6 +950,8 @@ msgid "" "unintended or insecure behavior. Read the :ref:`tarfile-extraction-filter` " "section for details." msgstr "" +"從 Python 3.14 開始,預設值(:func:`data `)將防止最危險的安全問題。但是,它不會防止\\ " +"*所有*\\ 意外或不安全的行為。詳細資訊請閱讀 :ref:`tarfile-extraction-filter` 一節。" #: ../../library/tarfile.rst:562 ../../library/tarfile.rst:599 msgid "Added the *numeric_owner* parameter." @@ -863,7 +959,7 @@ msgstr "新增 *numeric_owner* 參數。" #: ../../library/tarfile.rst:565 ../../library/tarfile.rst:602 msgid "The *path* parameter accepts a :term:`path-like object`." -msgstr "" +msgstr "*path* 參數接受\\ :term:`類路徑物件 `。" #: ../../library/tarfile.rst:568 ../../library/tarfile.rst:605 #: ../../library/tarfile.rst:689 @@ -872,7 +968,7 @@ msgstr "新增 *filter* 參數。" #: ../../library/tarfile.rst:571 msgid "The *filter* parameter now defaults to ``'data'``." -msgstr "" +msgstr "*filter* 參數現在預設為 ``'data'``。" #: ../../library/tarfile.rst:577 msgid "" @@ -882,24 +978,27 @@ msgid "" "different directory using *path*. *path* may be a :term:`path-like object`. " "File attributes (owner, mtime, mode) are set unless *set_attrs* is false." msgstr "" +"使用完整名稱將一個成員從封存檔解壓縮到目前的工作目錄。其檔案資訊會盡可能準確地解壓縮。*member* 可以是檔案名稱或 " +":class:`TarInfo` 物件。你可以使用 *path* 指定不同的目錄。*path* 可以是\\ :term:`類路徑物件 `。除非 *set_attrs* 為 false,否則會設定檔案屬性 (owner, mtime, mode)。" #: ../../library/tarfile.rst:583 msgid "" "The *numeric_owner* and *filter* arguments are the same as for :meth:" "`extractall`." -msgstr "" +msgstr "*numeric_owner* 和 *filter* 引數與 :meth:`extractall` 相同。" #: ../../library/tarfile.rst:588 msgid "" "The :meth:`extract` method does not take care of several extraction issues. " "In most cases you should consider using the :meth:`extractall` method." -msgstr "" +msgstr ":meth:`extract` 方法不處理多個解壓縮問題。在大多數情況下,你應該考慮使用 :meth:`extractall` 方法。" #: ../../library/tarfile.rst:593 msgid "" "Never extract archives from untrusted sources without prior inspection. See " "the warning for :meth:`extractall` for details." -msgstr "" +msgstr "切勿在事先檢查之前從不受信任的來源解壓縮封存檔。詳細資訊請參閱 :meth:`extractall` 的警告。" #: ../../library/tarfile.rst:596 msgid "Added the *set_attrs* parameter." @@ -913,16 +1012,20 @@ msgid "" "existing members, :const:`None` is returned. If *member* does not appear in " "the archive, :exc:`KeyError` is raised." msgstr "" +"以檔案物件的形式從封存檔解壓縮一個成員。*member* 可以是檔案名稱或 :class:`TarInfo` 物件。如果 *member* " +"是一般檔案或連結,則回傳 :class:`io.BufferedReader` 物件。對於所有其他現有成員,回傳 :const:`None`。如果 " +"*member* 未出現在封存檔中,則引發 :exc:`KeyError`。" #: ../../library/tarfile.rst:617 msgid "Return an :class:`io.BufferedReader` object." -msgstr "" +msgstr "回傳 :class:`io.BufferedReader` 物件。" #: ../../library/tarfile.rst:620 msgid "" "The returned :class:`io.BufferedReader` object has the :attr:`!mode` " "attribute which is always equal to ``'rb'``." msgstr "" +"回傳的 :class:`io.BufferedReader` 物件具有 :attr:`!mode` 屬性,該屬性始終等於 ``'rb'``。" #: ../../library/tarfile.rst:627 msgid "" @@ -933,12 +1036,16 @@ msgid "" "`FilterError` exceptions. If ``2``, all *non-fatal* errors are raised as :" "exc:`TarError` exceptions as well." msgstr "" +"如果 *errorlevel* 為 ``0``,則使用 :meth:`TarFile.extract` 和 :meth:`TarFile.extractall` " +"時會忽略錯誤。然而,當 *debug* 大於 0 時,它們會在偵錯輸出中顯示為錯誤訊息。如果為 ``1``\\ (預設值)" +",所有\\ *致命*\\ 錯誤都會以 :exc:`OSError` 或 :exc:`FilterError` 例外的形式引發。如果為" +" ``2``,所有\\ *非致命*\\ 錯誤也會以 :exc:`TarError` 例外的形式引發。" #: ../../library/tarfile.rst:635 msgid "" "Some exceptions, e.g. ones caused by wrong argument types or data " "corruption, are always raised." -msgstr "" +msgstr "某些例外,例如由錯誤的引數型別或資料損壞引起的例外,總是會被引發。" #: ../../library/tarfile.rst:638 msgid "" @@ -946,12 +1053,14 @@ msgid "" "exc:`FilterError` for *fatal* errors and :exc:`ExtractError` for *non-fatal* " "ones." msgstr "" +"自訂的\\ :ref:`解壓縮篩選器 `\\ 應該對\\ *致命*\\ 錯誤引發 " +":exc:`FilterError`,對\\ *非致命*\\ 錯誤引發 :exc:`ExtractError`。" #: ../../library/tarfile.rst:642 msgid "" "Note that when an exception is raised, the archive may be partially " "extracted. It is the user’s responsibility to clean up." -msgstr "" +msgstr "請注意,當引發例外時,封存檔可能已部分解壓縮。清理是使用者的責任。" #: ../../library/tarfile.rst:649 msgid "" @@ -959,18 +1068,24 @@ msgid "" "for the *filter* argument of :meth:`~TarFile.extract` and :meth:`~TarFile." "extractall`." msgstr "" +"用作 :meth:`~TarFile.extract` 和 :meth:`~TarFile.extractall` 的 *filter* " +"引數預設的\\ :ref:`解壓縮篩選器 `。" #: ../../library/tarfile.rst:653 msgid "" "The attribute may be ``None`` or a callable. String names are not allowed " "for this attribute, unlike the *filter* argument to :meth:`~TarFile.extract`." msgstr "" +"此屬性可以是 ``None`` 或可呼叫物件。與 :meth:`~TarFile.extract` 的 *filter* " +"引數不同,此屬性不允許使用字串名稱。" #: ../../library/tarfile.rst:657 msgid "" "If ``extraction_filter`` is ``None`` (the default), extraction methods will " "use the :func:`data ` filter by default." msgstr "" +"如果 ``extraction_filter`` 為 ``None``\\ (預設值),解壓縮方法將預設使用 :func:`data " +"` 篩選器。" #: ../../library/tarfile.rst:660 msgid "" @@ -981,6 +1096,10 @@ msgid "" "`. To set a global default this way, a filter function needs to be " "wrapped in :func:`staticmethod` to prevent injection of a ``self`` argument." msgstr "" +"此屬性可以在實例上設定或在子類別中覆寫。也可以在 ``TarFile`` 類別本身上設定它以設定全域預設值," +"儘管由於它會影響 *tarfile* 的所有使用,最佳做法是僅在頂層應用程式或 :mod:`site 組態 `\\ " +"中這樣做。要以這種方式設定全域預設值,需要將篩選器函式包裝在 :func:`staticmethod` 中以防止注入 " +"``self`` 引數。" #: ../../library/tarfile.rst:670 msgid "" @@ -989,6 +1108,9 @@ msgid "" "the destination. Previously, the default was equivalent to :func:" "`fully_trusted `." msgstr "" +"預設篩選器設為 :func:`data " +"`,這會禁止一些危險的功能,例如指向絕對路徑或目的地之外路徑的連結。在此之前,預設值等同於 " +":func:`fully_trusted `。" #: ../../library/tarfile.rst:678 msgid "" @@ -1002,10 +1124,15 @@ msgid "" "`None` the :class:`TarInfo` object will be excluded from the archive. See :" "ref:`tar-examples` for an example." msgstr "" +"將檔案 *name* 新增到封存檔。*name* 可以是任何型別的檔案(目錄、FIFO、符號連結等)。如果提供了 " +"*arcname*,則為封存檔中的檔案指定替代名稱。預設情況下,目錄會遞迴新增。這可以透過將 *recursive* 設為 :const:`False`" +" 來避免。遞迴以排序順序新增條目。如果提供了 *filter*,它應該是一個接受 :class:`TarInfo` 物件引數並回傳變更後的 " +":class:`TarInfo` 物件的函式。如果它回傳 :const:`None`,則 :class:`TarInfo` " +"物件將從封存檔中排除。範例請參閱 :ref:`tar-examples`。" #: ../../library/tarfile.rst:692 msgid "Recursion adds entries in sorted order." -msgstr "" +msgstr "遞迴以排序後的順序新增條目。" #: ../../library/tarfile.rst:698 msgid "" @@ -1015,10 +1142,13 @@ msgid "" "the archive. You can create :class:`TarInfo` objects directly, or by using :" "meth:`gettarinfo`." msgstr "" +"將 :class:`TarInfo` 物件 *tarinfo* 新增到封存檔。如果 *tarinfo* 表示一個非零大小的一般檔案," +"*fileobj* 引數應該是\\ :term:`二進位檔案 `,並從中讀取 ``tarinfo.size`` " +"位元組並新增到封存檔。你可以直接建立 :class:`TarInfo` 物件,或使用 :meth:`gettarinfo`。" #: ../../library/tarfile.rst:705 msgid "*fileobj* must be given for non-zero-sized regular files." -msgstr "" +msgstr "對於非零大小的一般檔案,必須提供 *fileobj*。" #: ../../library/tarfile.rst:710 msgid "" @@ -1030,6 +1160,10 @@ msgid "" "from *fileobj*’s :attr:`~io.FileIO.name` attribute, or the *name* argument. " "The name should be a text string." msgstr "" +"從現有檔案的 :func:`os.stat` 或等效結果建立 :class:`TarInfo` 物件。檔案可以由 *name* " +"命名,或指定為具有檔案描述符的\\ :term:`檔案物件 ` *fileobj*。*name* 可以是\\ " +":term:`類路徑物件 `。如果提供了 *arcname*,則為封存檔中的檔案指定替代名稱,否則,名稱取自 " +"*fileobj* 的 :attr:`~io.FileIO.name` 屬性或 *name* 引數。名稱應該是文字字串。" #: ../../library/tarfile.rst:719 msgid "" @@ -1040,16 +1174,20 @@ msgid "" "`~gzip.GzipFile`. The :attr:`~TarInfo.name` may also be modified, in which " "case *arcname* could be a dummy string." msgstr "" +"在使用 :meth:`addfile` 新增之前,你可以修改 :class:`TarInfo` " +"的某些屬性。如果檔案物件不是位於檔案開頭的普通檔案物件,則可能需要修改諸如 :attr:`~TarInfo.size` 之類的屬性。這種情況適用於 " +":class:`~gzip.GzipFile` 等物件。:attr:`~TarInfo.name` 也可以被修改,在這種情況下 *arcname* " +"可以是一個虛設字串 (dummy string)。" #: ../../library/tarfile.rst:733 msgid "" "Close the :class:`TarFile`. In write mode, two finishing zero blocks are " "appended to the archive." -msgstr "" +msgstr "關閉 :class:`TarFile`。在寫入模式下,會在封存檔末尾附加兩個結束零區塊。" #: ../../library/tarfile.rst:740 msgid "A dictionary containing key-value pairs of pax global headers." -msgstr "" +msgstr "包含 pax 全域標頭鍵值對的字典。" #: ../../library/tarfile.rst:747 msgid "TarInfo Objects" @@ -1062,6 +1200,9 @@ msgid "" "permissions, owner etc.), it provides some useful methods to determine its " "type. It does *not* contain the file's data itself." msgstr "" +":class:`TarInfo` 物件表示 :class:`TarFile` 中的一個成員。除了儲存檔案的所有必要屬性" +"(如檔案型別、大小、時間、權限、擁有者等)之外,它還提供一些有用的方法來確定其型別。它\\ *不*\\ " +"包含檔案的資料本身。" #: ../../library/tarfile.rst:754 msgid "" @@ -1069,6 +1210,9 @@ msgid "" "`~TarFile.getmember`, :meth:`~TarFile.getmembers` and :meth:`~TarFile." "gettarinfo`." msgstr "" +":class:`TarInfo` 物件由 :class:`TarFile` 的方法 " +":meth:`~TarFile.getmember`、:meth:`~TarFile.getmembers` 和 " +":meth:`~TarFile.gettarinfo` 回傳。" #: ../../library/tarfile.rst:758 msgid "" @@ -1078,6 +1222,9 @@ msgid "" "call the :meth:`~TarInfo.replace` method to create a modified copy in one " "step." msgstr "" +"修改由 :meth:`~TarFile.getmember` 或 :meth:`~TarFile.getmembers` " +"回傳的物件將影響封存檔上的所有後續操作。對於不希望出現這種情況的情況,你可以使用 :mod:`copy.copy() ` 或呼叫 " +":meth:`~TarInfo.replace` 方法來一步建立修改後的副本。" #: ../../library/tarfile.rst:764 msgid "" @@ -1085,44 +1232,51 @@ msgid "" "metadata is unused or unknown. Different :class:`TarInfo` methods handle " "``None`` differently:" msgstr "" +"可以將多個屬性設為 ``None`` 以表示一段中介資料 (metadata) 未被使用或未知。不同的 " +":class:`TarInfo` 方法會以不同的方式處理 ``None``:" #: ../../library/tarfile.rst:768 msgid "" "The :meth:`~TarFile.extract` or :meth:`~TarFile.extractall` methods will " "ignore the corresponding metadata, leaving it set to a default." msgstr "" +":meth:`~TarFile.extract` 或 :meth:`~TarFile.extractall` 方法將忽略對應的中介資料,使其保持預設值。" #: ../../library/tarfile.rst:770 msgid ":meth:`~TarFile.addfile` will fail." -msgstr "" +msgstr ":meth:`~TarFile.addfile` 將失敗。" #: ../../library/tarfile.rst:771 msgid ":meth:`~TarFile.list` will print a placeholder string." -msgstr "" +msgstr ":meth:`~TarFile.list` 將印出一個佔位字串 (placeholder string)。" #: ../../library/tarfile.rst:775 msgid "Create a :class:`TarInfo` object." -msgstr "" +msgstr "建立 :class:`TarInfo` 物件。" #: ../../library/tarfile.rst:780 msgid "Create and return a :class:`TarInfo` object from string buffer *buf*." -msgstr "" +msgstr "從字串緩衝區 *buf* 建立並回傳 :class:`TarInfo` 物件。" #: ../../library/tarfile.rst:782 msgid "Raises :exc:`HeaderError` if the buffer is invalid." -msgstr "" +msgstr "如果緩衝區無效,則引發 :exc:`HeaderError`。" #: ../../library/tarfile.rst:787 msgid "" "Read the next member from the :class:`TarFile` object *tarfile* and return " "it as a :class:`TarInfo` object." msgstr "" +"從 :class:`TarFile` 物件 *tarfile* 讀取下一個成員並將其作為 :class:`TarInfo` " +"物件回傳。" #: ../../library/tarfile.rst:793 msgid "" "Create a string buffer from a :class:`TarInfo` object. For information on " "the arguments see the constructor of the :class:`TarFile` class." msgstr "" +"從 :class:`TarInfo` 物件建立字串緩衝區。關於引數的資訊,請參" +"閱 :class:`TarFile` 類別的建構函式。" #: ../../library/tarfile.rst:800 msgid "A ``TarInfo`` object has the following public data attributes:" @@ -1130,17 +1284,18 @@ msgstr "一個 ``TarInfo`` 物件具有以下公開資料屬性:" #: ../../library/tarfile.rst:806 msgid "Name of the archive member." -msgstr "" +msgstr "封存檔成員的名稱。" #: ../../library/tarfile.rst:812 msgid "Size in bytes." -msgstr "" +msgstr "大小(以位元組為單位)。" #: ../../library/tarfile.rst:818 msgid "" "Time of last modification in seconds since the :ref:`epoch `, as in :" "attr:`os.stat_result.st_mtime`." msgstr "" +"自\\ :ref:`epoch ` 以來的最後修改時間(以秒為單位),如 :attr:`os.stat_result.st_mtime`。" #: ../../library/tarfile.rst:823 ../../library/tarfile.rst:834 #: ../../library/tarfile.rst:866 ../../library/tarfile.rst:877 @@ -1149,10 +1304,12 @@ msgid "" "Can be set to ``None`` for :meth:`~TarFile.extract` and :meth:`~TarFile." "extractall`, causing extraction to skip applying this attribute." msgstr "" +"對於 :meth:`~TarFile.extract` 和 :meth:`~TarFile.extractall`,可以設為 " +"``None``,讓解壓縮跳過套用此屬性。" #: ../../library/tarfile.rst:830 msgid "Permission bits, as for :func:`os.chmod`." -msgstr "" +msgstr "權限位元 (permission bits),如 :func:`os.chmod` 所用。" #: ../../library/tarfile.rst:840 msgid "" @@ -1162,12 +1319,18 @@ msgid "" "const:`GNUTYPE_SPARSE`. To determine the type of a :class:`TarInfo` object " "more conveniently, use the ``is*()`` methods below." msgstr "" +"檔案類型。*type* 通常是這些常數之一:" +":const:`REGTYPE`、:const:`AREGTYPE`、:const:`LNKTYPE`、:const:`SYMTYPE`、:const:`DIRTYPE`、" +":const:`FIFOTYPE`、:const:`CONTTYPE`、:const:`CHRTYPE`、:const:`BLKTYPE`、" +":const:`GNUTYPE_SPARSE`。要更方便地確定 :class:`TarInfo` 物件的類型,請使用下面的 ``is*()`` 方法。" #: ../../library/tarfile.rst:850 msgid "" "Name of the target file name, which is only present in :class:`TarInfo` " "objects of type :const:`LNKTYPE` and :const:`SYMTYPE`." msgstr "" +"目標檔案名稱的名稱,僅存在於型別為 :const:`LNKTYPE` 和 :const:`SYMTYPE` 的 :class:`TarInfo` " +"物件中。" #: ../../library/tarfile.rst:853 msgid "" @@ -1175,51 +1338,53 @@ msgid "" "directory that contains the link. For hard links (``LNKTYPE``), the " "*linkname* is relative to the root of the archive." msgstr "" +"對於符號連結(``SYMTYPE``),*linkname* 相對於包含連結的目錄。對於硬連結(``LNKTYPE``),*linkname* " +"相對於封存檔的根。" #: ../../library/tarfile.rst:862 msgid "User ID of the user who originally stored this member." -msgstr "" +msgstr "最初儲存此成員的使用者的使用者 ID。" #: ../../library/tarfile.rst:873 msgid "Group ID of the user who originally stored this member." -msgstr "" +msgstr "最初儲存此成員的使用者的群組 ID。" #: ../../library/tarfile.rst:884 msgid "User name." -msgstr "" +msgstr "使用者名稱。" #: ../../library/tarfile.rst:895 msgid "Group name." -msgstr "" +msgstr "群組名稱。" #: ../../library/tarfile.rst:906 msgid "Header checksum." -msgstr "" +msgstr "標頭校驗和 (checksum)。" #: ../../library/tarfile.rst:912 msgid "Device major number." -msgstr "" +msgstr "裝置主號碼。" #: ../../library/tarfile.rst:918 msgid "Device minor number." -msgstr "" +msgstr "裝置副號碼。" #: ../../library/tarfile.rst:924 msgid "The tar header starts here." -msgstr "" +msgstr "tar 標頭從這裡開始。" #: ../../library/tarfile.rst:930 msgid "The file's data starts here." -msgstr "" +msgstr "檔案的資料從這裡開始。" #: ../../library/tarfile.rst:935 msgid "Sparse member information." -msgstr "" +msgstr "稀疏成員資訊。" #: ../../library/tarfile.rst:941 msgid "" "A dictionary containing key-value pairs of an associated pax extended header." -msgstr "" +msgstr "包含關聯的 pax 擴充標頭鍵值對的字典。" #: ../../library/tarfile.rst:949 msgid "" @@ -1227,6 +1392,8 @@ msgid "" "attributes changed. For example, to return a ``TarInfo`` with the group name " "set to ``'staff'``, use::" msgstr "" +"回傳具有給定屬性變更的 :class:`!TarInfo` 物件的\\ *新*\\ 副本。例如,要回傳群組名稱設為 ``'staff'`` 的 " +"``TarInfo``,請使用: ::" #: ../../library/tarfile.rst:953 msgid "new_tarinfo = old_tarinfo.replace(gname='staff')" @@ -1238,18 +1405,20 @@ msgid "" "e. ``pax_headers`` and any custom attributes are shared with the original " "``TarInfo`` object." msgstr "" +"預設情況下,會進行深度複製。如果 *deep* 為 false,則複製為淺複製,即 ``pax_headers`` 和任何自訂屬性與原始 " +"``TarInfo`` 物件共用。" #: ../../library/tarfile.rst:959 msgid "A :class:`TarInfo` object also provides some convenient query methods:" -msgstr "" +msgstr ":class:`TarInfo` 物件也提供一些方便的查詢方法:" #: ../../library/tarfile.rst:964 msgid "Return :const:`True` if the :class:`TarInfo` object is a regular file." -msgstr "" +msgstr "如果 :class:`TarInfo` 物件是一般檔案,則回傳 :const:`True`。" #: ../../library/tarfile.rst:969 msgid "Same as :meth:`isfile`." -msgstr "" +msgstr "與 :meth:`isfile` 相同。" #: ../../library/tarfile.rst:974 msgid "Return :const:`True` if it is a directory." @@ -1261,7 +1430,7 @@ msgstr "如果它是一個符號連結,則回傳 :const:`True`。" #: ../../library/tarfile.rst:984 msgid "Return :const:`True` if it is a hard link." -msgstr "" +msgstr "如果它是一個硬連結,則回傳 :const:`True`。" #: ../../library/tarfile.rst:989 msgid "Return :const:`True` if it is a character device." @@ -1282,7 +1451,7 @@ msgstr "如果它是一個字元裝置、區塊裝置或 FIFO,則回傳 :const #: ../../library/tarfile.rst:1010 msgid "Extraction filters" -msgstr "" +msgstr "解壓縮篩選器" #: ../../library/tarfile.rst:1014 msgid "" @@ -1293,13 +1462,17 @@ msgid "" "arbitrary files in various ways (e.g. by using absolute paths, ``..`` path " "components, or symlinks that affect later members)." msgstr "" +"*tar* 格式是為了捕捉 UNIX-like 檔案系統的所有細節而設計的,這使它非常強大。不" +"幸的是,這些功能使得建立在解壓縮時具有非預期甚至可能是惡意影響的 tar 檔案變得" +"很容易。例如,解壓縮 tar 檔案可以透過各種方式覆寫任意檔案(例如使用絕對路徑、" +"``..`` 路徑元件,或影響後續成員的符號連結)。" #: ../../library/tarfile.rst:1022 msgid "" "In most cases, the full functionality is not needed. Therefore, *tarfile* " "supports extraction filters: a mechanism to limit functionality, and thus " "mitigate some of the security issues." -msgstr "" +msgstr "在大多數情況下,不需要完整功能。因此,*tarfile* 支援解壓縮篩選器:一種限制功能的機制,從而減輕某些安全性問題。" #: ../../library/tarfile.rst:1028 msgid "" @@ -1307,6 +1480,9 @@ msgid "" "extract archives from untrusted sources without prior inspection. See also :" "ref:`tarfile-further-verification`." msgstr "" +"沒有任何可用的篩選器會阻擋\\ *所有*\\ 危險的封存檔功能。永遠不要在沒有事先檢" +"查的情況下從不受信任的來源解壓縮封存檔。另請參閱 :ref:`tarfile-further-" +"verification`。" #: ../../library/tarfile.rst:1034 msgid ":pep:`706`" @@ -1314,13 +1490,15 @@ msgstr ":pep:`706`" #: ../../library/tarfile.rst:1035 msgid "Contains further motivation and rationale behind the design." -msgstr "" +msgstr "包含此設計背後的進一步動機和理由。" #: ../../library/tarfile.rst:1037 msgid "" "The *filter* argument to :meth:`TarFile.extract` or :meth:`~TarFile." "extractall` can be:" msgstr "" +":meth:`TarFile.extract` 或 :meth:`~TarFile.extractall` 的 *filter* 引數可以" +"是:" #: ../../library/tarfile.rst:1040 msgid "" @@ -1328,6 +1506,8 @@ msgid "" "archive. Should be used if the user trusts the archive completely, or " "implements their own complex verification." msgstr "" +"``'fully_trusted'`` 字串:遵守封存檔中指定的所有中介資料。應在使用者完全信任" +"封存檔或實作自己的複雜驗證時使用。" #: ../../library/tarfile.rst:1045 msgid "" @@ -1335,6 +1515,8 @@ msgid "" "UNIX-like filesystems), but block features that are very likely to be " "surprising or malicious. See :func:`tar_filter` for details." msgstr "" +"``'tar'`` 字串:遵守大多數 *tar* 特定功能(即 UNIX-like 檔案系統的功能),但" +"阻擋很可能令人驚訝或惡意的功能。詳見 :func:`tar_filter`。" #: ../../library/tarfile.rst:1049 msgid "" @@ -1342,21 +1524,25 @@ msgid "" "filesystems. Intended for extracting cross-platform data archives. See :func:" "`data_filter` for details." msgstr "" +"``'data'`` 字串:忽略或阻擋大多數 UNIX-like 檔案系統特定功能。用於解壓縮跨平" +"台資料封存檔。詳見 :func:`data_filter`。" #: ../../library/tarfile.rst:1053 msgid "``None`` (default): Use :attr:`TarFile.extraction_filter`." -msgstr "" +msgstr "``None``\\ (預設):使用 :attr:`TarFile.extraction_filter`。" #: ../../library/tarfile.rst:1055 msgid "" "If that is also ``None`` (the default), the ``'data'`` filter will be used." -msgstr "" +msgstr "如果該值也是 ``None``\\ (預設值),則會使用 ``'data'`` 篩選器。" #: ../../library/tarfile.rst:1059 msgid "" "The default filter is set to :func:`data `. Previously, the " "default was equivalent to :func:`fully_trusted `." msgstr "" +"預設篩選器設為 :func:`data `。在此之前,預設等同" +"於 :func:`fully_trusted `。" #: ../../library/tarfile.rst:1063 msgid "" @@ -1365,6 +1551,9 @@ msgid "" "to where the archive is extracted (i.e. the same path is used for all " "members)::" msgstr "" +"一個可呼叫物件,對於每個解壓縮的成員,會使用描述該成員的 :ref:`TarInfo " +"` 和封存檔解壓縮目的地路徑來呼叫它(即所有成員使用相同的路" +"徑): ::" #: ../../library/tarfile.rst:1068 msgid "filter(member: TarInfo, path: str, /) -> TarInfo | None" @@ -1375,16 +1564,17 @@ msgid "" "The callable is called just before each member is extracted, so it can take " "the current state of the disk into account. It can:" msgstr "" +"此可呼叫物件在每個成員解壓縮之前被呼叫,因此可以考慮磁碟的目前狀態。它可以:" #: ../../library/tarfile.rst:1074 msgid "" "return a :class:`TarInfo` object which will be used instead of the metadata " "in the archive, or" -msgstr "" +msgstr "回傳一個 :class:`TarInfo` 物件,該物件將用於替代封存檔中的中介資料,或" #: ../../library/tarfile.rst:1076 msgid "return ``None``, in which case the member will be skipped, or" -msgstr "" +msgstr "回傳 ``None``,在此情況下該成員會被跳過,或" #: ../../library/tarfile.rst:1077 msgid "" @@ -1393,32 +1583,35 @@ msgid "" "`~TarFile.extractall` may leave the archive partially extracted. It does not " "attempt to clean up." msgstr "" +"引發例外以中止操作或跳過該成員,取決於 :attr:`~TarFile.errorlevel`。請注意," +"當解壓縮被中止時,:meth:`~TarFile.extractall` 可能會留下部分解壓縮的封存檔。" +"它不會嘗試清理。" #: ../../library/tarfile.rst:1083 msgid "Default named filters" -msgstr "" +msgstr "預設具名篩選器" #: ../../library/tarfile.rst:1085 msgid "" "The pre-defined, named filters are available as functions, so they can be " "reused in custom filters:" -msgstr "" +msgstr "預先定義的具名篩選器可作為函式使用,因此可以在自訂篩選器中重複使用:" #: ../../library/tarfile.rst:1090 msgid "Return *member* unchanged." -msgstr "" +msgstr "回傳未經修改的 *member*。" #: ../../library/tarfile.rst:1092 msgid "This implements the ``'fully_trusted'`` filter." -msgstr "" +msgstr "這實作了 ``'fully_trusted'`` 篩選器。" #: ../../library/tarfile.rst:1096 msgid "Implements the ``'tar'`` filter." -msgstr "" +msgstr "實作 ``'tar'`` 篩選器。" #: ../../library/tarfile.rst:1098 msgid "Strip leading slashes (``/`` and :data:`os.sep`) from filenames." -msgstr "" +msgstr "從檔名中移除開頭的斜線(``/`` 和 :data:`os.sep`)。" #: ../../library/tarfile.rst:1099 msgid "" @@ -1426,6 +1619,9 @@ msgid "" "paths (in case the name is absolute even after stripping slashes, e.g. ``C:/" "foo`` on Windows). This raises :class:`~tarfile.AbsolutePathError`." msgstr "" +":ref:`拒絕 `\\ 解壓縮具有絕對路徑的檔案(在移除斜" +"線後名稱仍是絕對路徑的情況下,例如 Windows 上的 ``C:/foo``)。這會引" +"發 :class:`~tarfile.AbsolutePathError`。" #: ../../library/tarfile.rst:1103 msgid "" @@ -1433,21 +1629,26 @@ msgid "" "path (after following symlinks) would end up outside the destination. This " "raises :class:`~tarfile.OutsideDestinationError`." msgstr "" +":ref:`拒絕 `\\ 解壓縮其絕對路徑(在跟隨符號連結" +"後)會位於目的地之外的檔案。這會引" +"發 :class:`~tarfile.OutsideDestinationError`。" #: ../../library/tarfile.rst:1106 msgid "" "Clear high mode bits (setuid, setgid, sticky) and group/other write bits (:" "const:`~stat.S_IWGRP` | :const:`~stat.S_IWOTH`)." msgstr "" +"清除高位模式位元 (setuid, setgid, sticky) 以及群組/其他人的寫入位元" +"(:const:`~stat.S_IWGRP` | :const:`~stat.S_IWOTH`)。" #: ../../library/tarfile.rst:1109 ../../library/tarfile.rst:1148 msgid "Return the modified ``TarInfo`` member." -msgstr "" +msgstr "回傳修改後的 ``TarInfo`` 成員。" #: ../../library/tarfile.rst:1113 msgid "" "Implements the ``'data'`` filter. In addition to what ``tar_filter`` does:" -msgstr "" +msgstr "實作 ``'data'`` 篩選器。除了 ``tar_filter`` 的功能外,還包括:" #: ../../library/tarfile.rst:1116 msgid "" @@ -1456,72 +1657,86 @@ msgid "" "change the meaning of the link if the path in :attr:`!TarInfo.linkname` " "traverses symbolic links." msgstr "" +"使用 :func:`os.path.normpath` 正規化連結目標(:attr:`TarInfo.linkname`)。請" +"注意,這會移除內部的 ``..`` 元件,如果 :attr:`!TarInfo.linkname` 中的路徑會遍" +"歷符號連結,這可能會改變連結的意義。" #: ../../library/tarfile.rst:1122 msgid "" ":ref:`Refuse ` to extract links (hard or soft) " "that link to absolute paths, or ones that link outside the destination." msgstr "" +":ref:`拒絕 `\\ 解壓縮指向絕對路徑的連結(硬連結或" +"軟連結),或指向目的地之外的連結。" #: ../../library/tarfile.rst:1125 msgid "" "This raises :class:`~tarfile.AbsoluteLinkError` or :class:`~tarfile." "LinkOutsideDestinationError`." msgstr "" +"這會引發 :class:`~tarfile.AbsoluteLinkError` 或 " +":class:`~tarfile.LinkOutsideDestinationError`。" #: ../../library/tarfile.rst:1128 msgid "" "Note that such files are refused even on platforms that do not support " "symbolic links." -msgstr "" +msgstr "請注意,即使在不支援符號連結的平台上,這類檔案也會被拒絕。" #: ../../library/tarfile.rst:1131 msgid "" ":ref:`Refuse ` to extract device files (including " "pipes). This raises :class:`~tarfile.SpecialFileError`." msgstr "" +":ref:`拒絕 `\\ 解壓縮裝置檔案(包括 pipe)。這會引發 " +":class:`~tarfile.SpecialFileError`。" #: ../../library/tarfile.rst:1135 msgid "For regular files, including hard links:" -msgstr "" +msgstr "對於一般檔案,包括硬連結:" #: ../../library/tarfile.rst:1137 msgid "" "Set the owner read and write permissions (:const:`~stat.S_IRUSR` | :const:" "`~stat.S_IWUSR`)." msgstr "" +"設定擁有者的讀取和寫入權限(:const:`~stat.S_IRUSR` | :const:`~stat.S_IWUSR`)。" #: ../../library/tarfile.rst:1139 msgid "" "Remove the group & other executable permission (:const:`~stat.S_IXGRP` | :" "const:`~stat.S_IXOTH`) if the owner doesn’t have it (:const:`~stat.S_IXUSR`)." msgstr "" +"如果擁有者沒有執行權限(:const:`~stat.S_IXUSR`),則移除群組和其他人的執行權限(:const:`~stat.S_IXGRP` | " +":const:`~stat.S_IXOTH`)。" #: ../../library/tarfile.rst:1143 msgid "" "For other files (directories), set ``mode`` to ``None``, so that extraction " "methods skip applying permission bits." -msgstr "" +msgstr "對於其他檔案(目錄),將 ``mode`` 設為 ``None``,讓解壓縮方法跳過套用權限位元。" #: ../../library/tarfile.rst:1145 msgid "" "Set user and group info (``uid``, ``gid``, ``uname``, ``gname``) to " "``None``, so that extraction methods skip setting it." msgstr "" +"將使用者和群組資訊 (``uid``, ``gid``, ``uname``, ``gname``) 設為 ``None``,讓解壓縮方法跳過設定它們。" #: ../../library/tarfile.rst:1150 msgid "" "Note that this filter does not block *all* dangerous archive features. See :" "ref:`tarfile-further-verification` for details." msgstr "" +"請注意,此篩選器並未阻擋\\ *所有*\\ 危險的封存檔功能。詳細資訊請參閱 :ref:`tarfile-further-verification`。" #: ../../library/tarfile.rst:1155 msgid "Link targets are now normalized." -msgstr "" +msgstr "連結目標現在會被正規化。" #: ../../library/tarfile.rst:1161 msgid "Filter errors" -msgstr "" +msgstr "篩選器錯誤" #: ../../library/tarfile.rst:1163 msgid "" @@ -1531,10 +1746,13 @@ msgid "" "the error will be logged and the member will be skipped, but extraction will " "continue." msgstr "" +"當篩選器拒絕解壓縮檔案時,它會引發適當的例外,該例外是 :class:`~tarfile.FilterError`" +" 的子類別。如果 :attr:`TarFile.errorlevel` 為 1 或更高,這將中止解壓縮。使用 " +"``errorlevel=0`` 時,錯誤將被記錄並跳過該成員,但解壓縮將繼續進行。" #: ../../library/tarfile.rst:1173 msgid "Hints for further verification" -msgstr "" +msgstr "進一步驗證的提示" #: ../../library/tarfile.rst:1175 msgid "" @@ -1543,10 +1761,13 @@ msgid "" "defined filters do not prevent denial-of-service attacks. Users should do " "additional checks." msgstr "" +"即使使用 ``filter='data'``,*tarfile* 也不適合在沒有事先檢查的情況下解壓縮不" +"受信任的檔案。除了其他問題外,預先定義的篩選器不會防止阻斷服務攻擊。使用者應" +"進行額外檢查。" #: ../../library/tarfile.rst:1180 msgid "Here is an incomplete list of things to consider:" -msgstr "" +msgstr "以下是需要考慮的不完整清單:" #: ../../library/tarfile.rst:1182 msgid "" @@ -1554,22 +1775,27 @@ msgid "" "g. exploiting pre-existing links, and to make it easier to clean up after a " "failed extraction." msgstr "" +"解壓縮到\\ :func:`新的臨時目錄 `\\ 以防止例如利用預先存在的" +"連結,並使解壓縮失敗後更容易清理。" #: ../../library/tarfile.rst:1185 msgid "Disallow symbolic links if you do not need the functionality." -msgstr "" +msgstr "如果不需要符號連結功能,請禁止它。" #: ../../library/tarfile.rst:1186 msgid "" "When working with untrusted data, use external (e.g. OS-level) limits on " "disk, memory and CPU usage." msgstr "" +"處理不受信任的資料時,請使用外部(例如作業系統層級)的磁碟、記憶體和 CPU 使用" +"量限制。" #: ../../library/tarfile.rst:1188 msgid "" "Check filenames against an allow-list of characters (to filter out control " "characters, confusables, foreign path separators, and so on)." msgstr "" +"根據字元白名單檢查檔名(以過濾掉控制字元、易混淆字元、外部路徑分隔符號等)。" #: ../../library/tarfile.rst:1191 msgid "" @@ -1577,20 +1803,24 @@ msgid "" "execute when you “click on them”, or extension-less files like Windows " "special device names)." msgstr "" +"檢查檔名是否具有預期的副檔名(避免點擊時會執行的檔案,或像 Windows 特殊裝置名" +"稱這樣的無副檔名檔案)。" #: ../../library/tarfile.rst:1194 msgid "" "Limit the number of extracted files, total size of extracted data, filename " "length (including symlink length), and size of individual files." msgstr "" +"限制解壓縮檔案的數量、解壓縮資料的總大小、檔名長度(包括符號連結長度)以及個" +"別檔案的大小。" #: ../../library/tarfile.rst:1196 msgid "Check for files that would be shadowed on case-insensitive filesystems." -msgstr "" +msgstr "檢查在不區分大小寫的檔案系統上會被遮蔽的檔案。" #: ../../library/tarfile.rst:1198 msgid "Also note that:" -msgstr "" +msgstr "另請注意:" #: ../../library/tarfile.rst:1200 msgid "" @@ -1598,6 +1828,8 @@ msgid "" "expected to overwrite any earlier ones. This feature is crucial to allow " "updating tape archives, but can be abused maliciously." msgstr "" +"Tar 檔案可能包含同一檔案的多個版本。較晚的版本預期會覆蓋較早的版本。此功能對" +"於允許更新磁帶封存檔至關重要,但可能被惡意濫用。" #: ../../library/tarfile.rst:1204 msgid "" @@ -1605,10 +1837,12 @@ msgid "" "tinkering with the destination (or source) directory while extraction (or " "archiving) is in progress." msgstr "" +"*tarfile* 不會防止「即時」資料的問題,例如攻擊者在解壓縮(或封存)進行中時篡" +"改目的地(或來源)目錄。" #: ../../library/tarfile.rst:1210 msgid "Supporting older Python versions" -msgstr "" +msgstr "支援舊版 Python" #: ../../library/tarfile.rst:1212 msgid "" @@ -1617,6 +1851,9 @@ msgid "" "e.g. ``hasattr(tarfile, 'data_filter')`` rather than checking the Python " "version." msgstr "" +"解壓縮篩選器在 Python 3.12 中加入,但可能會作為安全性更新移植到較舊版本。要檢" +"查此功能是否可用,請使用 ``hasattr(tarfile, 'data_filter')`` 而不是檢查 " +"Python 版本。" #: ../../library/tarfile.rst:1217 msgid "" @@ -1624,10 +1861,12 @@ msgid "" "the feature. Note that setting ``extraction_filter`` will affect any " "subsequent operations." msgstr "" +"以下範例顯示如何支援有此功能和沒有此功能的 Python 版本。請注意,設定 " +"``extraction_filter`` 會影響任何後續操作。" #: ../../library/tarfile.rst:1221 msgid "Fully trusted archive::" -msgstr "" +msgstr "完全信任的封存檔: ::" #: ../../library/tarfile.rst:1223 msgid "" @@ -1642,6 +1881,8 @@ msgid "" "Use the ``'data'`` filter if available, but revert to Python 3.11 behavior " "(``'fully_trusted'``) if this feature is not available::" msgstr "" +"如果可用則使用 ``'data'`` 篩選器,但如果此功能不可用則使用後備的 Python 3.11 " +"的行為(``'fully_trusted'``):" #: ../../library/tarfile.rst:1229 msgid "" @@ -1655,7 +1896,7 @@ msgstr "" #: ../../library/tarfile.rst:1233 msgid "Use the ``'data'`` filter; *fail* if it is not available::" -msgstr "" +msgstr "使用 ``'data'`` 篩選器;如果不可用則\\ *失敗*\\ : ::" #: ../../library/tarfile.rst:1235 msgid "my_tarfile.extractall(filter=tarfile.data_filter)" @@ -1675,7 +1916,7 @@ msgstr "" #: ../../library/tarfile.rst:1242 msgid "Use the ``'data'`` filter; *warn* if it is not available::" -msgstr "" +msgstr "使用 ``'data'`` 篩選器;如果不可用則\\ *警告*\\ : ::" #: ../../library/tarfile.rst:1244 msgid "" @@ -1695,7 +1936,7 @@ msgstr "" #: ../../library/tarfile.rst:1253 msgid "Stateful extraction filter example" -msgstr "" +msgstr "有狀態的解壓縮篩選器範例" #: ../../library/tarfile.rst:1255 msgid "" @@ -1703,6 +1944,8 @@ msgid "" "filters may be more complex objects with an internal state. It may be useful " "to write these as context managers, to be used like this::" msgstr "" +"雖然 *tarfile* 的解壓縮方法接受一個簡單的 *filter* 可呼叫物件,但自訂篩選器可" +"能是具有內部狀態的更複雜物件。將這些寫成情境管理器可能很有用,像這樣使用: ::" #: ../../library/tarfile.rst:1259 msgid "" @@ -1714,7 +1957,7 @@ msgstr "" #: ../../library/tarfile.rst:1262 msgid "Such a filter can be written as, for example::" -msgstr "" +msgstr "例如,這樣的篩選器可以寫成: ::" #: ../../library/tarfile.rst:1264 msgid "" @@ -1754,13 +1997,15 @@ msgstr "命令列介面" msgid "" "The :mod:`tarfile` module provides a simple command-line interface to " "interact with tar archives." -msgstr "" +msgstr ":mod:`tarfile` 模組提供了簡單的命令列介面來與 tar 封存檔互動。" #: ../../library/tarfile.rst:1291 msgid "" "If you want to create a new tar archive, specify its name after the :option:" "`-c` option and then list the filename(s) that should be included:" msgstr "" +"如果你要建立新的 tar 封存檔,請在 :option:`-c` 選項後指定其名稱,然後列出應包" +"含的檔案名稱:" #: ../../library/tarfile.rst:1294 msgid "$ python -m tarfile -c monty.tar spam.txt eggs.txt" @@ -1768,7 +2013,7 @@ msgstr "$ python -m tarfile -c monty.tar spam.txt eggs.txt" #: ../../library/tarfile.rst:1298 msgid "Passing a directory is also acceptable:" -msgstr "" +msgstr "也可以傳遞目錄:" #: ../../library/tarfile.rst:1300 msgid "$ python -m tarfile -c monty.tar life-of-brian_1979/" @@ -1779,6 +2024,7 @@ msgid "" "If you want to extract a tar archive into the current directory, use the :" "option:`-e` option:" msgstr "" +"如果你要將 tar 封存檔解壓縮到目前目錄,請使用 :option:`-e` 選項:" #: ../../library/tarfile.rst:1307 msgid "$ python -m tarfile -e monty.tar" @@ -1788,7 +2034,7 @@ msgstr "$ python -m tarfile -e monty.tar" msgid "" "You can also extract a tar archive into a different directory by passing the " "directory's name:" -msgstr "" +msgstr "你也可以透過傳遞目錄名稱,將 tar 封存檔解壓縮到不同的目錄:" #: ../../library/tarfile.rst:1314 msgid "$ python -m tarfile -e monty.tar other-dir/" @@ -1796,7 +2042,7 @@ msgstr "$ python -m tarfile -e monty.tar other-dir/" #: ../../library/tarfile.rst:1318 msgid "For a list of the files in a tar archive, use the :option:`-l` option:" -msgstr "" +msgstr "若要列出 tar 封存檔中的檔案,請使用 :option:`-l` 選項:" #: ../../library/tarfile.rst:1320 msgid "$ python -m tarfile -l monty.tar" @@ -1808,24 +2054,24 @@ msgstr "命令列選項" #: ../../library/tarfile.rst:1331 msgid "List files in a tarfile." -msgstr "" +msgstr "列出 tarfile 中的檔案。" #: ../../library/tarfile.rst:1336 msgid "Create tarfile from source files." -msgstr "" +msgstr "從來源檔案建立 tarfile。" #: ../../library/tarfile.rst:1341 msgid "" "Extract tarfile into the current directory if *output_dir* is not specified." -msgstr "" +msgstr "如果未指定 *output_dir*,則將 tarfile 解壓縮到目前目錄。" #: ../../library/tarfile.rst:1346 msgid "Test whether the tarfile is valid or not." -msgstr "" +msgstr "測試 tarfile 是否有效。" #: ../../library/tarfile.rst:1350 msgid "Verbose output." -msgstr "" +msgstr "詳細輸出。" #: ../../library/tarfile.rst:1354 msgid "" @@ -1833,6 +2079,8 @@ msgid "" "filter` for details. Only string names are accepted (that is, " "``fully_trusted``, ``tar``, and ``data``)." msgstr "" +"為 ``--extract`` 指定 *filter*。詳見 :ref:`tarfile-extraction-filter`。僅接受" +"字串名稱(即 ``fully_trusted``、``tar`` 和 ``data``)。" #: ../../library/tarfile.rst:1362 msgid "Examples" @@ -1840,11 +2088,11 @@ msgstr "範例" #: ../../library/tarfile.rst:1365 msgid "Reading examples" -msgstr "" +msgstr "讀取範例" #: ../../library/tarfile.rst:1367 msgid "How to extract an entire tar archive to the current working directory::" -msgstr "" +msgstr "如何將整個 tar 封存檔解壓縮到目前的工作目錄: ::" #: ../../library/tarfile.rst:1369 msgid "" @@ -1863,6 +2111,8 @@ msgid "" "How to extract a subset of a tar archive with :meth:`TarFile.extractall` " "using a generator function instead of a list::" msgstr "" +"如何使用產生器函式而非串列,來以 :meth:`TarFile.extractall` 解壓縮 tar 封存檔" +"的子集: ::" #: ../../library/tarfile.rst:1377 msgid "" @@ -1894,7 +2144,7 @@ msgstr "" msgid "" "How to read a gzip compressed tar archive and display some member " "information::" -msgstr "" +msgstr "如何讀取 gzip 壓縮的 tar 封存檔並顯示部分成員資訊: ::" #: ../../library/tarfile.rst:1391 msgid "" @@ -1911,14 +2161,26 @@ msgid "" " print(\"something else.\")\n" "tar.close()" msgstr "" +"import tarfile\n" +"tar = tarfile.open(\"sample.tar.gz\", \"r:gz\")\n" +"for tarinfo in tar:\n" +" print(tarinfo.name, \"is\", tarinfo.size, \"bytes in size and is \", " +"end=\"\")\n" +" if tarinfo.isreg():\n" +" print(\"a regular file.\")\n" +" elif tarinfo.isdir():\n" +" print(\"a directory.\")\n" +" else:\n" +" print(\"something else.\")\n" +"tar.close()" #: ../../library/tarfile.rst:1404 msgid "Writing examples" -msgstr "" +msgstr "寫入範例" #: ../../library/tarfile.rst:1406 msgid "How to create an uncompressed tar archive from a list of filenames::" -msgstr "" +msgstr "如何從檔案名稱串列建立未壓縮的 tar 封存檔: ::" #: ../../library/tarfile.rst:1408 msgid "" @@ -1936,7 +2198,7 @@ msgstr "" #: ../../library/tarfile.rst:1414 msgid "The same example using the :keyword:`with` statement::" -msgstr "" +msgstr "使用 :keyword:`with` 陳述式的相同範例: ::" #: ../../library/tarfile.rst:1416 msgid "" @@ -1955,6 +2217,8 @@ msgid "" "How to create and write an archive to stdout using :data:`sys.stdout.buffer " "` in the *fileobj* parameter in :meth:`TarFile.add`::" msgstr "" +"如何在 :meth:`TarFile.add` 的 *fileobj* 參數中使用 :data:`sys.stdout.buffer " +"` 建立封存檔並寫入標準輸出:" #: ../../library/tarfile.rst:1425 msgid "" @@ -1977,6 +2241,8 @@ msgid "" "How to create an archive and reset the user information using the *filter* " "parameter in :meth:`TarFile.add`::" msgstr "" +"如何在 :meth:`TarFile.add` 中使用 *filter* 參數來建立封存檔並重設使用者資" +"訊: ::" #: ../../library/tarfile.rst:1434 msgid "" @@ -2006,7 +2272,7 @@ msgstr "支援的 tar 格式" msgid "" "There are three tar formats that can be created with the :mod:`tarfile` " "module:" -msgstr "" +msgstr "使用 :mod:`tarfile` 模組可以建立三種 tar 格式:" #: ../../library/tarfile.rst:1451 msgid "" @@ -2015,6 +2281,9 @@ msgid "" "The maximum file size is 8 GiB. This is an old and limited but widely " "supported format." msgstr "" +"POSIX.1-1988 ustar 格式(:const:`USTAR_FORMAT`)。它支援最多 256 個字元的檔名" +"和最多 100 個字元的連結名稱。檔案大小上限為 8 GiB。這是一種老舊且受限的格式," +"但廣受支援。" #: ../../library/tarfile.rst:1456 msgid "" @@ -2023,6 +2292,9 @@ msgid "" "standard on GNU/Linux systems. :mod:`tarfile` fully supports the GNU tar " "extensions for long names, sparse file support is read-only." msgstr "" +"GNU tar 格式(:const:`GNU_FORMAT`)。它支援長檔名和長連結名稱、超過 8 GiB 的檔案以及" +"稀疏檔案。這是 GNU/Linux 系統上的實際標準。:mod:`tarfile` 完全支援 " +"GNU tar 對長名稱的擴充,但稀疏檔案僅有唯讀支援。" #: ../../library/tarfile.rst:1461 msgid "" @@ -2034,6 +2306,11 @@ msgid "" "but should treat *pax* archives as if they were in the universally supported " "*ustar* format. It is the current default format for new archives." msgstr "" +"POSIX.1-2001 pax 格式(:const:`PAX_FORMAT`)。這是最靈活的格式,幾乎沒有任何" +"限制。它支援長檔名和長連結名稱、大型檔案,並以可攜的方式儲存路徑名稱。現代的 " +"tar 實作(包括 GNU tar、bsdtar/libarchive 和 star)都完全支援擴充的 *pax* 功" +"能;某些舊的或未維護的函式庫可能不支援,但應將 *pax* 封存檔視為普遍支援的 " +"*ustar* 格式。這是目前建立新封存檔的預設格式。" #: ../../library/tarfile.rst:1469 msgid "" @@ -2043,12 +2320,16 @@ msgid "" "valid for the complete archive and affect all following files. All the data " "in a pax header is encoded in *UTF-8* for portability reasons." msgstr "" +"它透過額外的標頭擴充既有的 *ustar* 格式,以儲存無法以其他方式儲存的資訊。pax " +"標頭有兩種類型:擴充標頭(Extended headers)只影響緊接在後的檔案標頭,全域標頭(global " +"headers)則對整個封存檔有效並影響所有後續檔案。為了可攜性,pax 標頭中的所有資料都使用 " +"*UTF-8* 編碼。" #: ../../library/tarfile.rst:1475 msgid "" "There are some more variants of the tar format which can be read, but not " "created:" -msgstr "" +msgstr "還有一些 tar 格式的變體可以讀取,但無法建立:" #: ../../library/tarfile.rst:1478 msgid "" @@ -2058,16 +2339,18 @@ msgid "" "archives have miscalculated header checksums in case of fields with non-" "ASCII characters." msgstr "" +"古老的 V7 格式。這是 Unix 第七版的第一個 tar 格式,只能儲存一般檔案和目錄。名稱不得超過 100 " +"個字元,且沒有使用者/群組名稱資訊。某些封存檔在欄位包含非 ASCII 字元時,標頭檢查碼會計算錯誤。" #: ../../library/tarfile.rst:1483 msgid "" "The SunOS tar extended format. This format is a variant of the POSIX.1-2001 " "pax format, but is not compatible." -msgstr "" +msgstr "SunOS tar 擴充格式。此格式是 POSIX.1-2001 pax 格式的變體,但並不相容。" #: ../../library/tarfile.rst:1489 msgid "Unicode issues" -msgstr "" +msgstr "Unicode 議題" #: ../../library/tarfile.rst:1491 msgid "" @@ -2083,12 +2366,20 @@ msgid "" "encoding of an archive. The pax format was designed to solve this problem. " "It stores non-ASCII metadata using the universal character encoding *UTF-8*." msgstr "" +"tar 格式最初是為了在磁帶機上進行備份而設計的,主要著重於保存檔案系統資訊。現" +"今 tar 封存檔常用於檔案發布和透過網路交換封存檔。原始格式(也是所有其他格式的" +"基礎)的一個問題是,它沒有支援不同字元編碼的概念。例如,在 *UTF-8* 系統上建立" +"的普通 tar 封存檔,如果包含非 *ASCII* 字元,在 *Latin-1* 系統上就無法正確讀" +"取。文字中介資料(如檔名、連結名稱、使用者/群組名稱)會顯示為損壞。不幸的是," +"無法自動偵測封存檔的編碼。pax 格式就是為了解決此問題而設計的。它使用通用字元" +"編碼 *UTF-8* 來儲存非 ASCII 中介資料。" #: ../../library/tarfile.rst:1503 msgid "" "The details of character conversion in :mod:`tarfile` are controlled by the " "*encoding* and *errors* keyword arguments of the :class:`TarFile` class." msgstr "" +":mod:`tarfile` 中字元轉換的細節由 :class:`TarFile` 類別的 *encoding* 和 *errors* 關鍵字引數控制。" #: ../../library/tarfile.rst:1506 msgid "" @@ -2098,6 +2389,10 @@ msgid "" "written, the metadata must be either decoded or encoded. If *encoding* is " "not set appropriately, this conversion may fail." msgstr "" +"*encoding* 定義封存檔中介資料所使用的字元編碼。預設值" +"為 :func:`sys.getfilesystemencoding`,若無法取得則使用 ``'ascii'`` 作為備用。" +"根據封存檔是讀取還是寫入,中介資料必須被解碼或編碼。如果 *encoding* 設定不" +"當,此轉換可能會失敗。" #: ../../library/tarfile.rst:1512 msgid "" @@ -2106,6 +2401,9 @@ msgid "" "default scheme is ``'surrogateescape'`` which Python also uses for its file " "system calls, see :ref:`os-filenames`." msgstr "" +"*errors* 引數定義如何處理無法轉換的字元。可能的值列於 :ref:`error-handlers` " +"一節。預設方案是 ``'surrogateescape'``,這也是 Python 用於檔案系統呼叫的方" +"案,參見 :ref:`os-filenames`。" #: ../../library/tarfile.rst:1517 msgid "" @@ -2114,6 +2412,6 @@ msgid "" "used in the rare cases when binary pax headers are decoded or when strings " "with surrogate characters are stored." msgstr "" - -#~ msgid "See the warning for :meth:`extractall`." -#~ msgstr "參閱 :meth:`extractall` 的警告。" +"對於 :const:`PAX_FORMAT` 封存檔(預設格式),通常不需要 *encoding*,因為所有" +"中介資料都使用 *UTF-8* 儲存。*encoding* 只在少數情況下使用,例如解碼二進位 " +"pax 標頭或儲存包含代理字元的字串時。"