8000 [po] auto sync · python/python-docs-zh-cn@217f8be · GitHub
[go: up one dir, main page]

Skip to content

Commit 217f8be

Browse files
[po] auto sync
1 parent f442a93 commit 217f8be

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed

.stat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation": "80.59%", "updated_at": "2024-12-31T09:55:52Z"}
1+
{"translation": "80.60%", "updated_at": "2025-01-01T06:55:58Z"}

library/contextlib.po

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# jaystone776 <1732865113@qq.com>, 2021
1111
# Heyi Tang <tangheyi.09@gmail.com>, 2021
1212
# Nyuan Zhang, 2022
13-
# Freesand Leo <yuqinju@163.com>, 2024
13+
# Freesand Leo <yuqinju@163.com>, 2025
1414
#
1515
#, fuzzy
1616
msgid ""
@@ -19,7 +19,7 @@ msgstr ""
1919
"Report-Msgid-Bugs-To: \n"
2020
"POT-Creation-Date: 2024-12-27 14:16+0000\n"
2121
"PO-Revision-Date: 2021-06-28 00:57+0000\n"
22-
"Last-Translator: Freesand Leo <yuqinju@163.com>, 2024\n"
22+
"Last-Translator: Freesand Leo <yuqinju@163.com>, 2025\n"
2323
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
2424
"MIME-Version: 1.0\n"
2525
"Content-Type: text/plain; charset=UTF-8\n"
@@ -453,6 +453,15 @@ msgid ""
453453
" with cm:\n"
454454
" # Do something"
455455
msgstr ""
456+
"def myfunction(arg, ignore_exceptions=False):\n"
457+
" if ignore_exceptions:\n"
458+
" # 使用 suppress 来忽略所有异常。\n"
459+
" cm = contextlib.suppress(Exception)\n"
460+
" else:\n"
461+
" # 不忽略任何异常,cm 将没有影响。\n"
462+
" cm = contextlib.nullcontext()\n"
463+
" with cm:\n"
464+
" # 执行某些操作"
456465

457466
#: ../../library/contextlib.rst:245
458467
msgid "An example using *enter_result*::"
@@ -471,6 +480,16 @@ msgid ""
471480
" with cm as file:\n"
472481
" # Perform processing on the file"
473482
msgstr ""
483+
"def process_file(file_or_path):\n"
484+
" if isinstance(file_or_path, str):\n"
485+
" # If string, open file\n"
486+
" cm = open(file_or_path)\n"
487+
" else:\n"
488+
" # 调用方要负责关闭文件\n"
489+
" cm = nullcontext(file_or_path)\n"
490+
"\n"
491+
" with cm as file:\n"
492+
" # 在文件上执行处理"
474493

475494
#: ../../library/contextlib.rst:258
476495
msgid ""
@@ -492,6 +511,16 @@ msgid ""
492511
" async with cm as session:\n"
493512
" # Send http requests with session"
494513
msgstr ""
514+
"async def send_http(session=None):\n"
515+
" if not session:\n"
516+
" # 如果没有 http 会话,则使用 aiohttp 创建它\n"
517+
" cm = aiohttp.ClientSession()\n"
518+
" else:\n"
519+
" # 调用方要负责关闭会话\n"
520+
" cm = nullcontext(session)\n"
521+
"\n"
522+
" async with cm as session:\n"
523+
" # 使用会话发送 http 请求"
495524

496525
#: ../../library/contextlib.rst:274
497526
msgid ":term:`asynchronous context manager` support was added."
@@ -529,6 +558,13 @@ msgid ""
529558
"with suppress(FileNotFoundError):\n"
530559
" os.remove('someotherfile.tmp')"
531560
msgstr ""
561+
"from contextlib import suppress\n"
562+
"\n"
563+
"with suppress(FileNotFoundError):\n"
564+
" os.remove('somefile.tmp')\n"
565+
"\n"
566+
"with suppress(FileNotFoundError):\n"
567+
" os.remove('someotherfile.tmp')"
532568

533569
#: ../../library/contextlib.rst:301
534570
msgid "This code is equivalent to::"
@@ -546,6 +582,15 @@ msgid ""
546582
"except FileNotFoundError:\n"
547583
" pass"
548584
msgstr ""
585+
"try:\n"
586+
" os.remove('somefile.tmp')\n"
587+
"except FileNotFoundError:\n"
588+
" pass\n"
589+
"\n"
590+
"try:\n"
591+
" os.remove('someotherfile.tmp')\n"
592+
"except FileNotFoundError:\n"
593+
" pass"
549594

550595
#: ../../library/contextlib.rst:313 ../../library/contextlib.rst:362
551596
#: ../../library/contextlib.rst:372 ../../library/contextlib.rst:389
@@ -599,6 +644,9 @@ msgid ""
599644
" help(pow)\n"
600645
"s = f.getvalue()"
601646
msgstr ""
647+
"with redirect_stdout(io.StringIO()) as f:\n"
648+
" help(pow)\n"
649+
"s = f.getvalue()"
602650

603651
#: ../../library/contextlib.rst:345
604652
msgid ""
@@ -702,6 +750,16 @@ msgid ""
702750
" print('Finishing')\n"
703751
" return False"
704752
msgstr ""
753+
"from contextlib import ContextDecorator\n"
754+
"\n"
755+
"class mycontext(ContextDecorator):\n"
756+
" def __enter__(self):\n"
757+
" print('Starting')\n"
758+
" return self\n"
759+
"\n"
760+
" def __exit__(self, *exc):\n"
761+
" print('Finishing')\n"
762+
" return False"
705763

706764
#: ../../library/contextlib.rst:418 ../../library/contextlib.rst:490
707765
msgid "The class can then be used like this::"
@@ -725,6 +783,21 @@ msgid ""
725783
"The bit in the middle\n"
726784
"Finishing"
727785
msgstr ""
786+
">>> @mycontext()\n"
787+
"... def function():\n"
788+
"... print('The bit in the middle')\n"
789+
"...\n"
790+
">>> function()\n"
791+
"Starting\n"
792+
"The bit in the middle\n"
793+
"Finishing\n"
794+
"\n"
795+
">>> with mycontext():\n"
796+
"... print('The bit in the middle')\n"
797+
"...\n"
798+
"Starting\n"
799+
"The bit in the middle\n"
800+
"Finishing"
728801

729802
#: ../../library/contextlib.rst:436
730803
msgid ""
@@ -738,6 +811,9 @@ msgid ""
738811
" with cm():\n"
739812
" # Do stuff"
740813
msgstr ""
814+
"def f():\n"
815+
" with cm():\n"
816+
" # 执行操作"
741817

742818
#: ../../library/contextlib.rst:442
743819
msgid "``ContextDecorator`` lets you instead write::"
@@ -749,6 +825,9 @@ msgid ""
749825
"def f():\n"
750826
" # Do stuff"
751827
msgstr ""
828+
"@cm()\n"
829+
"def f():\n"
830+
" # 执行操作"
752831

753832
#: ../../library/contextlib.rst:448
754833
msgid ""

0 commit comments

Comments
 (0)
0