Skip to content

Commit a423dc0

Browse files
[po] auto sync
1 parent a3fcfc0 commit a423dc0

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

library/optparse.po

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,6 +2168,8 @@ msgid ""
21682168
"the only option attribute you must specify is ``callback``, the function to "
21692169
"call::"
21702170
msgstr ""
2171+
"一般来说,定义回调选项的最简单方式是使用 :meth:`OptionParser.add_option` 方法。 在 "
2172+
":attr:`~Option.action` 之外,你必须指定的唯一选项属性是 ``callback``,即要调用的函数::"
21712173

21722174
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1571
21732175
msgid ""
@@ -2180,6 +2182,10 @@ msgid ""
21802182
"number of command-line arguments. This is where writing callbacks gets "
21812183
"tricky; it's covered later in this section."
21822184
msgstr ""
2185+
"``callback`` 是一个函数(或其他可调用对象),因此当你创建这个回调选项时你必须已经定义了 ``my_callback()``。 "
2186+
"在这个简单的例子中,:mod:`optparse` 甚至不知道 ``-c`` 是否接受任何参数,这通常意味着该选项不接受任何参数 --- "
2187+
"它需要知道的就是存在命令行参数 ``-c``。 但是,在某些情况下,你可能希望你的回调接受任意数量的命令行参数。 "
2188+
"这是编写回调的一个麻烦之处;本小节将稍后讲解这个问题。"
21832189

21842190
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1580
21852191
msgid ""
@@ -2188,16 +2194,18 @@ msgid ""
21882194
":attr:`~Option.callback_args` and :attr:`~Option.callback_kwargs`. Thus, "
21892195
"the minimal callback function signature is::"
21902196
msgstr ""
2197+
":mod:`optparse` 总是会向你的回调传递四个特定参数,它只会在你通过 :attr:`~Option.callback_args` 和 "
2198+
":attr:`~Option.callback_kwargs` 进行指定时才传入额外的参数。 因此,最小化的回调函数签名如下::"
21912199

21922200
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1587
21932201
msgid "The four arguments to a callback are described below."
2194-
msgstr ""
2202+
msgstr "以下是对传给回调的四个参数的说明。"
21952203

21962204
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1589
21972205
msgid ""
21982206
"There are several other option attributes that you can supply when you "
21992207
"define a callback option:"
2200-
msgstr ""
2208+
msgstr "当你定义回调选项时还可以提供一些其他的选项属性:"
22012209

22022210
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1596
22032211
msgid ":attr:`~Option.type`"
@@ -2210,6 +2218,9 @@ msgid ""
22102218
":attr:`~Option.type`. Rather than storing the converted value(s) anywhere, "
22112219
"though, :mod:`optparse` passes it to your callback function."
22122220
msgstr ""
2221+
"具有其通常的含义:与在 ``\"store\"`` 或 ``\"append\"`` 动作中一样,它指示 :mod:`optparse` "
2222+
"读取一个参数并将其转换为 :attr:`~Option.type`。 但是,:mod:`optparse` "
2223+
"并不会将所转换的值保存到某个地方,而是将其转给你的回调函数。"
22132224

22142225
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1602
22152226
msgid ":attr:`~Option.nargs`"
@@ -2222,38 +2233,40 @@ msgid ""
22222233
"to :attr:`~Option.type`. It then passes a tuple of converted values to your"
22232234
" callback."
22242235
msgstr ""
2236+
"同样具有其通常的含义:如果提供了该属性并且其值 > 1,:mod:`optparse` 将读取 :attr:`~Option.nargs` "
2237+
"个参数,每个参数都必须可被转换为 :attr:`~Option.type`。 随后它会将被转换值的元组传给你的回调。"
22252238

22262239
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1605
22272240
msgid ":attr:`~Option.callback_args`"
22282241
msgstr ":attr:`~Option.callback_args`"
22292242

22302243
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1605
22312244
msgid "a tuple of extra positional arguments to pass to the callback"
2232-
msgstr ""
2245+
msgstr "一个要传给回调的由额外位置参数组成的元组"
22332246

22342247
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1609
22352248
msgid ":attr:`~Option.callback_kwargs`"
22362249
msgstr ":attr:`~Option.callback_kwargs`"
22372250

22382251
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1608
22392252
msgid "a dictionary of extra keyword arguments to pass to the callback"
2240-
msgstr ""
2253+
msgstr "一个要传给回调的由额外关键字参数组成的字典"
22412254

22422255
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1614
22432256
msgid "How callbacks are called"
2244-
msgstr ""
2257+
msgstr "回调应当如何调用"
22452258

22462259
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1616
22472260
msgid "All callbacks are called as follows::"
2248-
msgstr ""
2261+
msgstr "所有回调都将使用以下方式调用::"
22492262

22502263
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1623
22512264
msgid "``option``"
22522265
msgstr "``option``"
22532266

22542267
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1623
22552268
msgid "is the Option instance that's calling the callback"
2256-
msgstr ""
2269+
msgstr "是调用该回调的 Option 实例"
22572270

22582271
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1630
22592272
msgid "``opt_str``"
@@ -2267,6 +2280,9 @@ msgid ""
22672280
"command-line as an abbreviation for ``--foobar``, then ``opt_str`` will be "
22682281
"``\"--foobar\"``.)"
22692282
msgstr ""
2283+
"是在触发回调的命令行参数中出现的选项字符串。 (如果使用了长选项的缩写形式,则 ``opt_str`` 将为完整规范的选项字符串 --- "
2284+
"举例来说,如果用户在命令行中将 ``--foo`` 作为 ``--foobar`` 的缩写形式,则 ``opt_str`` 将为 ``\"--"
2285+
"foobar\"``。)"
22702286

22712287
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1637
22722288
msgid "``value``"
@@ -2281,6 +2297,10 @@ msgid ""
22812297
"then ``value`` will be ``None``. If :attr:`~Option.nargs` > 1, ``value`` "
22822298
"will be a tuple of values of the appropriate type."
22832299
msgstr ""
2300+
"是在命令行中提供给该选项的参数。 :mod:`optparse` 将只在设置了 :attr:`~Option.type` "
2301+
"的时候才接受参数;``value`` 将为该选项的类型所指定的类型。 如果该选项的 :attr:`~Option.type` 为 ``None`` "
2302+
"(不接受参数),则 ``value`` 将为 ``None``。 如果 :attr:`~Option.nargs` > 1,则 ``value`` "
2303+
"将为由指定类型的值组成的元组。"
22842304

22852305
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1660
22862306
msgid "``parser``"
@@ -2290,7 +2310,7 @@ msgstr "``parser``"
22902310
msgid ""
22912311
"is the OptionParser instance driving the whole thing, mainly useful because "
22922312
"you can access some other interesting data through its instance attributes:"
2293-
msgstr ""
2313+
msgstr "是驱动选项解析过程的 OptionParser 实例,主要作用在于你可以通过其实例属性访问其他一些相关数据:"
22942314

22952315
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1647
22962316
msgid "``parser.largs``"
@@ -2303,6 +2323,8 @@ msgid ""
23032323
"``parser.largs``, e.g. by adding more arguments to it. (This list will "
23042324
"become ``args``, the second return value of :meth:`parse_args`.)"
23052325
msgstr ""
2326+
"当前的剩余参数列表,即已被读取但不属于选项或选项参数的参数。 可以任意修改 ``parser.largs``,例如向其添加更多的参数。 (该列表将成为 "
2327+
"``args``,即 :meth:`parse_args` 的第二个返回值。)"
23062328

23072329
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1653
23082330
msgid "``parser.rargs``"
@@ -2314,6 +2336,8 @@ msgid ""
23142336
"(if applicable) removed, and only the arguments following them still there."
23152337
" Feel free to modify ``parser.rargs``, e.g. by consuming more arguments."
23162338
msgstr ""
2339+
"当前的保留参数列表,即移除了 ``opt_str`` 和 ``value`` (如果可用),并且只有在它们之后的参数才会被保留。 可以任意修改 "
2340+
"``parser.rargs``,例如读取更多的参数。"
23172341

23182342
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1660
23192343
msgid "``parser.values``"
@@ -2327,12 +2351,14 @@ msgid ""
23272351
"around with globals or closures. You can also access or modify the value(s)"
23282352
" of any options already encountered on the command-line."
23292353
msgstr ""
2354+
"作为选项值默认保存位置的对象(一个 optparse.OptionValues 实例)。 这使得回调能使用与 :mod:`optparse` "
2355+
"的其他部分相同的机制来保存选项值;你不需要手动处理全局变量或闭包。 你还可以访问或修改在命令行中遇到的任何选项的值。"
23302356

23312357
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1663
23322358
msgid ""
23332359
"is a tuple of arbitrary positional arguments supplied via the "
23342360
":attr:`~Option.callback_args` option attribute."
2335-
msgstr ""
2361+
msgstr "是一个由通过 :attr:`~Option.callback_args` 选项属性提供的任意位置参数组成的元组。"
23362362

23372363
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1669
23382364
msgid "``kwargs``"
@@ -2342,11 +2368,11 @@ msgstr "``kwargs``"
23422368
msgid ""
23432369
"is a dictionary of arbitrary keyword arguments supplied via "
23442370
":attr:`~Option.callback_kwargs`."
2345-
msgstr ""
2371+
msgstr "是一个由通过 :attr:`~Option.callback_kwargs` 提供的任意关键字参数组成的字典。"
23462372

23472373
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1674
23482374
msgid "Raising errors in a callback"
2349-
msgstr ""
2375+
msgstr "在回调中引发错误"
23502376

23512377
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1676
23522378
msgid ""
@@ -2357,16 +2383,18 @@ msgid ""
23572383
" fault. Otherwise, the user will have a hard time figuring out what they did"
23582384
" wrong."
23592385
msgstr ""
2386+
"如果选项或其参数存在任何问题则回调函数应当引发 :exc:`OptionValueError`。 :mod:`optparse` "
2387+
"将捕获该异常并终止程序,将你提供的错误消息打印到 stderr。 你的消息应当清晰、简洁、准确并指明出错的选项。 否则,用户将很难弄清楚自己做错了什么。"
23602388

23612389
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1686
23622390
msgid "Callback example 1: trivial callback"
2363-
msgstr ""
2391+
msgstr "回调示例 1:最简回调"
23642392

23652393
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1688
23662394
msgid ""
23672395
"Here's an example of a callback option that takes no arguments, and simply "
23682396
"records that the option was seen::"
2369-
msgstr ""
2397+
msgstr "下面是一个不接受任何参数,只是简单地记录所遇见的选项的回调选项示例::"
23702398

23712399
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:1696
23722400
msgid "Of course, you could do that with the ``\"store_true\"`` action."

0 commit comments

Comments
 (0)