"Language-Team: Persian (https://github.com/python/python-docs-fa/)\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
msgid":mod:`!contextvars` --- Context Variables"
msgstr":mod:`!contextvars` --- متغیرهای زمینه"
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هایی را برای مدیریت، ذخیره و دسترسی به وضعیت محلی زمینه فراهم میکند. از کلاس :class:`~contextvars.ContextVar` برای اعلام و کار با *متغیرهای زمینه* استفاده میشود. برای مدیریت زمینه جاری در چارچوبهای ناهمگام باید از تابع :func:`~contextvars.copy_context` و کلاس :class:`~contextvars.Context` استفاده شود."
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"مدیران زمینهای که وضعیت دارند، باید بهجای :func:`threading.local` از متغیرهای زمینه استفاده کنند تا هنگام استفاده در کد همروند، از نشت وضعیتشان به سایر کدها بهطور غیرمنتظره جلوگیری شود."
msgid"See also :pep:`567` for additional details."
msgstr"همچنین برای جزئیات بیشتر، :pep:`567` را ببینید."
msgid"Context Variables"
msgstr"متغیرهای زمینه"
msgid"This class is used to declare a new Context Variable, e.g.::"
msgstr"این کلاس برای اعلام یک متغیر زمینه (Context Variable) جدید به کار میرود، برای مثال::"
msgid"The required *name* parameter is used for introspection and debug purposes."
msgstr"پارامتر الزامی *name* برای دروننگری و اهداف اشکالزدایی استفاده میشود."
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` برگردانده میشود، هنگامی که هیچ مقداری برای متغیر در زمینه جاری یافت نشود."
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"**مهم:** متغیرهای زمینه باید در سطح بالای ماژول ایجاد شوند و هرگز در بستهها (closures) ایجاد نشوند. اشیای :class:`Context` ارجاعهای قوی به متغیرهای زمینه نگه میدارند که مانع از زبالهروبی صحیح متغیرهای زمینه میشود."
msgid":class:`!ContextVar`\\s are :ref:`generic <generics>` over the type of their contained value."
msgstr":class:`!ContextVar` ها نسبت به نوع مقدار درون خود :ref:`عام <generics>` هستند."
msgid"The name of the variable. This is a read-only property."
msgstr"نام متغیر. این یک ویژگی فقطخواندنی است."
msgid"Return a value for the context variable for the current context."
msgstr"مقداری برای متغیر زمینه در زمینه جاری برمیگرداند."
msgid"If there is no value for the variable in the current context, the method will:"
msgstr"اگر در زمینه فعلی مقداری برای متغیر وجود نداشته باشد، متد:"
msgid"return the value of the *default* argument of the method, if provided; or"
msgstr"مقدار آرگومان *default* متد را، در صورتی که ارائه شده باشد، برمیگرداند؛ یا"
msgid"return the default value for the context variable, if it was created with one; or"
msgstr"مقدار پیشفرض متغیر زمینه را برمیگرداند، اگر با یک مقدار پیشفرض ایجاد شده باشد؛ یا"
msgid"raise a :exc:`LookupError`."
msgstr"یک :exc:`LookupError` پرتاب میکند."
msgid"Call to set a new value for the context variable in the current context."
msgstr"فراخوانی برای تنظیم مقدار جدید برای متغیر زمینه در زمینه فعلی."
msgid"The required *value* argument is the new value for the context variable."
msgstr"آرگومان *value* الزامی، مقدار جدید برای متغیر زمینه است."
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` استفاده کرد."
msgid"For convenience, the token object can be used as a context manager to avoid calling :meth:`ContextVar.reset` manually::"
msgstr"برای سهولت، میتوان از شیء توکن بهعنوان مدیر زمینه استفاده کرد تا از فراخوانی دستی :meth:`ContextVar.reset` اجتناب شود::"
msgid"Added support for using tokens as context managers."
msgstr"پشتیبانی از استفاده از توکنها بهعنوان مدیران زمینه افزوده شد."
msgid"Reset the context variable to the value it had before the :meth:`ContextVar.set` that created the *token* was used."
msgstr"متغیر زمینه را به مقداری که پیش از استفاده از :meth:`ContextVar.set` برای ایجاد *token* داشت، بازنشانی میکند."
msgid"For example::"
msgstr"برای مثال::"
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""
"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."
msgid"The same *token* cannot be used twice."
msgstr"نمیتوان از همان *توکن* دو بار استفاده کرد."
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*. A single token cannot reset a context variable more than once."
msgstr"اشیای *Token* توسط متد :meth:`ContextVar.set` برگردانده میشوند. میتوان آنها را به متد :meth:`ContextVar.reset` ارسال کرد تا مقدار متغیر به مقداری که پیش از *set* مربوطه داشت برگردانده شود. یک توکن واحد نمیتواند یک متغیر زمینه را بیش از یک بار بازنشانی کند."
msgid"Tokens support the :ref:`context manager protocol <context-managers>` to automatically reset context variables. See :meth:`ContextVar.set`."
msgstr"توکنها از :ref:`پروتکل مدیریت زمینه <context-managers>` برای بازنشانی خودکار متغیرهای زمینه پشتیبانی میکنند. :meth:`ContextVar.set` را ببینید."
msgid"Tokens are :ref:`generic <generics>` over the same type as the :class:`ContextVar` which created them."
msgstr"توکنها نسبت به همان نوعی که :class:`ContextVar` آنها را ایجاد کرده است، :ref:`عام <generics>` هستند."
msgid"Added support for usage as a context manager."
msgstr"پشتیبانی از استفاده بهعنوان مدیر زمینه افزوده شد."
msgid"A read-only property. Points to the :class:`ContextVar` object that created the token."
msgstr"یک ویژگی فقطخواندنی. به شیء :class:`ContextVar` که توکن را ایجاد کرده است اشاره میکند."
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` اشاره میکند."
msgid"A marker object used by :attr:`Token.old_value`."
msgstr"یک شیء نشانگر که توسط :attr:`Token.old_value` استفاده میشود."
msgid"Manual Context Management"
msgstr"مدیریت دستی زمینه"
msgid"Returns a copy of the current :class:`~contextvars.Context` object."
msgstr"نسخهای از شیء :class:`~contextvars.Context` فعلی را برمیگرداند."
msgid"The following snippet gets a copy of the current context and prints all variables and their values that are set in it::"
msgstr"قطعهکد زیر یک کپی از زمینه فعلی را میگیرد و همه متغیرهایی را که در آن تنظیم شدهاند، به همراه مقادیرشان چاپ میکند::"
msgid""
"ctx: Context = copy_context()\n"
"print(list(ctx.items()))"
msgstr""
"ctx: Context = copy_context()\n"
"print(list(ctx.items()))"
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) است، یعنی هم برای زمینههایی با چند متغیر زمینه و هم برای زمینههایی که تعداد زیادی از آنها دارند، با سرعت یکسانی کار میکند."
msgid"A mapping of :class:`ContextVars <ContextVar>` to their values."
msgstr"یک نگاشت از :class:`ContextVars <ContextVar>` به مقدارهای آنها."
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` استفاده کنید."
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"هر نخ، پشتهی مؤثر خود از اشیای :class:`!Context` را دارد. :term:`زمینه جاری <current context>`، شیء :class:`!Context` در بالای پشتهی نخ جاری است. تمام اشیای :class:`!Context` در پشتهها، *واردشده* در نظر گرفته میشوند."
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"*ورود* به یک زمینه، که میتواند با فراخوانی متد :meth:`~Context.run` آن انجام شود، زمینه را با قرار دادن آن در بالای پشتهی زمینهی نخ جاری به زمینهی جاری تبدیل میکند."
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"*خروج* از زمینه فعلی، که میتوان آن را با بازگشت از کالبک دادهشده به متد :meth:`~Context.run` انجام داد، با برداشتن زمینه از بالای پشتهی زمینه، زمینه فعلی را به وضعیتی که پیش از ورود به زمینه داشت بازمیگرداند."
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"از آنجایی که هر نخ پشتهی زمینهی مختص به خود را دارد، اشیای :class:`ContextVar` هنگامی که مقدارها در نخهای مختلف اختصاص داده میشوند، رفتاری مشابه :func:`threading.local` دارند."
msgid"Attempting to enter an already entered context, including contexts entered in other threads, raises a :exc:`RuntimeError`."
msgstr"تلاش برای ورود به زمینهای که از قبل وارد شده است، از جمله زمینههایی که در نخهای دیگر وارد شدهاند، باعث پرتاب یک :exc:`RuntimeError` میشود."
msgid"After exiting a context, it can later be re-entered (from any thread)."
msgstr"پس از خروج از یک زمینه، میتوان بعداً دوباره وارد آن شد (از هر نخی)."
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"هرگونه تغییر در مقادیر :class:`ContextVar` از طریق متد :meth:`ContextVar.set` در زمینه فعلی ثبت میشود. متد :meth:`ContextVar.get` مقدار مرتبط با زمینه فعلی را برمیگرداند. خروج از یک زمینه، عملاً هر تغییری را که در متغیرهای زمینه در مدتی که وارد زمینه شده بودید ایجاد شده باشد، برمیگرداند (در صورت نیاز، میتوان با ورود مجدد به زمینه، مقادیر را بازیابی کرد)."
msgid"Context implements the :class:`collections.abc.Mapping` interface."
msgstr"Context رابط :class:`collections.abc.Mapping` را پیادهسازی میکند."
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"وارد Context میشود، ``callable(*args, **kwargs)`` را اجرا میکند، سپس از Context خارج میشود. مقدار بازگشتی *callable* را بازمیگرداند، یا اگر استثنایی رخ داده باشد، آن را منتشر میکند."
msgid"Example:"
msgstr"مثال:"
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""
"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'"
msgid"Return a shallow copy of the context object."
msgstr"یک کپی سطحی از شیء زمینه برمیگرداند."
msgid"Return ``True`` if the *context* has a value for *var* set; return ``False`` otherwise."
msgstr"اگر *context* دارای مقداری برای *var* تنظیمشده باشد، ``True`` را برمیگرداند؛ در غیر این صورت ``False`` را برمیگرداند."
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"مقدار متغیر *var* از کلاس :class:`ContextVar` را برمیگرداند. اگر متغیر در شیء زمینه تنظیمنشده باشد، استثنای :exc:`KeyError` پرتاب میشود."
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* در شیء زمینه مقدار داشته باشد، مقدار *var* را برمیگرداند. در غیر این صورت، *default* را برمیگرداند. اگر *default* داده نشده باشد، ``None`` را برمیگرداند."
msgid"Return an iterator over the variables stored in the context object."
msgstr"یک پیمایشگر بر روی متغیرهای ذخیرهشده در شیء زمینه برمیگرداند."
msgid"Return the number of variables set in the context object."
msgstr"تعداد متغیرهای تنظیمشده در شیء زمینه را برمیگرداند."
msgid"Return a list of all variables in the context object."
msgstr"فهرستی از همه متغیرهای شیء زمینه را برمیگرداند."
msgid"Return a list of all variables' values in the context object."
msgstr"فهرستی از مقادیر تمام متغیرها در شیء زمینه برمیگرداند."
msgid"Return a list of 2-tuples containing all variables and their values in the context object."
msgstr"فهرستی از تاپلهای دوتایی را برمیگرداند که شامل تمام متغیرها و مقادیر آنها در شیء زمینه است."
msgid"asyncio support"
msgstr"پشتیبانی از asyncio"
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` پشتیبانی میشوند و بدون هیچگونه پیکربندی اضافی آماده استفاده هستند. برای مثال، در اینجا یک سرور اکو ساده آمده است که از یک متغیر زمینه استفاده میکند تا نشانی یک کلاینت دوردست را در Taskای که آن کلاینت را مدیریت میکند در دسترس قرار دهد::"