77# ww song <[email protected] >, 201888# Meng Du <[email protected] >, 20199910- # Freesand Leo <yuqinju@163 .com>, 2019
11- # cdarlint <cdarling@126 .com>, 2019
10+ # Heyi Tang <tangheyi.09@gmail .com>, 2020
11+ # Freesand Leo <yuqinju@163 .com>, 2020
1212#
1313#, fuzzy
1414msgid ""
@@ -17,7 +17,7 @@ msgstr ""
1717"Report-Msgid-Bugs-To : \n "
1818"POT-Creation-Date : 2020-05-31 09:25+0000\n "
1919"PO-Revision-Date : 2017-02-16 23:04+0000\n "
20- "Last-Translator : cdarlint <cdarling@126 .com>, 2019 \n "
20+ "Last-Translator : Freesand Leo <yuqinju@163 .com>, 2020 \n "
2121"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
2222"MIME-Version : 1.0\n "
2323"Content-Type : text/plain; charset=UTF-8\n "
@@ -28,7 +28,7 @@ msgstr ""
2828#: ../../library/contextlib.rst:2
2929msgid ""
3030":mod:`!contextlib` --- Utilities for :keyword:`!with`\\ -statement contexts"
31- msgstr ""
31+ msgstr ":mod:`!contextlib` --- 为 :keyword:`!with` \\ 语句上下文提供的工具 "
3232
3333#: ../../library/contextlib.rst:7
3434msgid "**Source code:** :source:`Lib/contextlib.py`"
@@ -40,7 +40,7 @@ msgid ""
4040":keyword:`with` statement. For more information see also "
4141":ref:`typecontextmanager` and :ref:`context-managers`."
4242msgstr ""
43- "此模块为涉及 :keyword:`with` 语句的常见任务提供了实用的程序 。更多信息请参见 :ref:`typecontextmanager` 和 "
43+ "此模块为涉及 :keyword:`with` 语句的常见任务提供了实用的工具 。更多信息请参见 :ref:`typecontextmanager` 和 "
4444":ref:`context-managers`。"
4545
4646#: ../../library/contextlib.rst:17
@@ -60,6 +60,10 @@ msgid ""
6060"default returns ``None``. See also the definition of "
6161":ref:`typecontextmanager`."
6262msgstr ""
63+ "一个为实现了 :meth:`object.__enter__` 与 :meth:`object.__exit__` 的类提供的 "
64+ ":term:`abstract base class`。为 :meth:`object.__enter__` 提供的一个默认实现是返回 ``self``"
65+ " 而 :meth:`object.__exit__` 是一个默认返回 ``None`` 的抽象方法。 参见 "
66+ ":ref:`typecontextmanager` 的定义。"
6367
6468#: ../../library/contextlib.rst:34
6569msgid ""
@@ -70,13 +74,19 @@ msgid ""
7074"default returns ``None``. See also the definition of :ref:`async-context-"
7175"managers`."
7276msgstr ""
77+ "一个为实现了 :meth:`object.__aenter__` 与 :meth:`object.__aexit__` 的类提供的 "
78+ ":term:`abstract base class`。 为 :meth:`object.__aenter__` 提供的一个默认实现是返回 "
79+ "``self`` 而 :meth:`object.__aexit__` 是一个默认返回 ``None`` 的抽象方法。 参见 :ref:`async-"
80+ "context-managers` 的定义。"
7381
7482#: ../../library/contextlib.rst:46
7583msgid ""
7684"This function is a :term:`decorator` that can be used to define a factory "
7785"function for :keyword:`with` statement context managers, without needing to "
7886"create a class or separate :meth:`__enter__` and :meth:`__exit__` methods."
7987msgstr ""
88+ "这个函数是一个 :term:`decorator` ,它可以定义一个支持 :keyword:`with` 语句上下文管理器的工厂函数, "
89+ "而不需要创建一个类或区 :meth:`__enter__` 与 :meth:`__exit__` 方法。"
8090
8191#: ../../library/contextlib.rst:50
8292msgid ""
@@ -85,12 +95,14 @@ msgid ""
8595"and doesn't implement a ``close()`` method for use with "
8696"``contextlib.closing``"
8797msgstr ""
98+ "尽管许多对象原生支持使用 with 语句,但有些需要被管理的资源并不是上下文管理器,并且没有实现 ``close()`` 方法而不能使用 "
99+ "``contextlib.closing`` 。"
88100
89101#: ../../library/contextlib.rst:54
90102msgid ""
91103"An abstract example would be the following to ensure correct resource "
92104"management::"
93- msgstr ""
105+ msgstr "下面是一个抽象的示例,展示如何确保正确的资源管理:: "
94106
95107#: ../../library/contextlib.rst:73
96108msgid ""
@@ -99,7 +111,7 @@ msgid ""
99111"the targets in the :keyword:`with` statement's :keyword:`!as` clause, if "
100112"any."
101113msgstr ""
102- "被装饰的函数在被调用时,必须返回一个 :term:`generator`-iterator。 这个迭代器必须只 yield 一个值出来,这个值会被用在 "
114+ "被装饰的函数在被调用时,必须返回一个 :term:`generator` 迭代器。 这个迭代器必须只 yield 一个值出来,这个值会被用在 "
103115":keyword:`with` 语句中,绑定到 :keyword:`!as` 后面的变量,如果给定了的话。"
104116
105117#: ../../library/contextlib.rst:77
@@ -117,6 +129,11 @@ msgid ""
117129"handled, and execution will resume with the statement immediately following "
118130"the :keyword:`!with` statement."
119131msgstr ""
132+ "当生成器发生 yield 时,嵌套在 :keyword:`with` 语句中的语句体会被执行。 语句体执行完毕离开之后,该生成器将被恢复执行。 "
133+ "如果在该语句体中发生了未处理的异常,则该异常会在生成器发生 yield 时重新被引发。 因此,你可以使用 :keyword:`try`...\\ "
134+ ":keyword:`except`...\\ :keyword:`finally` 语句来捕获该异常(如果有的话),或确保进行了一些清理。 "
135+ "如果仅出于记录日志或执行某些操作(而非完全抑制异常)的目的捕获了异常,生成器必须重新引发该异常。 否则生成器的上下文管理器将向 "
136+ ":keyword:`!with` 语句指示该异常已经被处理,程序将立即在 :keyword:`!with` 语句之后恢复并继续执行。"
120137
121138#: ../../library/contextlib.rst:89
122139msgid ""
@@ -128,10 +145,13 @@ msgid ""
128145"that context managers support multiple invocations in order to be used as "
129146"decorators)."
130147msgstr ""
148+ ":func:`contextmanager` 使用 :class:`ContextDecorator` 因此它创建的上下文管理器不仅可以用在 "
149+ ":keyword:`with` 语句中,还可以用作一个装饰器。当它用作一个装饰器时,每一次函数调用时都会隐式创建一个新的生成器实例(这使得 "
150+ ":func:`contextmanager` 创建的上下文管理器满足了支持多次调用以用作装饰器的需求,而非“一次性”的上下文管理器)。"
131151
132152#: ../../library/contextlib.rst:96
133153msgid "Use of :class:`ContextDecorator`."
134- msgstr ""
154+ msgstr ":class:`ContextDecorator` 的使用。 "
135155
136156#: ../../library/contextlib.rst:102
137157msgid ""
0 commit comments