@@ -25,7 +25,7 @@ msgstr ""
25
25
26
26
#: ../../library/contextvars.rst:2
27
27
msgid ":mod:`contextvars` --- Context Variables"
28
- msgstr ""
28
+ msgstr ":mod:`contextvars` --- Variáveis de contexto "
29
29
30
30
#: ../../library/contextvars.rst:11
31
31
msgid ""
@@ -35,37 +35,51 @@ msgid ""
35
35
"the :class:`~contextvars.Context` class should be used to manage the current "
36
36
"context in asynchronous frameworks."
37
37
msgstr ""
38
+ "Este módulo fornece APIs para gerenciar, armazenar e acessar o estado local "
39
+ "do contexto. A classe :class:`~contextvars.ContextVar` é usada para declarar "
40
+ "e trabalhar com *Variáveis de Contexto*. A função :func:`~contextvars."
41
+ "copy_context` e a classe :class:`~contextvars.Context` devem ser usadas para "
42
+ "gerenciar o contexto atual em frameworks assíncronos."
38
43
39
44
#: ../../library/contextvars.rst:17
40
45
msgid ""
41
46
"Context managers that have state should use Context Variables instead of :"
42
47
"func:`threading.local()` to prevent their state from bleeding to other code "
43
48
"unexpectedly, when used in concurrent code."
44
49
msgstr ""
50
+ "Os gerenciadores de contexto que possuem estado devem usar Variáveis de "
51
+ "Contexto ao invés de :func:`threading.local()` para evitar que seu estado "
52
+ "vaze para outro código inesperadamente, quando usado em código concorrente."
45
53
46
54
#: ../../library/contextvars.rst:21
47
55
msgid "See also :pep:`567` for additional details."
48
- msgstr ""
56
+ msgstr "Veja também a :pep:`567` para detalhes adicionais. "
49
57
50
58
#: ../../library/contextvars.rst:27
51
59
msgid "Context Variables"
52
- msgstr ""
60
+ msgstr "Variáveis de contexto "
53
61
54
62
#: ../../library/contextvars.rst:31
55
63
msgid "This class is used to declare a new Context Variable, e.g.::"
56
64
msgstr ""
65
+ "Esta classe é usada para declarar uma nova variável de contexto, como, por "
66
+ "exemplo::"
57
67
58
68
#: ../../library/contextvars.rst:35
59
69
msgid ""
60
70
"The required *name* parameter is used for introspection and debug purposes."
61
71
msgstr ""
72
+ "O parâmetro obrigatório *name* é usado para fins de introspecção e depuração."
62
73
63
74
#: ../../library/contextvars.rst:38
64
75
msgid ""
65
76
"The optional keyword-only *default* parameter is returned by :meth:"
66
77
"`ContextVar.get` when no value for the variable is found in the current "
67
78
"context."
68
79
msgstr ""
80
+ "O parâmetro somente-nomeado opcional *default* é retornado por :meth:"
81
+ "`ContextVar.get` quando nenhum valor para a variável é encontrado no "
82
+ "contexto atual."
69
83
70
84
#: ../../library/contextvars.rst:42
71
85
msgid ""
@@ -74,57 +88,71 @@ msgid ""
74
88
"context variables which prevents context variables from being properly "
75
89
"garbage collected."
76
90
msgstr ""
91
+ "**Importante:** Variáveis de Contexto devem ser criadas no nível do módulo "
92
+ "superior e nunca em fechamentos. Os objetos :class:`Context` contêm "
93
+ "referências fortes a variáveis de contexto que evitam que as variáveis de "
94
+ "contexto sejam coletadas como lixo corretamente."
77
95
78
96
#: ../../library/contextvars.rst:49
79
97
msgid "The name of the variable. This is a read-only property."
80
- msgstr ""
98
+ msgstr "O nome da variável. Esta é uma propriedade somente leitura. "
81
99
82
100
#: ../../library/contextvars.rst:55
83
101
msgid "Return a value for the context variable for the current context."
84
- msgstr ""
102
+ msgstr "Retorna um valor para a variável de contexto para o contexto atual. "
85
103
86
104
#: ../../library/contextvars.rst:57
87
105
msgid ""
88
106
"If there is no value for the variable in the current context, the method "
89
107
"will:"
90
- msgstr ""
108
+ msgstr "Se não houver valor para a variável no contexto atual, o método vai: "
91
109
92
110
#: ../../library/contextvars.rst:60
93
111
msgid ""
94
112
"return the value of the *default* argument of the method, if provided; or"
95
- msgstr ""
113
+ msgstr "retornar o valor do argumento *default* do método, se fornecido; ou "
96
114
97
115
#: ../../library/contextvars.rst:63
98
116
msgid ""
99
117
"return the default value for the context variable, if it was created with "
100
118
"one; or"
101
119
msgstr ""
120
+ "retornar o valor padrão para a variável de contexto, se ela foi criada com "
121
+ "uma; ou"
102
122
103
123
#: ../../library/contextvars.rst:66
104
124
msgid "raise a :exc:`LookupError`."
105
- msgstr ""
125
+ msgstr "levantar uma :exc:`LookupError`. "
106
126
107
127
#: ../../library/contextvars.rst:70
108
128
msgid ""
109
129
"Call to set a new value for the context variable in the current context."
110
130
msgstr ""
131
+ "Chame para definir um novo valor para a variável de contexto no contexto "
132
+ "atual."
111
133
112
134
#: ../../library/contextvars.rst:73
113
135
msgid ""
114
136
"The required *value* argument is the new value for the context variable."
115
137
msgstr ""
138
+ "O argumento *value* obrigatório é o novo valor para a variável de contexto."
116
139
117
140
#: ../../library/contextvars.rst:76
118
141
msgid ""
119
142
"Returns a :class:`~contextvars.Token` object that can be used to restore the "
120
143
"variable to its previous value via the :meth:`ContextVar.reset` method."
121
144
msgstr ""
145
+ "Retorna um objeto :class:`~contextvars.Token` que pode ser usado para "
146
+ "restaurar a variável ao seu valor anterior através do método :meth:"
147
+ "`ContextVar.reset`."
122
148
123
149
#: ../../library/contextvars.rst:82
124
150
msgid ""
125
151
"Reset the context variable to the value it had before the :meth:`ContextVar."
126
152
"set` that created the *token* was used."
127
153
msgstr ""
154
+ "Redefine a variável de contexto para o valor que tinha antes de :meth: "
155
+ "`ContextVar.set`. que criou o *token*, ser usado."
128
156
129
157
#: ../../library/contextvars.rst:85
130
158
msgid "For example::"
@@ -136,120 +164,154 @@ msgid ""
136
164
"be passed to the :meth:`ContextVar.reset` method to revert the value of the "
137
165
"variable to what it was before the corresponding *set*."
138
166
msgstr ""
167
+ "Objetos *token* são retornados pelo método :meth:`ContextVar.set`. Eles "
168
+ "podem ser passados para o método :meth:`ContextVar.reset` para reverter o "
169
+ "valor da variável para o que era antes do *set* correspondente."
139
170
140
171
#: ../../library/contextvars.rst:106
141
172
msgid ""
142
173
"A read-only property. Points to the :class:`ContextVar` object that created "
143
174
"the token."
144
175
msgstr ""
176
+ "Uma propriedade somente leitura. Aponta para o objeto :class:`ContextVar` "
177
+ "que criou o token."
145
178
146
179
#: ../../library/contextvars.rst:111
147
180
msgid ""
148
181
"A read-only property. Set to the value the variable had before the :meth:"
149
182
"`ContextVar.set` method call that created the token. It points to :attr:"
150
183
"`Token.MISSING` is the variable was not set before the call."
151
184
msgstr ""
185
+ "Uma propriedade somente leitura. Defina com o valor que a variável tinha "
186
+ "antes da chamada do método :meth:`ContextVar.set` que criou o token. Ele "
187
+ "aponta para :attr:`Token.MISSING` é a variável não foi definida antes da "
188
+ "chamada."
152
189
153
190
#: ../../library/contextvars.rst:118
154
191
msgid "A marker object used by :attr:`Token.old_value`."
155
- msgstr ""
192
+ msgstr "Um objeto marcador usado por :attr:`Token.old_value`. "
156
193
157
194
#: ../../library/contextvars.rst:122
158
195
msgid "Manual Context Management"
159
- msgstr "Gerenciamento de Contexto Manual "
196
+ msgstr "Gerenciamento de contexto manual "
160
197
161
198
#: ../../library/contextvars.rst:126
162
199
msgid "Returns a copy of the current :class:`~contextvars.Context` object."
163
- msgstr ""
200
+ msgstr "Retorna uma cópia do objeto :class:`~contextvars.Context` atual. "
164
201
165
202
#: ../../library/contextvars.rst:128
166
203
msgid ""
167
204
"The following snippet gets a copy of the current context and prints all "
168
205
"variables and their values that are set in it::"
169
206
msgstr ""
207
+ "O trecho a seguir obtém uma cópia do contexto atual e imprime todas as "
208
+ "variáveis e seus valores que são definidos nele::"
170
209
171
210
#: ../../library/contextvars.rst:134
172
211
msgid ""
173
212
"The function has an O(1) complexity, i.e. works equally fast for contexts "
174
213
"with a few context variables and for contexts that have a lot of them."
175
214
msgstr ""
215
+ "A função tem uma complexidade O(1), ou seja, funciona igualmente rápido para "
216
+ "contextos com algumas variáveis de contexto e para contextos que têm muitas "
217
+ "delas."
176
218
177
219
#: ../../library/contextvars.rst:141
178
220
msgid "A mapping of :class:`ContextVars <ContextVar>` to their values."
179
- msgstr ""
221
+ msgstr "Um mapeamento de :class:`ContextVars <ContextVar>` para seus valores. "
180
222
181
223
#: ../../library/contextvars.rst:143
182
224
msgid ""
183
225
"``Context()`` creates an empty context with no values in it. To get a copy "
184
226
"of the current context use the :func:`~contextvars.copy_context` function."
185
227
msgstr ""
228
+ "``Context()`` cria um contexto vazio sem valores nele. Para obter uma cópia "
229
+ "do contexto atual, use a função :func:`~contextvars.copy_context`."
186
230
187
231
#: ../../library/contextvars.rst:147
188
232
msgid "Context implements the :class:`collections.abc.Mapping` interface."
189
- msgstr ""
233
+ msgstr "Context implementa a interface :class:`collections.abc.Mapping`. "
190
234
191
235
#: ../../library/contextvars.rst:151
192
236
msgid ""
193
237
"Execute ``callable(*args, **kwargs)`` code in the context object the *run* "
194
238
"method is called on. Return the result of the execution or propagate an "
195
239
"exception if one occurred."
196
240
msgstr ""
241
+ "Executa o código ``callable(*args, **kwargs)`` no objeto contexto em que o "
242
+ "método *run* é chamado. Retorna o resultado da execução ou propaga uma "
243
+ "exceção, se ocorrer."
197
244
198
245
#: ../../library/contextvars.rst:155
199
246
msgid ""
200
247
"Any changes to any context variables that *callable* makes will be contained "
201
248
"in the context object::"
202
249
msgstr ""
250
+ "Quaisquer mudanças em quaisquer variáveis de contexto que *callable* faça "
251
+ "estarão contidas no objeto de contexto::"
203
252
204
253
#: ../../library/contextvars.rst:184
205
254
msgid ""
206
255
"The method raises a :exc:`RuntimeError` when called on the same context "
207
256
"object from more than one OS thread, or when called recursively."
208
257
msgstr ""
258
+ "O método levanta uma :exc:`RuntimeError` quando chamado no mesmo objeto de "
259
+ "contexto de mais de uma thread do sistema operacional, ou quando chamado "
260
+ "recursivamente."
209
261
210
262
#: ../../library/contextvars.rst:190
211
263
msgid "Return a shallow copy of the context object."
212
- msgstr ""
264
+ msgstr "Retorna uma cópia rasa do objeto contexto. "
213
265
214
266
#: ../../library/contextvars.rst:194
215
267
msgid ""
216
268
"Return ``True`` if the *context* has a value for *var* set; return ``False`` "
217
269
"otherwise."
218
270
msgstr ""
271
+ "Retorna ``True`` se *context* tem uma variável para *var* definida; do "
272
+ "contrário, retorna ``False``."
219
273
220
274
#: ../../library/contextvars.rst:199
221
275
msgid ""
222
276
"Return the value of the *var* :class:`ContextVar` variable. If the variable "
223
277
"is not set in the context object, a :exc:`KeyError` is raised."
224
278
msgstr ""
279
+ "Retorna o valor da variável :class:`ContextVar` *var*. Se a variável não for "
280
+ "definida no objeto contexto, uma :exc:`KeyError` é levantada."
225
281
226
282
#: ../../library/contextvars.rst:205
227
283
msgid ""
228
284
"Return the value for *var* if *var* has the value in the context object. "
229
285
"Return *default* otherwise. If *default* is not given, return ``None``."
230
286
msgstr ""
287
+ "Retorna o valor para *var* se *var* tiver o valor no objeto contexto. Caso "
288
+ "contrário, retorna *default*. Se *default* não for fornecido, retorna "
289
+ "``None``."
231
290
232
291
#: ../../library/contextvars.rst:211
233
292
msgid "Return an iterator over the variables stored in the context object."
234
- msgstr ""
293
+ msgstr "Retorna um iterador sobre as variáveis armazenadas no objeto contexto. "
235
294
236
295
#: ../../library/contextvars.rst:216
237
296
msgid "Return the number of variables set in the context object."
238
- msgstr ""
297
+ msgstr "Retorna o número das variáveis definidas no objeto contexto. "
239
298
240
299
#: ../../library/contextvars.rst:220
241
300
msgid "Return a list of all variables in the context object."
242
- msgstr ""
301
+ msgstr "Retorna uma lista de todas as variáveis no objeto contexto. "
243
302
244
303
#: ../../library/contextvars.rst:224
245
304
msgid "Return a list of all variables' values in the context object."
246
305
msgstr ""
306
+ "Retorna uma lista dos valores de todas as variáveis no objeto contexto."
247
307
248
308
#: ../../library/contextvars.rst:229
249
309
msgid ""
250
310
"Return a list of 2-tuples containing all variables and their values in the "
251
311
"context object."
252
312
msgstr ""
313
+ "Retorna uma lista de tuplas de 2 elementos contendo todas as variáveis e "
314
+ "seus valores no objeto contexto."
253
315
254
316
#: ../../library/contextvars.rst:234
255
317
msgid "asyncio support"
@@ -262,3 +324,8 @@ msgid ""
262
324
"server, that uses a context variable to make the address of a remote client "
263
325
"available in the Task that handles that client::"
264
326
msgstr ""
327
+ "Variáveis de contexto encontram suporte nativo em :mod:`asyncio` e estão "
328
+ "prontas para serem usadas sem qualquer configuração extra. Por exemplo, aqui "
329
+ "está um servidor simples de eco, que usa uma variável de contexto para "
330
+ "disponibilizar o endereço de um cliente remoto na Task que lida com esse "
331
+ "cliente::"
0 commit comments