66# Translators:
77# ww song <[email protected] >, 201888# zeroswan <[email protected] >, 20209+ # Freesand Leo <[email protected] >, 2020910#
1011#, fuzzy
1112msgid ""
@@ -14,7 +15,7 @@ msgstr ""
1415"Report-Msgid-Bugs-To : \n "
1516"POT-Creation-Date : 2020-05-31 09:25+0000\n "
1617"PO-Revision-Date : 2018-06-29 21:06+0000\n "
17- "Last-Translator : zeroswan <weditor @163.com>, 2020\n "
18+ "Last-Translator : Freesand Leo <yuqinju @163.com>, 2020\n "
1819"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
1920"MIME-Version : 1.0\n "
2021"Content-Type : text/plain; charset=UTF-8\n "
@@ -24,7 +25,7 @@ msgstr ""
2425
2526#: ../../library/contextvars.rst:2
2627msgid ":mod:`contextvars` --- Context Variables"
27- msgstr ":mod:`contextvars` 上下文变量"
28+ msgstr ":mod:`contextvars` --- 上下文变量"
2829
2930#: ../../library/contextvars.rst:11
3031msgid ""
@@ -124,12 +125,14 @@ msgid ""
124125"Returns a :class:`~contextvars.Token` object that can be used to restore the"
125126" variable to its previous value via the :meth:`ContextVar.reset` method."
126127msgstr ""
128+ "返回一个 :class:`~contextvars.Token` 对象,可通过 :meth:`ContextVar.reset` "
129+ "方法将上下文变量还原为之前某个状态。"
127130
128131#: ../../library/contextvars.rst:82
129132msgid ""
130133"Reset the context variable to the value it had before the "
131134":meth:`ContextVar.set` that created the *token* was used."
132- msgstr ""
135+ msgstr "将上下文变量重置为调用 :meth:`ContextVar.set` 之前、创建 *token* 时候的状态。 "
133136
134137#: ../../library/contextvars.rst:85
135138msgid "For example::"
@@ -141,124 +144,135 @@ msgid ""
141144"be passed to the :meth:`ContextVar.reset` method to revert the value of the "
142145"variable to what it was before the corresponding *set*."
143146msgstr ""
147+ ":meth:`ContextVar.set` 方法返回 *Token* 对象。此对象可以传递给 :meth:`ContextVar.reset` "
148+ "方法用于将上下文变量还原为调用 *set* 前的状态。"
144149
145150#: ../../library/contextvars.rst:106
146151msgid ""
147152"A read-only property. Points to the :class:`ContextVar` object that created"
148153" the token."
149- msgstr ""
154+ msgstr "只读属性。指向创建此 token 的 :class:`ContextVar` 对象。 "
150155
151156#: ../../library/contextvars.rst:111
152157msgid ""
153158"A read-only property. Set to the value the variable had before the "
154159":meth:`ContextVar.set` method call that created the token. It points to "
155160":attr:`Token.MISSING` is the variable was not set before the call."
156161msgstr ""
162+ "一个只读属性。 会被设为在创建此令牌的 :meth:`ContextVar.set` 方法调用之前该变量所具有的值。 它指向的 "
163+ ":attr:`Token.MISSING` 是在调用之前未设置的变量。"
157164
158165#: ../../library/contextvars.rst:118
159166msgid "A marker object used by :attr:`Token.old_value`."
160- msgstr ""
167+ msgstr ":attr:`Token.old_value` 会用到的一个标记对象。 "
161168
162169#: ../../library/contextvars.rst:122
163170msgid "Manual Context Management"
164- msgstr ""
171+ msgstr "手动上下文管理 "
165172
166173#: ../../library/contextvars.rst:126
167174msgid "Returns a copy of the current :class:`~contextvars.Context` object."
168- msgstr ""
175+ msgstr "返回当前上下文中 :class:`~contextvars.Context` 对象的拷贝。 "
169176
170177#: ../../library/contextvars.rst:128
171178msgid ""
172179"The following snippet gets a copy of the current context and prints all "
173180"variables and their values that are set in it::"
174- msgstr ""
181+ msgstr "以下代码片段会获取当前上下文的拷贝并打印设置到其中的所有变量及其值:: "
175182
176183#: ../../library/contextvars.rst:134
177184msgid ""
178185"The function has an O(1) complexity, i.e. works equally fast for contexts "
179186"with a few context variables and for contexts that have a lot of them."
180- msgstr ""
187+ msgstr "此函数复杂度为 O(1) ,也就是说对于只包含几个上下文变量和很多上下文变量的情况,他们是一样快的。 "
181188
182189#: ../../library/contextvars.rst:141
183190msgid "A mapping of :class:`ContextVars <ContextVar>` to their values."
184- msgstr ""
191+ msgstr ":class:`ContextVars <ContextVar>` 中所有值的映射。 "
185192
186193#: ../../library/contextvars.rst:143
187194msgid ""
188195"``Context()`` creates an empty context with no values in it. To get a copy "
189196"of the current context use the :func:`~contextvars.copy_context` function."
190197msgstr ""
198+ "``Context()`` 创建一个不包含任何值的空上下文。如果要获取当前上下文的拷贝,使用 "
199+ ":func:`~contextvars.copy_context` 函数。"
191200
192201#: ../../library/contextvars.rst:147
193202msgid "Context implements the :class:`collections.abc.Mapping` interface."
194- msgstr ""
203+ msgstr "Context 实现了 :class:`collections.abc.Mapping` 接口。 "
195204
196205#: ../../library/contextvars.rst:151
197206msgid ""
198207"Execute ``callable(*args, **kwargs)`` code in the context object the *run* "
199208"method is called on. Return the result of the execution or propagate an "
200209"exception if one occurred."
201210msgstr ""
211+ "按照 *run* 方法中的参数在上下文对象中执行 ``callable(*args, **kwargs)`` "
212+ "代码。返回执行结果,如果发生异常,则将异常透传出来。"
202213
203214#: ../../library/contextvars.rst:155
204215msgid ""
205216"Any changes to any context variables that *callable* makes will be contained"
206217" in the context object::"
207- msgstr ""
218+ msgstr "*callable* 中队上下文变量做出的任何修改会保留在上下文对象中:: "
208219
209220#: ../../library/contextvars.rst:184
210221msgid ""
211222"The method raises a :exc:`RuntimeError` when called on the same context "
212223"object from more than one OS thread, or when called recursively."
213- msgstr ""
224+ msgstr "当在多个系统线程或者递归调用同一个上下文对象的此方法,抛出 :exc:`RuntimeError` 异常。 "
214225
215226#: ../../library/contextvars.rst:190
216227msgid "Return a shallow copy of the context object."
217- msgstr ""
228+ msgstr "返回此上下文对象的浅拷贝。 "
218229
219230#: ../../library/contextvars.rst:194
220231msgid ""
221232"Return ``True`` if the *context* has a value for *var* set; return ``False``"
222233" otherwise."
223- msgstr ""
234+ msgstr "如果*context* 中含有名称为 *var* 的变量,返回 ``True`` , 否则返回 ``False`` 。 "
224235
225236#: ../../library/contextvars.rst:199
226237msgid ""
227238"Return the value of the *var* :class:`ContextVar` variable. If the variable "
228239"is not set in the context object, a :exc:`KeyError` is raised."
229240msgstr ""
241+ "返回名称为 *var* 的 :class:`ContextVar` 变量。如果上下文对象中不包含这个变量,则抛出 :exc:`KeyError` 异常。"
230242
231243#: ../../library/contextvars.rst:205
232244msgid ""
233245"Return the value for *var* if *var* has the value in the context object. "
234246"Return *default* otherwise. If *default* is not given, return ``None``."
235247msgstr ""
248+ "如果 *var* 在上下文对象中具有值则返回 *var* 的值。 在其他情况下返回 *default*。 如果未给出 *default* 则返回 "
249+ "``None``。"
236250
237251#: ../../library/contextvars.rst:211
238252msgid "Return an iterator over the variables stored in the context object."
239- msgstr ""
253+ msgstr "返回一个存储在上下文对象中的变量的迭代器。 "
240254
241255#: ../../library/contextvars.rst:216
242256msgid "Return the number of variables set in the context object."
243- msgstr ""
257+ msgstr "返回上下文对象中所设的变量的数量。 "
244258
245259#: ../../library/contextvars.rst:220
246260msgid "Return a list of all variables in the context object."
247- msgstr ""
261+ msgstr "返回上下文对象中的所有变量的列表。 "
248262
249263#: ../../library/contextvars.rst:224
250264msgid "Return a list of all variables' values in the context object."
251- msgstr ""
265+ msgstr "返回上下文对象中所有变量值的列表。 "
252266
253267#: ../../library/contextvars.rst:229
254268msgid ""
255269"Return a list of 2-tuples containing all variables and their values in the "
256270"context object."
257- msgstr ""
271+ msgstr "返回包含上下文对象中所有变量及其值的 2 元组的列表。 "
258272
259273#: ../../library/contextvars.rst:234
260274msgid "asyncio support"
261- msgstr ""
275+ msgstr "asyncio 支持 "
262276
263277#: ../../library/contextvars.rst:236
264278msgid ""
@@ -267,3 +281,5 @@ msgid ""
267281" server, that uses a context variable to make the address of a remote client"
268282" available in the Task that handles that client::"
269283msgstr ""
284+ "上下文变量在 :mod:`asyncio` 中有原生的支持并且无需任何额外配置即可被使用。 "
285+ "例如,以下是一个简单的回显服务器,它使用上下文变量来让远程客户端的地址在处理该客户端的 Task 中可用::"
0 commit comments