Repository navigation
Expand file tree
/
Copy pathargparse.po
More file actions
4035 lines (3595 loc) · 133 KB
/
Copy pathargparse.po
File metadata and controls
4035 lines (3595 loc) · 133 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-03 11:11+0800\n"
"PO-Revision-Date: 2018-05-23 14:38+0000\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../library/argparse.rst:2
msgid ""
":mod:`!argparse` --- Parser for command-line options, arguments and sub-"
"commands"
msgstr ""
#: ../../library/argparse.rst:12
msgid "**Source code:** :source:`Lib/argparse.py`"
msgstr "**原始碼:**\\ :source:`Lib/argparse.py`"
#: ../../library/argparse.rst:-1
msgid "Tutorial"
msgstr "教學"
#: ../../library/argparse.rst:18
msgid ""
"This page contains the API reference information. For a more gentle "
"introduction to Python command-line parsing, have a look at the :ref:"
"`argparse tutorial <argparse-tutorial>`."
msgstr ""
#: ../../library/argparse.rst:22
msgid ""
"The :mod:`argparse` module makes it easy to write user-friendly command-line "
"interfaces. The program defines what arguments it requires, and :mod:"
"`argparse` will figure out how to parse those out of :data:`sys.argv`. The :"
"mod:`argparse` module also automatically generates help and usage messages. "
"The module will also issue errors when users give the program invalid "
"arguments."
msgstr ""
#: ../../library/argparse.rst:30
msgid "Core Functionality"
msgstr ""
#: ../../library/argparse.rst:32
msgid ""
"The :mod:`argparse` module's support for command-line interfaces is built "
"around an instance of :class:`argparse.ArgumentParser`. It is a container "
"for argument specifications and has options that apply to the parser as "
"whole::"
msgstr ""
#: ../../library/argparse.rst:36
msgid ""
"parser = argparse.ArgumentParser(\n"
" prog='ProgramName',\n"
" description='What the program does',\n"
" epilog='Text at the bottom of help')"
msgstr ""
#: ../../library/argparse.rst:41
msgid ""
"The :meth:`ArgumentParser.add_argument` method attaches individual argument "
"specifications to the parser. It supports positional arguments, options "
"that accept values, and on/off flags::"
msgstr ""
#: ../../library/argparse.rst:45
msgid ""
"parser.add_argument('filename') # positional argument\n"
"parser.add_argument('-c', '--count') # option that takes a value\n"
"parser.add_argument('-v', '--verbose',\n"
" action='store_true') # on/off flag"
msgstr ""
#: ../../library/argparse.rst:50
msgid ""
"The :meth:`ArgumentParser.parse_args` method runs the parser and places the "
"extracted data in a :class:`argparse.Namespace` object::"
msgstr ""
#: ../../library/argparse.rst:53
msgid ""
"args = parser.parse_args()\n"
"print(args.filename, args.count, args.verbose)"
msgstr ""
#: ../../library/argparse.rst:58
msgid "Quick Links for add_argument()"
msgstr ""
#: ../../library/argparse.rst:61
msgid "Name"
msgstr "名稱"
#: ../../library/argparse.rst:61
msgid "Description"
msgstr "描述"
#: ../../library/argparse.rst:61
msgid "Values"
msgstr "數值"
#: ../../library/argparse.rst:63
msgid "action_"
msgstr "action_"
#: ../../library/argparse.rst:63
msgid "Specify how an argument should be handled"
msgstr ""
#: ../../library/argparse.rst:63
msgid ""
"``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, "
"``'append_const'``, ``'count'``, ``'help'``, ``'version'``"
msgstr ""
"``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, "
"``'append_const'``, ``'count'``, ``'help'``, ``'version'``"
#: ../../library/argparse.rst:64
msgid "choices_"
msgstr "choices_"
#: ../../library/argparse.rst:64
msgid "Limit values to a specific set of choices"
msgstr ""
#: ../../library/argparse.rst:64
msgid ""
"``['foo', 'bar']``, ``range(1, 10)``, or :class:`~collections.abc.Container` "
"instance"
msgstr ""
#: ../../library/argparse.rst:65
msgid "const_"
msgstr "const_"
#: ../../library/argparse.rst:65
msgid "Store a constant value"
msgstr ""
#: ../../library/argparse.rst:66
msgid "default_"
msgstr "default_"
#: ../../library/argparse.rst:66
msgid "Default value used when an argument is not provided"
msgstr ""
#: ../../library/argparse.rst:66
msgid "Defaults to ``None``"
msgstr ""
#: ../../library/argparse.rst:67
msgid "dest_"
msgstr "dest_"
#: ../../library/argparse.rst:67
msgid "Specify the attribute name used in the result namespace"
msgstr ""
#: ../../library/argparse.rst:68
msgid "help_"
msgstr "help_"
#: ../../library/argparse.rst:68
msgid "Help message for an argument"
msgstr ""
#: ../../library/argparse.rst:69
msgid "metavar_"
msgstr "metavar_"
#: ../../library/argparse.rst:69
msgid "Alternate display name for the argument as shown in help"
msgstr ""
#: ../../library/argparse.rst:70
msgid "nargs_"
msgstr "nargs_"
#: ../../library/argparse.rst:70
msgid "Number of times the argument can be used"
msgstr ""
#: ../../library/argparse.rst:70
msgid ":class:`int`, ``'?'``, ``'*'``, or ``'+'``"
msgstr ":class:`int`, ``'?'``, ``'*'``, or ``'+'``"
#: ../../library/argparse.rst:71
msgid "required_"
msgstr "required_"
#: ../../library/argparse.rst:71
msgid "Indicate whether an argument is required or optional"
msgstr ""
#: ../../library/argparse.rst:71
msgid "``True`` or ``False``"
msgstr "``True`` 或 ``False``"
#: ../../library/argparse.rst:72
msgid ":ref:`type <argparse-type>`"
msgstr ""
#: ../../library/argparse.rst:72
msgid "Automatically convert an argument to the given type"
msgstr ""
#: ../../library/argparse.rst:72
msgid ""
":class:`int`, :class:`float`, ``argparse.FileType('w')``, or callable "
"function"
msgstr ""
":class:`int`、:class:`float`、``argparse.FileType('w')`` 或可呼叫的函式"
#: ../../library/argparse.rst:77
msgid "Example"
msgstr "範例"
#: ../../library/argparse.rst:79
msgid ""
"The following code is a Python program that takes a list of integers and "
"produces either the sum or the max::"
msgstr ""
#: ../../library/argparse.rst:82
msgid ""
"import argparse\n"
"\n"
"parser = argparse.ArgumentParser(description='Process some integers.')\n"
"parser.add_argument('integers', metavar='N', type=int, nargs='+',\n"
" help='an integer for the accumulator')\n"
"parser.add_argument('--sum', dest='accumulate', action='store_const',\n"
" const=sum, default=max,\n"
" help='sum the integers (default: find the max)')\n"
"\n"
"args = parser.parse_args()\n"
"print(args.accumulate(args.integers))"
msgstr ""
"import argparse\n"
"\n"
"parser = argparse.ArgumentParser(description='Process some integers.')\n"
"parser.add_argument('integers', metavar='N', type=int, nargs='+',\n"
" help='an integer for the accumulator')\n"
"parser.add_argument('--sum', dest='accumulate', action='store_const',\n"
" const=sum, default=max,\n"
" help='sum the integers (default: find the max)')\n"
"\n"
"args = parser.parse_args()\n"
"print(args.accumulate(args.integers))"
#: ../../library/argparse.rst:94
msgid ""
"Assuming the above Python code is saved into a file called ``prog.py``, it "
"can be run at the command line and it provides useful help messages:"
msgstr ""
#: ../../library/argparse.rst:97
msgid ""
"$ python prog.py -h\n"
"usage: prog.py [-h] [--sum] N [N ...]\n"
"\n"
"Process some integers.\n"
"\n"
"positional arguments:\n"
" N an integer for the accumulator\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --sum sum the integers (default: find the max)"
msgstr ""
"$ python prog.py -h\n"
"usage: prog.py [-h] [--sum] N [N ...]\n"
"\n"
"Process some integers.\n"
"\n"
"positional arguments:\n"
" N an integer for the accumulator\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --sum sum the integers (default: find the max)"
#: ../../library/argparse.rst:111
msgid ""
"When run with the appropriate arguments, it prints either the sum or the max "
"of the command-line integers:"
msgstr ""
#: ../../library/argparse.rst:114
msgid ""
"$ python prog.py 1 2 3 4\n"
"4\n"
"\n"
"$ python prog.py 1 2 3 4 --sum\n"
"10"
msgstr ""
"$ python prog.py 1 2 3 4\n"
"4\n"
"\n"
"$ python prog.py 1 2 3 4 --sum\n"
"10"
#: ../../library/argparse.rst:122
msgid "If invalid arguments are passed in, an error will be displayed:"
msgstr ""
#: ../../library/argparse.rst:124
msgid ""
"$ python prog.py a b c\n"
"usage: prog.py [-h] [--sum] N [N ...]\n"
"prog.py: error: argument N: invalid int value: 'a'"
msgstr ""
"$ python prog.py a b c\n"
"usage: prog.py [-h] [--sum] N [N ...]\n"
"prog.py: error: argument N: invalid int value: 'a'"
#: ../../library/argparse.rst:130
msgid "The following sections walk you through this example."
msgstr ""
#: ../../library/argparse.rst:134
msgid "Creating a parser"
msgstr "建立一個剖析器"
#: ../../library/argparse.rst:136
msgid ""
"The first step in using the :mod:`argparse` is creating an :class:"
"`ArgumentParser` object::"
msgstr ""
#: ../../library/argparse.rst:139
msgid ""
">>> parser = argparse.ArgumentParser(description='Process some integers.')"
msgstr ""
">>> parser = argparse.ArgumentParser(description='Process some integers.')"
#: ../../library/argparse.rst:141
msgid ""
"The :class:`ArgumentParser` object will hold all the information necessary "
"to parse the command line into Python data types."
msgstr ""
#: ../../library/argparse.rst:146
msgid "Adding arguments"
msgstr "增加引數"
#: ../../library/argparse.rst:148
msgid ""
"Filling an :class:`ArgumentParser` with information about program arguments "
"is done by making calls to the :meth:`~ArgumentParser.add_argument` method. "
"Generally, these calls tell the :class:`ArgumentParser` how to take the "
"strings on the command line and turn them into objects. This information is "
"stored and used when :meth:`~ArgumentParser.parse_args` is called. For "
"example::"
msgstr ""
#: ../../library/argparse.rst:154
msgid ""
">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n"
"... help='an integer for the accumulator')\n"
">>> parser.add_argument('--sum', dest='accumulate', action='store_const',\n"
"... const=sum, default=max,\n"
"... help='sum the integers (default: find the max)')"
msgstr ""
">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n"
"... help='an integer for the accumulator')\n"
">>> parser.add_argument('--sum', dest='accumulate', action='store_const',\n"
"... const=sum, default=max,\n"
"... help='sum the integers (default: find the max)')"
#: ../../library/argparse.rst:160
msgid ""
"Later, calling :meth:`~ArgumentParser.parse_args` will return an object with "
"two attributes, ``integers`` and ``accumulate``. The ``integers`` attribute "
"will be a list of one or more integers, and the ``accumulate`` attribute "
"will be either the :func:`sum` function, if ``--sum`` was specified at the "
"command line, or the :func:`max` function if it was not."
msgstr ""
#: ../../library/argparse.rst:168
msgid "Parsing arguments"
msgstr "剖析引數"
#: ../../library/argparse.rst:170
msgid ""
":class:`ArgumentParser` parses arguments through the :meth:`~ArgumentParser."
"parse_args` method. This will inspect the command line, convert each "
"argument to the appropriate type and then invoke the appropriate action. In "
"most cases, this means a simple :class:`Namespace` object will be built up "
"from attributes parsed out of the command line::"
msgstr ""
#: ../../library/argparse.rst:176
msgid ""
">>> parser.parse_args(['--sum', '7', '-1', '42'])\n"
"Namespace(accumulate=<built-in function sum>, integers=[7, -1, 42])"
msgstr ""
">>> parser.parse_args(['--sum', '7', '-1', '42'])\n"
"Namespace(accumulate=<built-in function sum>, integers=[7, -1, 42])"
#: ../../library/argparse.rst:179
msgid ""
"In a script, :meth:`~ArgumentParser.parse_args` will typically be called "
"with no arguments, and the :class:`ArgumentParser` will automatically "
"determine the command-line arguments from :data:`sys.argv`."
msgstr ""
#: ../../library/argparse.rst:185
msgid "ArgumentParser objects"
msgstr "ArgumentParser 物件"
#: ../../library/argparse.rst:194
msgid ""
"Create a new :class:`ArgumentParser` object. All parameters should be passed "
"as keyword arguments. Each parameter has its own more detailed description "
"below, but in short they are:"
msgstr ""
#: ../../library/argparse.rst:198
msgid ""
"prog_ - The name of the program (default: ``os.path.basename(sys.argv[0])``)"
msgstr ""
#: ../../library/argparse.rst:201
msgid ""
"usage_ - The string describing the program usage (default: generated from "
"arguments added to parser)"
msgstr ""
#: ../../library/argparse.rst:204
msgid ""
"description_ - Text to display before the argument help (by default, no text)"
msgstr ""
#: ../../library/argparse.rst:207
msgid "epilog_ - Text to display after the argument help (by default, no text)"
msgstr ""
#: ../../library/argparse.rst:209
msgid ""
"parents_ - A list of :class:`ArgumentParser` objects whose arguments should "
"also be included"
msgstr ""
#: ../../library/argparse.rst:212
msgid "formatter_class_ - A class for customizing the help output"
msgstr ""
#: ../../library/argparse.rst:214
msgid ""
"prefix_chars_ - The set of characters that prefix optional arguments "
"(default: '-')"
msgstr ""
#: ../../library/argparse.rst:217
msgid ""
"fromfile_prefix_chars_ - The set of characters that prefix files from which "
"additional arguments should be read (default: ``None``)"
msgstr ""
#: ../../library/argparse.rst:220
msgid ""
"argument_default_ - The global default value for arguments (default: "
"``None``)"
msgstr ""
#: ../../library/argparse.rst:223
msgid ""
"conflict_handler_ - The strategy for resolving conflicting optionals "
"(usually unnecessary)"
msgstr ""
#: ../../library/argparse.rst:226
msgid ""
"add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)"
msgstr ""
#: ../../library/argparse.rst:228
msgid ""
"allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is "
"unambiguous. (default: ``True``)"
msgstr ""
#: ../../library/argparse.rst:231
msgid ""
"exit_on_error_ - Determines whether or not ArgumentParser exits with error "
"info when an error occurs. (default: ``True``)"
msgstr ""
#: ../../library/argparse.rst:234
msgid "*allow_abbrev* parameter was added."
msgstr "新增 *allow_abbrev* 參數。"
#: ../../library/argparse.rst:237
msgid ""
"In previous versions, *allow_abbrev* also disabled grouping of short flags "
"such as ``-vv`` to mean ``-v -v``."
msgstr ""
#: ../../library/argparse.rst:241
msgid "*exit_on_error* parameter was added."
msgstr "新增 *exit_on_error* 參數。"
#: ../../library/argparse.rst:244 ../../library/argparse.rst:780
msgid "The following sections describe how each of these are used."
msgstr ""
#: ../../library/argparse.rst:250
msgid "prog"
msgstr ""
#: ../../library/argparse.rst:252
msgid ""
"By default, :class:`ArgumentParser` objects use ``sys.argv[0]`` to determine "
"how to display the name of the program in help messages. This default is "
"almost always desirable because it will make the help messages match how the "
"program was invoked on the command line. For example, consider a file named "
"``myprogram.py`` with the following code::"
msgstr ""
#: ../../library/argparse.rst:258 ../../library/argparse.rst:678
msgid ""
"import argparse\n"
"parser = argparse.ArgumentParser()\n"
"parser.add_argument('--foo', help='foo help')\n"
"args = parser.parse_args()"
msgstr ""
"import argparse\n"
"parser = argparse.ArgumentParser()\n"
"parser.add_argument('--foo', help='foo help')\n"
"args = parser.parse_args()"
#: ../../library/argparse.rst:263
msgid ""
"The help for this program will display ``myprogram.py`` as the program name "
"(regardless of where the program was invoked from):"
msgstr ""
#: ../../library/argparse.rst:266
msgid ""
"$ python myprogram.py --help\n"
"usage: myprogram.py [-h] [--foo FOO]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO foo help\n"
"$ cd ..\n"
"$ python subdir/myprogram.py --help\n"
"usage: myprogram.py [-h] [--foo FOO]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO foo help"
msgstr ""
"$ python myprogram.py --help\n"
"usage: myprogram.py [-h] [--foo FOO]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO foo help\n"
"$ cd ..\n"
"$ python subdir/myprogram.py --help\n"
"usage: myprogram.py [-h] [--foo FOO]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO foo help"
#: ../../library/argparse.rst:282
msgid ""
"To change this default behavior, another value can be supplied using the "
"``prog=`` argument to :class:`ArgumentParser`::"
msgstr ""
#: ../../library/argparse.rst:285
msgid ""
">>> parser = argparse.ArgumentParser(prog='myprogram')\n"
">>> parser.print_help()\n"
"usage: myprogram [-h]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='myprogram')\n"
">>> parser.print_help()\n"
"usage: myprogram [-h]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
#: ../../library/argparse.rst:292
msgid ""
"Note that the program name, whether determined from ``sys.argv[0]`` or from "
"the ``prog=`` argument, is available to help messages using the ``%(prog)s`` "
"format specifier."
msgstr ""
#: ../../library/argparse.rst:298
msgid ""
">>> parser = argparse.ArgumentParser(prog='myprogram')\n"
">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n"
">>> parser.print_help()\n"
"usage: myprogram [-h] [--foo FOO]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO foo of the myprogram program"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='myprogram')\n"
">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n"
">>> parser.print_help()\n"
"usage: myprogram [-h] [--foo FOO]\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO foo of the myprogram program"
#: ../../library/argparse.rst:309
msgid "usage"
msgstr ""
#: ../../library/argparse.rst:311
msgid ""
"By default, :class:`ArgumentParser` calculates the usage message from the "
"arguments it contains::"
msgstr ""
#: ../../library/argparse.rst:314
msgid ""
">>> parser = argparse.ArgumentParser(prog='PROG')\n"
">>> parser.add_argument('--foo', nargs='?', help='foo help')\n"
">>> parser.add_argument('bar', nargs='+', help='bar help')\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo [FOO]] bar [bar ...]\n"
"\n"
"positional arguments:\n"
" bar bar help\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo [FOO] foo help"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='PROG')\n"
">>> parser.add_argument('--foo', nargs='?', help='foo help')\n"
">>> parser.add_argument('bar', nargs='+', help='bar help')\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo [FOO]] bar [bar ...]\n"
"\n"
"positional arguments:\n"
" bar bar help\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo [FOO] foo help"
#: ../../library/argparse.rst:327
msgid ""
"The default message can be overridden with the ``usage=`` keyword argument::"
msgstr ""
#: ../../library/argparse.rst:329
msgid ""
">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s "
"[options]')\n"
">>> parser.add_argument('--foo', nargs='?', help='foo help')\n"
">>> parser.add_argument('bar', nargs='+', help='bar help')\n"
">>> parser.print_help()\n"
"usage: PROG [options]\n"
"\n"
"positional arguments:\n"
" bar bar help\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo [FOO] foo help"
msgstr ""
">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s "
"[options]')\n"
">>> parser.add_argument('--foo', nargs='?', help='foo help')\n"
">>> parser.add_argument('bar', nargs='+', help='bar help')\n"
">>> parser.print_help()\n"
"usage: PROG [options]\n"
"\n"
"positional arguments:\n"
" bar bar help\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo [FOO] foo help"
#: ../../library/argparse.rst:342
msgid ""
"The ``%(prog)s`` format specifier is available to fill in the program name "
"in your usage messages."
msgstr ""
#: ../../library/argparse.rst:349
msgid "description"
msgstr "描述"
#: ../../library/argparse.rst:351
msgid ""
"Most calls to the :class:`ArgumentParser` constructor will use the "
"``description=`` keyword argument. This argument gives a brief description "
"of what the program does and how it works. In help messages, the "
"description is displayed between the command-line usage string and the help "
"messages for the various arguments::"
msgstr ""
#: ../../library/argparse.rst:357
msgid ""
">>> parser = argparse.ArgumentParser(description='A foo that bars')\n"
">>> parser.print_help()\n"
"usage: argparse.py [-h]\n"
"\n"
"A foo that bars\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
msgstr ""
">>> parser = argparse.ArgumentParser(description='A foo that bars')\n"
">>> parser.print_help()\n"
"usage: argparse.py [-h]\n"
"\n"
"A foo that bars\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
#: ../../library/argparse.rst:366
msgid ""
"By default, the description will be line-wrapped so that it fits within the "
"given space. To change this behavior, see the formatter_class_ argument."
msgstr ""
#: ../../library/argparse.rst:371
msgid "epilog"
msgstr ""
#: ../../library/argparse.rst:373
msgid ""
"Some programs like to display additional description of the program after "
"the description of the arguments. Such text can be specified using the "
"``epilog=`` argument to :class:`ArgumentParser`::"
msgstr ""
#: ../../library/argparse.rst:377
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... description='A foo that bars',\n"
"... epilog=\"And that's how you'd foo a bar\")\n"
">>> parser.print_help()\n"
"usage: argparse.py [-h]\n"
"\n"
"A foo that bars\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
"\n"
"And that's how you'd foo a bar"
msgstr ""
">>> parser = argparse.ArgumentParser(\n"
"... description='A foo that bars',\n"
"... epilog=\"And that's how you'd foo a bar\")\n"
">>> parser.print_help()\n"
"usage: argparse.py [-h]\n"
"\n"
"A foo that bars\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
"\n"
"And that's how you'd foo a bar"
#: ../../library/argparse.rst:390
msgid ""
"As with the description_ argument, the ``epilog=`` text is by default line-"
"wrapped, but this behavior can be adjusted with the formatter_class_ "
"argument to :class:`ArgumentParser`."
msgstr ""
#: ../../library/argparse.rst:396
msgid "parents"
msgstr ""
#: ../../library/argparse.rst:398
msgid ""
"Sometimes, several parsers share a common set of arguments. Rather than "
"repeating the definitions of these arguments, a single parser with all the "
"shared arguments and passed to ``parents=`` argument to :class:"
"`ArgumentParser` can be used. The ``parents=`` argument takes a list of :"
"class:`ArgumentParser` objects, collects all the positional and optional "
"actions from them, and adds these actions to the :class:`ArgumentParser` "
"object being constructed::"
msgstr ""
#: ../../library/argparse.rst:405
msgid ""
">>> parent_parser = argparse.ArgumentParser(add_help=False)\n"
">>> parent_parser.add_argument('--parent', type=int)\n"
"\n"
">>> foo_parser = argparse.ArgumentParser(parents=[parent_parser])\n"
">>> foo_parser.add_argument('foo')\n"
">>> foo_parser.parse_args(['--parent', '2', 'XXX'])\n"
"Namespace(foo='XXX', parent=2)\n"
"\n"
">>> bar_parser = argparse.ArgumentParser(parents=[parent_parser])\n"
">>> bar_parser.add_argument('--bar')\n"
">>> bar_parser.parse_args(['--bar', 'YYY'])\n"
"Namespace(bar='YYY', parent=None)"
msgstr ""
">>> parent_parser = argparse.ArgumentParser(add_help=False)\n"
">>> parent_parser.add_argument('--parent', type=int)\n"
"\n"
">>> foo_parser = argparse.ArgumentParser(parents=[parent_parser])\n"
">>> foo_parser.add_argument('foo')\n"
">>> foo_parser.parse_args(['--parent', '2', 'XXX'])\n"
"Namespace(foo='XXX', parent=2)\n"
"\n"
">>> bar_parser = argparse.ArgumentParser(parents=[parent_parser])\n"
">>> bar_parser.add_argument('--bar')\n"
">>> bar_parser.parse_args(['--bar', 'YYY'])\n"
"Namespace(bar='YYY', parent=None)"
#: ../../library/argparse.rst:418
msgid ""
"Note that most parent parsers will specify ``add_help=False``. Otherwise, "
"the :class:`ArgumentParser` will see two ``-h/--help`` options (one in the "
"parent and one in the child) and raise an error."
msgstr ""
#: ../../library/argparse.rst:423
msgid ""
"You must fully initialize the parsers before passing them via ``parents=``. "
"If you change the parent parsers after the child parser, those changes will "
"not be reflected in the child."
msgstr ""
#: ../../library/argparse.rst:431
msgid "formatter_class"
msgstr "formatter_class"
#: ../../library/argparse.rst:433
msgid ""
":class:`ArgumentParser` objects allow the help formatting to be customized "
"by specifying an alternate formatting class. Currently, there are four such "
"classes:"
msgstr ""
#: ../../library/argparse.rst:442
msgid ""
":class:`RawDescriptionHelpFormatter` and :class:`RawTextHelpFormatter` give "
"more control over how textual descriptions are displayed. By default, :class:"
"`ArgumentParser` objects line-wrap the description_ and epilog_ texts in "
"command-line help messages::"
msgstr ""
#: ../../library/argparse.rst:447
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... description='''this description\n"
"... was indented weird\n"
"... but that is okay''',\n"
"... epilog='''\n"
"... likewise for this epilog whose whitespace will\n"
"... be cleaned up and whose words will be wrapped\n"
"... across a couple lines''')\n"
">>> parser.print_help()\n"
"usage: PROG [-h]\n"
"\n"
"this description was indented weird but that is okay\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
"\n"
"likewise for this epilog whose whitespace will be cleaned up and whose "
"words\n"
"will be wrapped across a couple lines"
msgstr ""
#: ../../library/argparse.rst:467
msgid ""
"Passing :class:`RawDescriptionHelpFormatter` as ``formatter_class=`` "
"indicates that description_ and epilog_ are already correctly formatted and "
"should not be line-wrapped::"
msgstr ""
#: ../../library/argparse.rst:471
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.RawDescriptionHelpFormatter,\n"
"... description=textwrap.dedent('''\\\n"
"... Please do not mess up this text!\n"
"... --------------------------------\n"
"... I have indented it\n"
"... exactly the way\n"
"... I want it\n"
"... '''))\n"
">>> parser.print_help()\n"
"usage: PROG [-h]\n"
"\n"
"Please do not mess up this text!\n"
"--------------------------------\n"
" I have indented it\n"
" exactly the way\n"
" I want it\n"
"\n"
"options:\n"
" -h, --help show this help message and exit"
msgstr ""
#: ../../library/argparse.rst:493
msgid ""
":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help "
"text, including argument descriptions. However, multiple new lines are "
"replaced with one. If you wish to preserve multiple blank lines, add spaces "
"between the newlines."
msgstr ""
#: ../../library/argparse.rst:498
msgid ""
":class:`ArgumentDefaultsHelpFormatter` automatically adds information about "
"default values to each of the argument help messages::"
msgstr ""
#: ../../library/argparse.rst:501
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n"
">>> parser.add_argument('--foo', type=int, default=42, help='FOO!')\n"
">>> parser.add_argument('bar', nargs='*', default=[1, 2, 3], help='BAR!')\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo FOO] [bar ...]\n"
"\n"
"positional arguments:\n"
" bar BAR! (default: [1, 2, 3])\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO FOO! (default: 42)"
msgstr ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n"
">>> parser.add_argument('--foo', type=int, default=42, help='FOO!')\n"
">>> parser.add_argument('bar', nargs='*', default=[1, 2, 3], help='BAR!')\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo FOO] [bar ...]\n"
"\n"
"positional arguments:\n"
" bar BAR! (default: [1, 2, 3])\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo FOO FOO! (default: 42)"
#: ../../library/argparse.rst:516
msgid ""
":class:`MetavarTypeHelpFormatter` uses the name of the type_ argument for "
"each argument as the display name for its values (rather than using the "
"dest_ as the regular formatter does)::"
msgstr ""
#: ../../library/argparse.rst:520
msgid ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.MetavarTypeHelpFormatter)\n"
">>> parser.add_argument('--foo', type=int)\n"
">>> parser.add_argument('bar', type=float)\n"
">>> parser.print_help()\n"
"usage: PROG [-h] [--foo int] float\n"
"\n"
"positional arguments:\n"
" float\n"
"\n"
"options:\n"
" -h, --help show this help message and exit\n"
" --foo int"
msgstr ""
">>> parser = argparse.ArgumentParser(\n"
"... prog='PROG',\n"
"... formatter_class=argparse.MetavarTypeHelpFormatter)\n"
">>> parser.add_argument('--foo', type=int)\n"