55#
66# Translators:
77# cdarlint <[email protected] >, 20208- # Freesand Leo <[email protected] >, 202098# dannyvi <[email protected] >, 2020109# Meng Du <[email protected] >, 2020111011+ # Heyi Tang <[email protected] >, 202012+ # Freesand Leo <[email protected] >, 20201213#
1314#, fuzzy
1415msgid ""
@@ -17,7 +18,7 @@ msgstr ""
1718"Report-Msgid-Bugs-To : \n "
1819"POT-Creation-Date : 2020-02-09 12:40+0000\n "
1920"PO-Revision-Date : 2020-05-30 11:58+0000\n "
20- "Last-Translator : nick <2330458484@qq .com>, 2020\n "
21+ "Last-Translator : Freesand Leo <yuqinju@163 .com>, 2020\n "
2122"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
2223"MIME-Version : 1.0\n "
2324"Content-Type : text/plain; charset=UTF-8\n "
@@ -28,7 +29,7 @@ msgstr ""
2829#: ../../library/contextlib.rst:2
2930msgid ""
3031":mod:`!contextlib` --- Utilities for :keyword:`!with`\\ -statement contexts"
31- msgstr ""
32+ msgstr ":mod:`!contextlib` --- 为 :keyword:`!with` \\ 语句上下文提供的工具 "
3233
3334#: ../../library/contextlib.rst:7
3435msgid "**Source code:** :source:`Lib/contextlib.py`"
@@ -60,6 +61,10 @@ msgid ""
6061"default returns ``None``. See also the definition of "
6162":ref:`typecontextmanager`."
6263msgstr ""
64+ "一个为实现了 :meth:`object.__aenter__` 与 :meth:`object.__aexit__` 的类提供的 "
65+ ":term:`abstract base class`。 为 :meth:`object.__aenter__` 提供的一个默认实现是返回 "
66+ "``self`` 而 :meth:`object.__aexit__` 是一个默认返回 ``None`` 的抽象方法。 参见 :ref:`async-"
67+ "context-managers` 的定义。"
6368
6469#: ../../library/contextlib.rst:34
6570msgid ""
@@ -70,13 +75,19 @@ msgid ""
7075"default returns ``None``. See also the definition of :ref:`async-context-"
7176"managers`."
7277msgstr ""
78+ "一个为实现了 :meth:`object.__aenter__` 与 :meth:`object.__aexit__` 的类提供的 "
79+ ":term:`abstract base class`。 为 :meth:`object.__aenter__` 提供的一个默认实现是返回 "
80+ "``self`` 而 :meth:`object.__aexit__` 是一个默认返回 ``None`` 的抽象方法。 参见 :ref:`async-"
81+ "context-managers` 的定义。"
7382
7483#: ../../library/contextlib.rst:46
7584msgid ""
7685"This function is a :term:`decorator` that can be used to define a factory "
7786"function for :keyword:`with` statement context managers, without needing to "
7887"create a class or separate :meth:`__enter__` and :meth:`__exit__` methods."
7988msgstr ""
89+ "这个函数是一个 :term:`decorator` ,它可以定义一个支持 :keyword:`with` 语句上下文的工厂函数, 而不需要创建一个类或区"
90+ " :meth:`__enter__` 与 :meth:`__exit__` 方法。"
8091
8192#: ../../library/contextlib.rst:50
8293msgid ""
@@ -85,12 +96,14 @@ msgid ""
8596"and doesn't implement a ``close()`` method for use with "
8697"``contextlib.closing``"
8798msgstr ""
99+ "尽管许多对象原生支持使用 with 语句,但有些需要被管理的资源并不是上下文管理器,并且没有实现 ``close()`` 方法而不能使用 "
100+ "``contextlib.closing`` 。"
88101
89102#: ../../library/contextlib.rst:54
90103msgid ""
91104"An abstract example would be the following to ensure correct resource "
92105"management::"
93- msgstr ""
106+ msgstr "下面是一个抽象的示例,展示如何确保正确的资源管理: "
94107
95108#: ../../library/contextlib.rst:73
96109msgid ""
@@ -117,6 +130,11 @@ msgid ""
117130"handled, and execution will resume with the statement immediately following "
118131"the :keyword:`!with` statement."
119132msgstr ""
133+ "当生成器发生 yield 时,嵌套在 :keyword:`with` 语句中的语句体会被执行。 语句体执行完毕离开之后,该生成器将被恢复执行。 "
134+ "如果在该语句体中发生了未处理的异常,则该异常会在生成器发生 yield 时重新被引发。 因此,你可以使用 :keyword:`try`...\\ "
135+ ":keyword:`except`...\\ :keyword:`finally` 语句来捕获该异常(如果有的话),或确保进行了一些清理。 "
136+ "如果仅出于记录日志或执行某些操作(而非完全抑制异常)的目的捕获了异常,生成器必须重新引发该异常。 否则生成器的上下文管理器将向 "
137+ ":keyword:`!with` 语句指示该异常已经被处理,程序将立即在 :keyword:`!with` 语句之后恢复并继续执行。"
120138
121139#: ../../library/contextlib.rst:89
122140msgid ""
@@ -128,10 +146,13 @@ msgid ""
128146"that context managers support multiple invocations in order to be used as "
129147"decorators)."
130148msgstr ""
149+ ":func:`contextmanager` 使用 :class:`ContextDecorator` 因此它创建的上下文管理器不仅可以用在 "
150+ ":keyword:`with` 语句中,还可以用作一个装饰器。当它用作一个装饰器时,每一次函数调用时都会隐式创建一个新的生成器实例(这使得 "
151+ ":func:`contextmanager` 创建的上下文管理器满足了支持多次调用以用作装饰器的需求,而非“一次性”的上下文管理器)。"
131152
132153#: ../../library/contextlib.rst:96
133154msgid "Use of :class:`ContextDecorator`."
134- msgstr ""
155+ msgstr ":class:`ContextDecorator` 的使用。 "
135156
136157#: ../../library/contextlib.rst:102
137158msgid ""
0 commit comments