@@ -984,45 +984,53 @@ msgid ""
984
984
" you can call :func:`OptionParser.error` to signal an application-defined "
985
985
"error condition::"
986
986
msgstr ""
987
+ "处理用户错误更为重要,因为无论你的代码有多稳定他们都肯定会发生。 :mod:`optparse` 可以自动检测部分用户错误,例如不正确的选项参数(如传入"
988
+ " ``-n 4x`` 而 ``-n`` 接受整数参数),缺少参数(如 ``-n`` 位于命令行的末尾,而 ``-n`` 接受任意类型的参数)。 "
989
+ "并且,你可以调用 :func:`OptionParser.error` 来指明应用程序自定义的错误条件::"
987
990
988
991
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:728
989
992
msgid ""
990
993
"In either case, :mod:`optparse` handles the error the same way: it prints "
991
994
"the program's usage message and an error message to standard error and exits"
992
995
" with error status 2."
993
996
msgstr ""
997
+ "在两种情况下,:mod:`optparse` 都是以相同方式处理错误的:它会将程序的用法消息和错误消息打印到标准错误并附带错误状态 2 退出。"
994
998
995
999
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:732
996
1000
msgid ""
997
1001
"Consider the first example above, where the user passes ``4x`` to an option "
998
1002
"that takes an integer:"
999
- msgstr ""
1003
+ msgstr "考虑上面的第一个示例,其中用户向一个接受整数的选项传入了 ``4x``: "
1000
1004
1001
1005
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:742
1002
1006
msgid "Or, where the user fails to pass a value at all:"
1003
- msgstr ""
1007
+ msgstr "或者,当用户未传入任何值: "
1004
1008
1005
1009
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:751
1006
1010
msgid ""
1007
1011
":mod:`optparse`\\ -generated error messages take care always to mention the "
1008
1012
"option involved in the error; be sure to do the same when calling "
1009
1013
":func:`OptionParser.error` from your application code."
1010
1014
msgstr ""
1015
+ ":mod:`optparse` 生成的错误消息总是会确保提示在错误中涉及的选项;请确保在从你的应用程序代码调用 "
1016
+ ":func:`OptionParser.error` 时也做同样的事。"
1011
1017
1012
1018
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:755
1013
1019
msgid ""
1014
1020
"If :mod:`optparse`'s default error-handling behaviour does not suit your "
1015
1021
"needs, you'll need to subclass OptionParser and override its "
1016
1022
":meth:`~OptionParser.exit` and/or :meth:`~OptionParser.error` methods."
1017
1023
msgstr ""
1024
+ "如果 :mod:`optparse` 的默认错误处理行为不适合你的需求,你需要子类化 OptionParser 并重载它的 "
1025
+ ":meth:`~OptionParser.exit` 和/或 :meth:`~OptionParser.error` 方法。"
1018
1026
1019
1027
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:763
1020
1028
msgid "Putting it all together"
1021
- msgstr ""
1029
+ msgstr "合并所有代码 "
1022
1030
1023
1031
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:765
1024
1032
msgid "Here's what :mod:`optparse`\\ -based scripts usually look like::"
1025
- msgstr ""
1033
+ msgstr "下面是基于 :mod:`optparse` 的脚本通常的结构:: "
1026
1034
1027
1035
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:793
1028
1036
msgid "Reference Guide"
0 commit comments