@@ -2756,27 +2756,35 @@ msgid ""
2756
2756
"value somewhere, so it goes in both :attr:`~Option.STORE_ACTIONS` and "
2757
2757
":attr:`~Option.TYPED_ACTIONS`."
2758
2758
msgstr ""
2759
+ "``\" extend\" `` 既预期在命令行接受一个值又会将该值保存到某处,因此它同时被归类于 "
2760
+ ":attr:`~Option.STORE_ACTIONS` 和 :attr:`~Option.TYPED_ACTIONS`。"
2759
2761
2760
2762
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:2015
2761
2763
msgid ""
2762
2764
"to ensure that :mod:`optparse` assigns the default type of ``\" string\" `` to"
2763
2765
" ``\" extend\" `` actions, we put the ``\" extend\" `` action in "
2764
2766
":attr:`~Option.ALWAYS_TYPED_ACTIONS` as well."
2765
2767
msgstr ""
2768
+ "为确保 :mod:`optparse` 将 ``\" string\" `` 的默认类型赋值给 ``\" extend\" `` 动作,我们同时将 "
2769
+ "``\" extend\" `` 动作归类于 :attr:`~Option.ALWAYS_TYPED_ACTIONS`。"
2766
2770
2767
2771
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:2019
2768
2772
msgid ""
2769
2773
":meth:`MyOption.take_action` implements just this one new action, and passes"
2770
2774
" control back to :meth:`Option.take_action` for the standard :mod:`optparse`"
2771
2775
" actions."
2772
2776
msgstr ""
2777
+ ":meth:`MyOption.take_action` 只实现了这一个新动作,并将控制权回传给 :meth:`Option.take_action` "
2778
+ "以执行标准的 :mod:`optparse` 动作。"
2773
2779
2774
2780
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:2023
2775
2781
msgid ""
2776
2782
"``values`` is an instance of the optparse_parser.Values class, which "
2777
2783
"provides the very useful :meth:`ensure_value` method. :meth:`ensure_value` "
2778
2784
"is essentially :func:`getattr` with a safety valve; it is called as ::"
2779
2785
msgstr ""
2786
+ "``values`` 是 optparse_parser.Values 类的一个实例,该类提供了非常有用的 :meth:`ensure_value` "
2787
+ "方法。 :meth:`ensure_value` 实际就是一个带有安全阀的 :func:`getattr`;它的调用形式为 ::"
2780
2788
2781
2789
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/library/optparse.rst:2029
2782
2790
msgid ""
@@ -2790,3 +2798,8 @@ msgid ""
2790
2798
"destinations in question; they can just leave the default as ``None`` and "
2791
2799
":meth:`ensure_value` will take care of getting it right when it's needed."
2792
2800
msgstr ""
2801
+ "如果 ``values`` 的 ``attr`` 属性不存在或为 ``None``,则 ensure_value() 会先将其设为 "
2802
+ "``value``,然后返回该值。 这非常适用于 ``\" extend\" ``, ``\" append\" `` 和 ``\" count\" `` "
2803
+ "等动作,它们会将数据累积在一个变量中并预期该变量属于特定的类型(前两项是一个列表,后一项是一个整数)。 使用 :meth:`ensure_value` "
2804
+ "意味着使用你的动作的脚本无需关心为相应的选项目标设置默认值;可以简单地保持默认的 ``None`` 则 :meth:`ensure_value` "
2805
+ "将在必要时负责为其设置适当的值。"