- Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathcontextvars.po
461 lines (405 loc) · 17.7 KB
/
contextvars.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Osamu NAKAMURA, 2021
# Arihiro TAKASE, 2023
# 石井明久, 2024
# tomo, 2024
#
#,fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-04-11 14:19+0000\n"
"PO-Revision-Date: 2021-06-28 00:57+0000\n"
"Last-Translator: tomo, 2024\n"
"Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/"
"ja/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ja\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#:../../library/contextvars.rst:2
msgid":mod:`!contextvars` --- Context Variables"
msgstr":mod:`!contextvars` --- コンテキスト変数"
#:../../library/contextvars.rst:11
msgid""
"This module provides APIs to manage, store, and access context-local state. "
"The :class:`~contextvars.ContextVar` class is used to declare and work with "
"*Context Variables*. The :func:`~contextvars.copy_context` function and "
"the :class:`~contextvars.Context` class should be used to manage the current "
"context in asynchronous frameworks."
msgstr""
"このモジュールは、コンテキストローカルな状態を管理し、保持し、アクセスするた"
"めの API を提供します。\n"
":class:`~contextvars.ContextVar` クラスは *コンテキスト変数* を宣言し、取り扱"
"うために使われます。\n"
"非同期フレームワークで現時点のコンテキストを管理するのには、 :func:"
"`~contextvars.copy_context` 関数と :class:`~contextvars.Context` クラスを使う"
"べきです。"
#:../../library/contextvars.rst:17
msgid""
"Context managers that have state should use Context Variables instead of :"
"func:`threading.local` to prevent their state from bleeding to other code "
"unexpectedly, when used in concurrent code."
msgstr""
#:../../library/contextvars.rst:21
msgid"See also :pep:`567` for additional details."
msgstr"より詳しくは :pep:`567` を参照をしてください。"
#:../../library/contextvars.rst:27
msgid"Context Variables"
msgstr"コンテキスト変数"
#:../../library/contextvars.rst:31
msgid"This class is used to declare a new Context Variable, e.g.::"
msgstr""
"このクラスは新しいコンテキスト変数を宣言するのに使われます。例えば、次の通り"
"です:"
#:../../library/contextvars.rst:33
msgid"var: ContextVar[int] = ContextVar('var', default=42)"
msgstr""
#:../../library/contextvars.rst:35
msgid""
"The required *name* parameter is used for introspection and debug purposes."
msgstr"必須のパラメータの *name* は内観やデバッグの目的で使われます。"
#:../../library/contextvars.rst:38
msgid""
"The optional keyword-only *default* parameter is returned by :meth:"
"`ContextVar.get` when no value for the variable is found in the current "
"context."
msgstr""
"オプションのキーワード専用引数 *default* は、現在のコンテキストにその変数の値"
"が見付からなかったときに :meth:`ContextVar.get` から返されます。"
#:../../library/contextvars.rst:42
msgid""
"**Important:** Context Variables should be created at the top module level "
"and never in closures. :class:`Context` objects hold strong references to "
"context variables which prevents context variables from being properly "
"garbage collected."
msgstr""
"**重要:** コンテキスト変数は、モジュールのトップレベルで生成する必要があり、"
"クロージャの中で作成すべきではありません。:class:`Context` オブジェクトはコン"
"テキスト変数への強参照を持っており、コンテキスト変数がガーベジコレクトされる"
"のを防ぎます。"
#:../../library/contextvars.rst:49
msgid"The name of the variable. This is a read-only property."
msgstr"変数の名前。読み出し専用のプロパティです。"
#:../../library/contextvars.rst:55
msgid"Return a value for the context variable for the current context."
msgstr"現在のコンテキストのコンテキスト変数の値を返します。"
#:../../library/contextvars.rst:57
msgid""
"If there is no value for the variable in the current context, the method "
"will:"
msgstr"現在のコンテキストのコンテキスト変数に値がなければ、メソッドは:"
#:../../library/contextvars.rst:60
msgid""
"return the value of the *default* argument of the method, if provided; or"
msgstr""
"メソッドの *default* 引数に値が指定されていればその値を返します。さもなければ"
#:../../library/contextvars.rst:63
msgid""
"return the default value for the context variable, if it was created with "
"one; or"
msgstr""
"コンテキスト変数が生成された時にデフォルト値が渡されていれば、その値を返しま"
"す。さもなければ"
#:../../library/contextvars.rst:66
msgid"raise a :exc:`LookupError`."
msgstr":exc:`LookupError` を送出します。"
#:../../library/contextvars.rst:70
msgid""
"Call to set a new value for the context variable in the current context."
msgstr""
"現在のコンテキストのコンテキスト変数に新しい値を設定する際に呼び出します。"
#:../../library/contextvars.rst:73
msgid""
"The required *value* argument is the new value for the context variable."
msgstr"*value* は必須の引数で、コンテキスト変数の新しい値を指定します。"
#:../../library/contextvars.rst:76
msgid""
"Returns a :class:`~contextvars.Token` object that can be used to restore the "
"variable to its previous value via the :meth:`ContextVar.reset` method."
msgstr""
":class:`~contextvars.Token` オブジェクトを返します。このオブジェクトを :meth:"
"`ContextVar.reset` メソッドに渡すことで、以前の値に戻すことができます。"
#:../../library/contextvars.rst:82
msgid""
"Reset the context variable to the value it had before the :meth:`ContextVar."
"set` that created the *token* was used."
msgstr""
"コンテキスト変数の値を、 *token* を生成した :meth:`ContextVar.set` が呼び出さ"
"れる前の値にリセットします。"
#:../../library/contextvars.rst:85
msgid"For example::"
msgstr"例えば::"
#:../../library/contextvars.rst:87
msgid""
"var = ContextVar('var')\n"
"\n"
"token = var.set('new value')\n"
"# code that uses 'var'; var.get() returns 'new value'.\n"
"var.reset(token)\n"
"\n"
"# After the reset call the var has no value again, so\n"
"# var.get() would raise a LookupError."
msgstr""
#:../../library/contextvars.rst:99
msgid""
"*Token* objects are returned by the :meth:`ContextVar.set` method. They can "
"be passed to the :meth:`ContextVar.reset` method to revert the value of the "
"variable to what it was before the corresponding *set*."
msgstr""
"*Token* オブジェクトは、:meth:`ContextVar.set` メソッドによって返されるオブ"
"ジェクトです。このオブジェクトを :meth:`ContextVar.reset` メソッドに渡すこと"
"で、対応する *set* を呼び出す前のコンテキスト変数の値に戻せます。"
#:../../library/contextvars.rst:106
msgid""
"A read-only property. Points to the :class:`ContextVar` object that created "
"the token."
msgstr""
"読み出し専用のプロパティです。トークンを生成した :class:`ContextVar` オブジェ"
"クトを指します。"
#:../../library/contextvars.rst:111
msgid""
"A read-only property. Set to the value the variable had before the :meth:"
"`ContextVar.set` method call that created the token. It points to :attr:"
"`Token.MISSING` if the variable was not set before the call."
msgstr""
"読み出し専用のプロパティです。このトークンを作成した :meth:`ContextVar.set` "
"メソッドの呼び出しの前に持っていた値に設定されています。もし呼び出しの前に値"
"が設定されていなければ :attr:`Token.MISSING` を指します。"
#:../../library/contextvars.rst:118
msgid"A marker object used by :attr:`Token.old_value`."
msgstr":attr:`Token.old_value` で利用されるマーカーオブジェクトです。"
#:../../library/contextvars.rst:122
msgid"Manual Context Management"
msgstr"マニュアルでのコンテキスト管理"
#:../../library/contextvars.rst:126
msgid"Returns a copy of the current :class:`~contextvars.Context` object."
msgstr"現在の :class:`~contextvars.Context` オブジェクトのコピーを返します。"
#:../../library/contextvars.rst:128
msgid""
"The following snippet gets a copy of the current context and prints all "
"variables and their values that are set in it::"
msgstr""
"次のスニペットは、現在のコンテキストのコピーを取得し、コンテキストに設定され"
"ているすべての変数とその値を表示します::"
#:../../library/contextvars.rst:131
msgid""
"ctx: Context = copy_context()\n"
"print(list(ctx.items()))"
msgstr""
#:../../library/contextvars.rst:134
msgid""
"The function has an *O*\\ (1) complexity, i.e. works equally fast for "
"contexts with a few context variables and for contexts that have a lot of "
"them."
msgstr""
"この関数の複雑性は *O*\\ (1) です。つまり、少数のコンテキスト変数を持つコンテ"
"キストと多くの変数を持つコンテキストで同程度の速度で動作します。"
#:../../library/contextvars.rst:141
msgid"A mapping of :class:`ContextVars <ContextVar>` to their values."
msgstr":class:`ContextVars` とその値の対応付け。"
#:../../library/contextvars.rst:143
msgid""
"``Context()`` creates an empty context with no values in it. To get a copy "
"of the current context use the :func:`~contextvars.copy_context` function."
msgstr""
"``Context()`` は、値を持たない空のコンテキストを生成します。現在のコンテキス"
"トのコピーを得るには、:func:`~contextvars.copy_context` 関数を利用します。"
#:../../library/contextvars.rst:147
msgid""
"Each thread has its own effective stack of :class:`!Context` objects. The :"
"term:`current context` is the :class:`!Context` object at the top of the "
"current thread's stack. All :class:`!Context` objects in the stacks are "
"considered to be *entered*."
msgstr""
#:../../library/contextvars.rst:152
msgid""
"*Entering* a context, which can be done by calling its :meth:`~Context.run` "
"method, makes the context the current context by pushing it onto the top of "
"the current thread's context stack."
msgstr""
#:../../library/contextvars.rst:156
msgid""
"*Exiting* from the current context, which can be done by returning from the "
"callback passed to the :meth:`~Context.run` method, restores the current "
"context to what it was before the context was entered by popping the context "
"off the top of the context stack."
msgstr""
#:../../library/contextvars.rst:161
msgid""
"Since each thread has its own context stack, :class:`ContextVar` objects "
"behave in a similar fashion to :func:`threading.local` when values are "
"assigned in different threads."
msgstr""
#:../../library/contextvars.rst:165
msgid""
"Attempting to enter an already entered context, including contexts entered "
"in other threads, raises a :exc:`RuntimeError`."
msgstr""
#:../../library/contextvars.rst:168
msgid"After exiting a context, it can later be re-entered (from any thread)."
msgstr""
#:../../library/contextvars.rst:170
msgid""
"Any changes to :class:`ContextVar` values via the :meth:`ContextVar.set` "
"method are recorded in the current context. The :meth:`ContextVar.get` "
"method returns the value associated with the current context. Exiting a "
"context effectively reverts any changes made to context variables while the "
"context was entered (if needed, the values can be restored by re-entering "
"the context)."
msgstr""
#:../../library/contextvars.rst:177
msgid"Context implements the :class:`collections.abc.Mapping` interface."
msgstr""
"Context は、 :class:`collections.abc.Mapping` インターフェースを実装します。"
#:../../library/contextvars.rst:181
msgid""
"Enters the Context, executes ``callable(*args, **kwargs)``, then exits the "
"Context. Returns *callable*'s return value, or propagates an exception if "
"one occurred."
msgstr""
#:../../library/contextvars.rst:185
msgid"Example:"
msgstr"例:"
#:../../library/contextvars.rst:187
msgid""
"import contextvars\n"
"\n"
"var = contextvars.ContextVar('var')\n"
"var.set('spam')\n"
"print(var.get()) # 'spam'\n"
"\n"
"ctx = contextvars.copy_context()\n"
"\n"
"def main():\n"
" # 'var' was set to 'spam' before\n"
" # calling 'copy_context()' and 'ctx.run(main)', so:\n"
" print(var.get()) # 'spam'\n"
" print(ctx[var]) # 'spam'\n"
"\n"
" var.set('ham')\n"
"\n"
" # Now, after setting 'var' to 'ham':\n"
" print(var.get()) # 'ham'\n"
" print(ctx[var]) # 'ham'\n"
"\n"
"# Any changes that the 'main' function makes to 'var'\n"
"# will be contained in 'ctx'.\n"
"ctx.run(main)\n"
"\n"
"# The 'main()' function was run in the 'ctx' context,\n"
"# so changes to 'var' are contained in it:\n"
"print(ctx[var]) # 'ham'\n"
"\n"
"# However, outside of 'ctx', 'var' is still set to 'spam':\n"
"print(var.get()) # 'spam'"
msgstr""
#:../../library/contextvars.rst:233
msgid"Return a shallow copy of the context object."
msgstr"コンテキストオブジェクトの浅いコピーを返します。"
#:../../library/contextvars.rst:237
msgid""
"Return ``True`` if the *context* has a value for *var* set; return ``False`` "
"otherwise."
msgstr""
"*context* に *var* の値が設定されていた場合 ``True`` を返します; そうでない場"
"合は ``False`` を返します。"
#:../../library/contextvars.rst:242
msgid""
"Return the value of the *var* :class:`ContextVar` variable. If the variable "
"is not set in the context object, a :exc:`KeyError` is raised."
msgstr""
":class:`ContextVar` *var* の値を返します。コンテキストオブジェクト内で変数が"
"設定されていない場合は、:exc:`KeyError` を送出します。"
#:../../library/contextvars.rst:248
msgid""
"Return the value for *var* if *var* has the value in the context object. "
"Return *default* otherwise. If *default* is not given, return ``None``."
msgstr""
"*var* がコンテキストオブジェクトの中に値を持てば、その値を返します。さもなけ"
"れば、*default* を返します。*default* を指定していなければ、``None`` を返しま"
"す。"
#:../../library/contextvars.rst:254
msgid"Return an iterator over the variables stored in the context object."
msgstr"コンテキストオブジェクトに格納されている変数群のイテレータを返します。"
#:../../library/contextvars.rst:259
msgid"Return the number of variables set in the context object."
msgstr"コンテキストオブジェクトに格納されている変数の数を返します。"
#:../../library/contextvars.rst:263
msgid"Return a list of all variables in the context object."
msgstr"コンテキストオブジェクト中のすべての変数のリストを返します。"
#:../../library/contextvars.rst:267
msgid"Return a list of all variables' values in the context object."
msgstr"コンテキストオブジェクト中のすべての変数の値のリストを返します。"
#:../../library/contextvars.rst:272
msgid""
"Return a list of 2-tuples containing all variables and their values in the "
"context object."
msgstr""
"コンテキストオブジェクト中のすべての変数について、変数とその値からなる2要素の"
"タプルのリストを返します。"
#:../../library/contextvars.rst:277
msgid"asyncio support"
msgstr"asyncio サポート"
#:../../library/contextvars.rst:279
msgid""
"Context variables are natively supported in :mod:`asyncio` and are ready to "
"be used without any extra configuration. For example, here is a simple echo "
"server, that uses a context variable to make the address of a remote client "
"available in the Task that handles that client::"
msgstr""
"コンテキスト変数は、追加の設定なしに :mod:`asyncio` をサポートします。例え"
"ば、次の単純なechoサーバーは、クライアントを扱う Task の中でリモートクライア"
"ントのアドレスが利用できるように、コンテキスト変数を利用します::"
#:../../library/contextvars.rst:285
msgid""
"import asyncio\n"
"import contextvars\n"
"\n"
"client_addr_var = contextvars.ContextVar('client_addr')\n"
"\n"
"def render_goodbye():\n"
" # The address of the currently handled client can be accessed\n"
" # without passing it explicitly to this function.\n"
"\n"
" client_addr = client_addr_var.get()\n"
" return f'Good bye, client @ {client_addr}\\r\\n'.encode()\n"
"\n"
"async def handle_request(reader, writer):\n"
" addr = writer.transport.get_extra_info('socket').getpeername()\n"
" client_addr_var.set(addr)\n"
"\n"
" # In any code that we call is now possible to get\n"
" # client's address by calling 'client_addr_var.get()'.\n"
"\n"
" while True:\n"
" line = await reader.readline()\n"
" print(line)\n"
" if not line.strip():\n"
" break\n"
"\n"
" writer.write(b'HTTP/1.1 200 OK\\r\\n') # status line\n"
" writer.write(b'\\r\\n') # headers\n"
" writer.write(render_goodbye()) # body\n"
" writer.close()\n"
"\n"
"async def main():\n"
" srv = await asyncio.start_server(\n"
" handle_request, '127.0.0.1', 8081)\n"
"\n"
" async with srv:\n"
" await srv.serve_forever()\n"
"\n"
"asyncio.run(main())\n"
"\n"
"# To test it you can use telnet or curl:\n"
"# telnet 127.0.0.1 8081\n"
"# curl 127.0.0.1:8081"
msgstr""