-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathconfigparser.po
1370 lines (1196 loc) · 71.1 KB
/
configparser.po
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-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# ww song <sww4718168@gmail.com>, 2018
# walkinrain <walkinrain2008@outlook.com>, 2019
# Freesand Leo <yuqinju@163.com>, 2022
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.9\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-07 16:40+0000\n"
"PO-Revision-Date: 2017-02-16 23:04+0000\n"
"Last-Translator: Rafael Fontenelle <rffontenelle@gmail.com>, 2025\n"
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../library/configparser.rst:2
msgid ":mod:`configparser` --- Configuration file parser"
msgstr ":mod:`configparser` --- 配置文件解析器"
#: ../../library/configparser.rst:14
msgid "**Source code:** :source:`Lib/configparser.py`"
msgstr "**源代码:** :source:`Lib/configparser.py`"
#: ../../library/configparser.rst:24
msgid ""
"This module provides the :class:`ConfigParser` class which implements a "
"basic configuration language which provides a structure similar to what's "
"found in Microsoft Windows INI files. You can use this to write Python "
"programs which can be customized by end users easily."
msgstr ""
"此模块提供了它实现一种基本配置语言 :class:`ConfigParser` 类,这种语言所提供的结构与 Microsoft Windows INI "
"文件的类似。 你可以使用这种语言来编写能够由最终用户来自定义的 Python 程序。"
#: ../../library/configparser.rst:31
msgid ""
"This library does *not* interpret or write the value-type prefixes used in "
"the Windows Registry extended version of INI syntax."
msgstr "这个库 *并不* 能够解析或写入在 Windows Registry 扩展版本 INI 语法中所使用的值-类型前缀。"
#: ../../library/configparser.rst:38
msgid "Module :mod:`shlex`"
msgstr "模块 :mod:`shlex`"
#: ../../library/configparser.rst:37
msgid ""
"Support for creating Unix shell-like mini-languages which can be used as an "
"alternate format for application configuration files."
msgstr "支持创建可被用作应用配置文件的替代的 Unix 终端式微语言。"
#: ../../library/configparser.rst:41
msgid "Module :mod:`json`"
msgstr "模块 :mod:`json`"
#: ../../library/configparser.rst:41
msgid ""
"The json module implements a subset of JavaScript syntax which can also be "
"used for this purpose."
msgstr "json 模块实现了一个 JavaScript 语法的子集,它也可被用于这种目的。"
#: ../../library/configparser.rst:56
msgid "Quick Start"
msgstr "快速起步"
#: ../../library/configparser.rst:58
msgid "Let's take a very basic configuration file that looks like this:"
msgstr "让我们准备一个非常基本的配置文件,它看起来是这样的:"
#: ../../library/configparser.rst:75
msgid ""
"The structure of INI files is described `in the following section "
"<#supported-ini-file-structure>`_. Essentially, the file consists of "
"sections, each of which contains keys with values. :mod:`configparser` "
"classes can read and write such files. Let's start by creating the above "
"configuration file programmatically."
msgstr ""
"INI 文件的结构描述见 `以下章节 <#supported-ini-file-structure>`_。 "
"总的来说,这种文件由多个节组成,每个节包含多个带有值的键。 :mod:`configparser` 类可以读取和写入这种文件。 "
"让我们先通过程序方式来创建上述的配置文件。"
#: ../../library/configparser.rst:99
msgid ""
"As you can see, we can treat a config parser much like a dictionary. There "
"are differences, `outlined later <#mapping-protocol-access>`_, but the "
"behavior is very close to what you would expect from a dictionary."
msgstr ""
"如你所见,我们可以把配置解析器当作一个字典来处理。 两者确实存在差异,`将在后文说明 <#mapping-protocol-"
"access>`_,但是其行为非常接近于字典所具有一般行为。"
#: ../../library/configparser.rst:103
msgid ""
"Now that we have created and saved a configuration file, let's read it back "
"and explore the data it holds."
msgstr "现在我们已经创建并保存了一个配置文件,让我们再将它读取出来并探究其中包含的数据。"
#: ../../library/configparser.rst:138
msgid ""
"As we can see above, the API is pretty straightforward. The only bit of "
"magic involves the ``DEFAULT`` section which provides default values for all"
" other sections [1]_. Note also that keys in sections are case-insensitive "
"and stored in lowercase [1]_."
msgstr ""
"正如我们在上面所看到的,相关的 API 相当直观。 唯一有些神奇的地方是 ``DEFAULT`` 小节,它为所有其他小节提供了默认值 [1]_。 "
"还要注意小节中的键大小写不敏感并且会存储为小写形式 [1]_。"
#: ../../library/configparser.rst:145
msgid "Supported Datatypes"
msgstr "支持的数据类型"
#: ../../library/configparser.rst:147
msgid ""
"Config parsers do not guess datatypes of values in configuration files, "
"always storing them internally as strings. This means that if you need "
"other datatypes, you should convert on your own:"
msgstr "配置解析器并不会猜测配置文件中值的类型,而总是将它们在内部存储为字符串。 这意味着如果你需要其他数据类型,你应当自己来转换:"
#: ../../library/configparser.rst:158
msgid ""
"Since this task is so common, config parsers provide a range of handy getter"
" methods to handle integers, floats and booleans. The last one is the most "
"interesting because simply passing the value to ``bool()`` would do no good "
"since ``bool('False')`` is still ``True``. This is why config parsers also "
"provide :meth:`~ConfigParser.getboolean`. This method is case-insensitive "
"and recognizes Boolean values from ``'yes'``/``'no'``, ``'on'``/``'off'``, "
"``'true'``/``'false'`` and ``'1'``/``'0'`` [1]_. For example:"
msgstr ""
"由于这种任务十分常用,配置解析器提供了一系列便捷的获取方法来处理整数、浮点数和布尔值。 最后一个类型的处理最为有趣,因为简单地将值传给 "
"``bool()`` 是没有用的,``bool('False')`` 仍然会是 ``True``。 为解决这个问题配置解析器还提供了 "
":meth:`~ConfigParser.getboolean`。 这个方法对大小写不敏感并可识别 ``'yes'``/``'no'``, "
"``'on'``/``'off'``, ``'true'``/``'false'`` 和 ``'1'``/``'0'`` [1]_ 等布尔值。 例如:"
#: ../../library/configparser.rst:175
msgid ""
"Apart from :meth:`~ConfigParser.getboolean`, config parsers also provide "
"equivalent :meth:`~ConfigParser.getint` and :meth:`~ConfigParser.getfloat` "
"methods. You can register your own converters and customize the provided "
"ones. [1]_"
msgstr ""
"除了 :meth:`~ConfigParser.getboolean`,配置解析器还提供了同类的 "
":meth:`~ConfigParser.getint` 和 :meth:`~ConfigParser.getfloat` 方法。 "
"你可以注册你自己的转换器并或是定制已提供的转换器。 [1]_"
#: ../../library/configparser.rst:181
msgid "Fallback Values"
msgstr "回退值"
#: ../../library/configparser.rst:183
msgid ""
"As with a dictionary, you can use a section's :meth:`get` method to provide "
"fallback values:"
msgstr "与字典类似,你可以使用某个小节的 :meth:`get` 方法来提供回退值:"
#: ../../library/configparser.rst:196
msgid ""
"Please note that default values have precedence over fallback values. For "
"instance, in our example the ``'CompressionLevel'`` key was specified only "
"in the ``'DEFAULT'`` section. If we try to get it from the section "
"``'topsecret.server.com'``, we will always get the default, even if we "
"specify a fallback:"
msgstr ""
"请注意默认值会优先于回退值。 例如,在我们的示例中 ``'CompressionLevel'`` 键仅在 ``'DEFAULT'`` 小节被指定。 "
"如果你尝试在 ``'topsecret.server.com'`` 小节获取它,我们将总是获取到默认值,即使我们指定了一个回退值:"
#: ../../library/configparser.rst:207
msgid ""
"One more thing to be aware of is that the parser-level :meth:`get` method "
"provides a custom, more complex interface, maintained for backwards "
"compatibility. When using this method, a fallback value can be provided via"
" the ``fallback`` keyword-only argument:"
msgstr ""
"还需要注意的一点是解析器层级的 :meth:`get` 方法提供了自定义的更复杂接口,它被维护用于向下兼容。 当使用此方法时,回退值可以通过 "
"``fallback`` 仅限关键字参数来提供:"
#: ../../library/configparser.rst:218
msgid ""
"The same ``fallback`` argument can be used with the "
":meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat` and "
":meth:`~ConfigParser.getboolean` methods, for example:"
msgstr ""
"同样的 ``fallback`` 参数也可在 :meth:`~ConfigParser.getint`, "
":meth:`~ConfigParser.getfloat` 和 :meth:`~ConfigParser.getboolean` 方法中使用,例如:"
#: ../../library/configparser.rst:234
msgid "Supported INI File Structure"
msgstr "受支持的 INI 文件结构"
#: ../../library/configparser.rst:236
msgid ""
"A configuration file consists of sections, each led by a ``[section]`` "
"header, followed by key/value entries separated by a specific string (``=`` "
"or ``:`` by default [1]_). By default, section names are case sensitive but"
" keys are not [1]_. Leading and trailing whitespace is removed from keys "
"and values. Values can be omitted if the parser is configured to allow it "
"[1]_, in which case the key/value delimiter may also be left out. Values "
"can also span multiple lines, as long as they are indented deeper than the "
"first line of the value. Depending on the parser's mode, blank lines may be"
" treated as parts of multiline values or ignored."
msgstr ""
"配置文件是由小节组成的,每个小节都有一个 ``[section]`` 标头,加上多个由特定字符串 (默认为 ``=`` 或 ``:`` [1]_) "
"分隔的键/值条目。 在默认情况下,小节名对大小写敏感而键对大小写不敏感 [1]_。 键和值开头和末尾的空格会被移除。 在解释器配置允许时值可以被省略 "
"[1]_,在此情况下键/值分隔符也可以被省略。 值还可以跨越多行,只要值的其他行带有比第一行更深的缩进。 "
"依据解析器的具体模式,空白行可能会被视为多行值的组成部分或是被忽略。"
#: ../../library/configparser.rst:246
msgid ""
"By default, a valid section name can be any string that does not contain "
"'\\\\n' or ']'. To change this, see :attr:`ConfigParser.SECTCRE`."
msgstr ""
"在默认情况下,有效的节名称可以是不包含 '\\\\n' 或 ']' 的任意字符串。 要改变此设定,请参阅 "
":attr:`ConfigParser.SECTCRE`。"
#: ../../library/configparser.rst:249
msgid ""
"Configuration files may include comments, prefixed by specific characters "
"(``#`` and ``;`` by default [1]_). Comments may appear on their own on an "
"otherwise empty line, possibly indented. [1]_"
msgstr ""
"配置文件可以包含注释,要带有指定字符前缀 (默认为 ``#`` 和 ``;`` [1]_)。 注释可以单独出现于原本的空白行,并可使用缩进。 [1]_"
#: ../../library/configparser.rst:253 ../../library/configparser.rst:316
msgid "For example:"
msgstr "例如:"
#: ../../library/configparser.rst:301
msgid "Interpolation of values"
msgstr "值的插值"
#: ../../library/configparser.rst:303
msgid ""
"On top of the core functionality, :class:`ConfigParser` supports "
"interpolation. This means values can be preprocessed before returning them "
"from ``get()`` calls."
msgstr "在核心功能之上,:class:`ConfigParser` 还支持插值。 这意味着值可以在被 ``get()`` 调用返回之前进行预处理。"
#: ../../library/configparser.rst:311
msgid ""
"The default implementation used by :class:`ConfigParser`. It enables values"
" to contain format strings which refer to other values in the same section, "
"or values in the special default section [1]_. Additional default values "
"can be provided on initialization."
msgstr ""
"默认实现由 :class:`ConfigParser` 来使用。 它允许值包含引用了相同小节中其他值或者特殊的默认小节中的值的格式字符串 [1]_。 "
"额外的默认值可以在初始化时提供。"
#: ../../library/configparser.rst:329
msgid ""
"In the example above, :class:`ConfigParser` with *interpolation* set to "
"``BasicInterpolation()`` would resolve ``%(home_dir)s`` to the value of "
"``home_dir`` (``/Users`` in this case). ``%(my_dir)s`` in effect would "
"resolve to ``/Users/lumberjack``. All interpolations are done on demand so "
"keys used in the chain of references do not have to be specified in any "
"specific order in the configuration file."
msgstr ""
"在上面的例子里,:class:`ConfigParser` 的 *interpolation* 设为 "
"``BasicInterpolation()``,这会将 ``%(home_dir)s`` 求解为 ``home_dir`` 的值 (在这里是 "
"``/Users``)。 ``%(my_dir)s`` 的将被实际求解为 ``/Users/lumberjack``。 "
"所有插值都是按需进行的,这样引用链中使用的键不必以任何特定顺序在配置文件中指明。"
#: ../../library/configparser.rst:336
msgid ""
"With ``interpolation`` set to ``None``, the parser would simply return "
"``%(my_dir)s/Pictures`` as the value of ``my_pictures`` and "
"``%(home_dir)s/lumberjack`` as the value of ``my_dir``."
msgstr ""
"当 ``interpolation`` 设为 ``None`` 时,解析器会简单地返回 ``%(my_dir)s/Pictures`` 作为 "
"``my_pictures`` 的值,并返回 ``%(home_dir)s/lumberjack`` 作为 ``my_dir`` 的值。"
#: ../../library/configparser.rst:344
msgid ""
"An alternative handler for interpolation which implements a more advanced "
"syntax, used for instance in ``zc.buildout``. Extended interpolation is "
"using ``${section:option}`` to denote a value from a foreign section. "
"Interpolation can span multiple levels. For convenience, if the "
"``section:`` part is omitted, interpolation defaults to the current section "
"(and possibly the default values from the special section)."
msgstr ""
"一个用于插值的替代处理程序实现了更高级的语法,它被用于 ``zc.buildout`` 中的实例。 扩展插值使用 "
"``${section:option}`` 来表示来自外部小节的值。 插值可以跨越多个层级。 为了方便使用,``section:`` "
"部分可被省略,插值会默认作用于当前小节(可能会从特殊小节获取默认值)。"
#: ../../library/configparser.rst:351
msgid ""
"For example, the configuration specified above with basic interpolation, "
"would look like this with extended interpolation:"
msgstr "例如,上面使用基本插值描述的配置,使用扩展插值将是这个样子:"
#: ../../library/configparser.rst:365
msgid "Values from other sections can be fetched as well:"
msgstr "来自其他小节的值也可以被获取:"
#: ../../library/configparser.rst:387
msgid "Mapping Protocol Access"
msgstr "映射协议访问"
#: ../../library/configparser.rst:391
msgid ""
"Mapping protocol access is a generic name for functionality that enables "
"using custom objects as if they were dictionaries. In case of "
":mod:`configparser`, the mapping interface implementation is using the "
"``parser['section']['option']`` notation."
msgstr ""
"映射协议访问这个通用名称是指允许以字典的方式来使用自定义对象的功能。 在 :mod:`configparser` 中,映射接口的实现使用了 "
"``parser['section']['option']`` 标记法。"
#: ../../library/configparser.rst:396
msgid ""
"``parser['section']`` in particular returns a proxy for the section's data "
"in the parser. This means that the values are not copied but they are taken"
" from the original parser on demand. What's even more important is that "
"when values are changed on a section proxy, they are actually mutated in the"
" original parser."
msgstr ""
"``parser['section']`` 专门为解析器中的小节数据返回一个代理。 这意味着其中的值不会被拷贝,而是在需要时从原始解析器中获取。 "
"更为重要的是,当值在小节代理上被修改时,它们其实是在原始解析器中发生了改变。"
#: ../../library/configparser.rst:402
msgid ""
":mod:`configparser` objects behave as close to actual dictionaries as "
"possible. The mapping interface is complete and adheres to the "
":class:`~collections.abc.MutableMapping` ABC. However, there are a few "
"differences that should be taken into account:"
msgstr ""
":mod:`configparser` 对象的行为会尽可能地接近真正的字典。 映射接口是完整而且遵循 "
":class:`~collections.abc.MutableMapping` ABC 规范的。 但是,还是有一些差异应当被纳入考虑:"
#: ../../library/configparser.rst:407
msgid ""
"By default, all keys in sections are accessible in a case-insensitive manner"
" [1]_. E.g. ``for option in parser[\"section\"]`` yields only "
"``optionxform``'ed option key names. This means lowercased keys by default."
" At the same time, for a section that holds the key ``'a'``, both "
"expressions return ``True``::"
msgstr ""
"默认情况下,小节中的所有键是以大小写不敏感的方式来访问的 [1]_。 例如 ``for option in parser[\"section\"]`` "
"只会产生 ``optionxform`` 形式的选项键名称。 也就是说默认使用小写字母键名。 与此同时,对于一个包含键 ``'a'`` "
"的小节,以下两个表达式均将返回 ``True``::"
#: ../../library/configparser.rst:415
msgid ""
"All sections include ``DEFAULTSECT`` values as well which means that "
"``.clear()`` on a section may not leave the section visibly empty. This is "
"because default values cannot be deleted from the section (because "
"technically they are not there). If they are overridden in the section, "
"deleting causes the default value to be visible again. Trying to delete a "
"default value causes a :exc:`KeyError`."
msgstr ""
"所有小节也包括 ``DEFAULTSECT``,这意味着对一个小节执行 ``.clear()`` 可能无法使得该小节显示为空。 "
"这是因为默认值是无法从小节中被删除的(因为从技术上说它们并不在那里)。 如果它们在小节中被覆盖,删除将导致默认值重新变为可见。 尝试删除默认值将会引发 "
":exc:`KeyError`。"
#: ../../library/configparser.rst:422
msgid "``DEFAULTSECT`` cannot be removed from the parser:"
msgstr "``DEFAULTSECT`` 无法从解析器中被移除:"
#: ../../library/configparser.rst:424
msgid "trying to delete it raises :exc:`ValueError`,"
msgstr "尝试删除将引发 :exc:`ValueError`,"
#: ../../library/configparser.rst:426
msgid "``parser.clear()`` leaves it intact,"
msgstr "``parser.clear()`` 会保留其原状,"
#: ../../library/configparser.rst:428
msgid "``parser.popitem()`` never returns it."
msgstr "``parser.popitem()`` 绝不会将其返回。"
#: ../../library/configparser.rst:430
msgid ""
"``parser.get(section, option, **kwargs)`` - the second argument is **not** a"
" fallback value. Note however that the section-level ``get()`` methods are "
"compatible both with the mapping protocol and the classic configparser API."
msgstr ""
"``parser.get(section, option, **kwargs)`` - 第二个参数 **并非** 回退值。 但是请注意小节层级的 "
"``get()`` 方法可同时兼容映射协议和经典配置解析器 API。"
#: ../../library/configparser.rst:434
msgid ""
"``parser.items()`` is compatible with the mapping protocol (returns a list "
"of *section_name*, *section_proxy* pairs including the DEFAULTSECT). "
"However, this method can also be invoked with arguments: "
"``parser.items(section, raw, vars)``. The latter call returns a list of "
"*option*, *value* pairs for a specified ``section``, with all interpolations"
" expanded (unless ``raw=True`` is provided)."
msgstr ""
"``parser.items()`` 兼容映射协议(返回 *section_name*, *section_proxy* 对的列表,包括 "
"DEFAULTSECT)。 但是,此方法也可以附带参数被唤起: ``parser.items(section, raw, vars)``。 "
"这种调用形式返回指定 ``section`` 的 *option*, *value* 对的列表,将展开所有插值(除非提供了 ``raw=True`` "
"选项)。"
#: ../../library/configparser.rst:441
msgid ""
"The mapping protocol is implemented on top of the existing legacy API so "
"that subclasses overriding the original interface still should have mappings"
" working as expected."
msgstr "映射协议是在现有的传统 API 之上实现的,以便重写原始接口的子类仍然具有符合预期的有效映射。"
#: ../../library/configparser.rst:447
msgid "Customizing Parser Behaviour"
msgstr "定制解析器行为"
#: ../../library/configparser.rst:449
msgid ""
"There are nearly as many INI format variants as there are applications using"
" it. :mod:`configparser` goes a long way to provide support for the largest "
"sensible set of INI styles available. The default functionality is mainly "
"dictated by historical background and it's very likely that you will want to"
" customize some of the features."
msgstr ""
"INI 格式的变种数量几乎和使用此格式的应用一样多。 :mod:`configparser` 花费了很大力气来为尽量大范围的可用 INI 样式提供支持。"
" 默认的可用功能主要由历史状况来确定,你很可能会想要定制某些特性。"
#: ../../library/configparser.rst:455
msgid ""
"The most common way to change the way a specific config parser works is to "
"use the :meth:`__init__` options:"
msgstr "改变特定配置解析器行为的最常见方式是使用 :meth:`__init__` 选项:"
#: ../../library/configparser.rst:458
msgid "*defaults*, default value: ``None``"
msgstr "*defaults*,默认值: ``None``"
#: ../../library/configparser.rst:460
msgid ""
"This option accepts a dictionary of key-value pairs which will be initially "
"put in the ``DEFAULT`` section. This makes for an elegant way to support "
"concise configuration files that don't specify values which are the same as "
"the documented default."
msgstr ""
"此选项接受一个键值对的字典,它将被首先放入 ``DEFAULT`` 小节。 "
"这实现了一种优雅的方式来支持简洁的配置文件,它不必指定与已记录的默认值相同的值。"
#: ../../library/configparser.rst:465
msgid ""
"Hint: if you want to specify default values for a specific section, use "
":meth:`read_dict` before you read the actual file."
msgstr "提示:如果你想要为特定的小节指定默认的值,请在读取实际文件之前使用 :meth:`read_dict`。"
#: ../../library/configparser.rst:468
msgid "*dict_type*, default value: :class:`dict`"
msgstr "*dict_type*,默认值: :class:`dict`"
#: ../../library/configparser.rst:470
msgid ""
"This option has a major impact on how the mapping protocol will behave and "
"how the written configuration files look. With the standard dictionary, "
"every section is stored in the order they were added to the parser. Same "
"goes for options within sections."
msgstr "此选项主要影响映射协议的行为和写入配置文件的外观。 使用标准字典时,每个小节是按照它们被加入解析器的顺序保存的。 在小节内的选项也是如此。"
#: ../../library/configparser.rst:475
msgid ""
"An alternative dictionary type can be used for example to sort sections and "
"options on write-back."
msgstr "还有其他替换的字典类型可以使用,例如在写回数据时对小节和选项进行排序。"
#: ../../library/configparser.rst:478
msgid ""
"Please note: there are ways to add a set of key-value pairs in a single "
"operation. When you use a regular dictionary in those operations, the order"
" of the keys will be ordered. For example:"
msgstr "请注意:存在其他方式只用一次操作来添加键值对的集合。 当你在这些操作中使用一个常规字典时,键将按顺序进行排列。 例如:"
#: ../../library/configparser.rst:500
msgid "*allow_no_value*, default value: ``False``"
msgstr "*allow_no_value*,默认值: ``False``"
#: ../../library/configparser.rst:502
msgid ""
"Some configuration files are known to include settings without values, but "
"which otherwise conform to the syntax supported by :mod:`configparser`. The"
" *allow_no_value* parameter to the constructor can be used to indicate that "
"such values should be accepted:"
msgstr ""
"已知某些配置文件会包括不带值的设置,但其在其他方面均符合 :mod:`configparser` 所支持的语法。 构造器的 "
"*allow_no_value* 形参可用于指明应当接受这样的值:"
#: ../../library/configparser.rst:537
msgid "*delimiters*, default value: ``('=', ':')``"
msgstr "*delimiters*,默认值: ``('=', ':')``"
#: ../../library/configparser.rst:539
msgid ""
"Delimiters are substrings that delimit keys from values within a section. "
"The first occurrence of a delimiting substring on a line is considered a "
"delimiter. This means values (but not keys) can contain the delimiters."
msgstr "分隔符是用于在小节内分隔键和值的子字符串。 在一行中首次出现的分隔子字符串会被视为一个分隔符。 这意味着值可以包含分隔符(但键不可以)。"
#: ../../library/configparser.rst:543
msgid ""
"See also the *space_around_delimiters* argument to "
":meth:`ConfigParser.write`."
msgstr "另请参见 :meth:`ConfigParser.write` 的 *space_around_delimiters* 参数。"
#: ../../library/configparser.rst:546
msgid "*comment_prefixes*, default value: ``('#', ';')``"
msgstr "*comment_prefixes*,默认值: ``('#', ';')``"
#: ../../library/configparser.rst:548
msgid "*inline_comment_prefixes*, default value: ``None``"
msgstr "*inline_comment_prefixes*,默认值: ``None``"
#: ../../library/configparser.rst:550
msgid ""
"Comment prefixes are strings that indicate the start of a valid comment "
"within a config file. *comment_prefixes* are used only on otherwise empty "
"lines (optionally indented) whereas *inline_comment_prefixes* can be used "
"after every valid value (e.g. section names, options and empty lines as "
"well). By default inline comments are disabled and ``'#'`` and ``';'`` are "
"used as prefixes for whole line comments."
msgstr ""
"注释前缀是配置文件中用于标示一条有效注释的开头的字符串。 *comment_prefixes* 仅用在被视为空白的行(可以缩进)之前而 "
"*inline_comment_prefixes* 可用在每个有效值之后(例如小节名称、选项以及空白的行)。 默认情况下禁用行内注释,并且 "
"``'#'`` 和 ``';'`` 都被用作完整行注释的前缀。"
#: ../../library/configparser.rst:557
msgid ""
"In previous versions of :mod:`configparser` behaviour matched "
"``comment_prefixes=('#',';')`` and ``inline_comment_prefixes=(';',)``."
msgstr ""
"在之前的 :mod:`configparser` 版本中行为匹配 ``comment_prefixes=('#',';')`` 和 "
"``inline_comment_prefixes=(';',)``。"
#: ../../library/configparser.rst:561
msgid ""
"Please note that config parsers don't support escaping of comment prefixes "
"so using *inline_comment_prefixes* may prevent users from specifying option "
"values with characters used as comment prefixes. When in doubt, avoid "
"setting *inline_comment_prefixes*. In any circumstances, the only way of "
"storing comment prefix characters at the beginning of a line in multiline "
"values is to interpolate the prefix, for example::"
msgstr ""
"请注意配置解析器不支持对注释前缀的转义,因此使用 *inline_comment_prefixes* 可能妨碍用户将被用作注释前缀的字符指定为可选值。 "
"当有疑问时,请避免设置 *inline_comment_prefixes*。 "
"在许多情况下,在多行值的一行开头存储注释前缀字符的唯一方式是进行前缀插值,例如::"
#: ../../library/configparser.rst:607
msgid "*strict*, default value: ``True``"
msgstr "*strict*,默认值: ``True``"
#: ../../library/configparser.rst:609
msgid ""
"When set to ``True``, the parser will not allow for any section or option "
"duplicates while reading from a single source (using :meth:`read_file`, "
":meth:`read_string` or :meth:`read_dict`). It is recommended to use strict "
"parsers in new applications."
msgstr ""
"当设为 ``True`` 时,解析器在从单一源读取 (使用 :meth:`read_file`, :meth:`read_string` 或 "
":meth:`read_dict`) 期间将不允许任何小节或选项出现重复。 推荐在新的应用中使用严格解析器。"
#: ../../library/configparser.rst:614
msgid ""
"In previous versions of :mod:`configparser` behaviour matched "
"``strict=False``."
msgstr "在之前的 :mod:`configparser` 版本中行为匹配 ``strict=False``。"
#: ../../library/configparser.rst:618
msgid "*empty_lines_in_values*, default value: ``True``"
msgstr "*empty_lines_in_values*,默认值: ``True``"
#: ../../library/configparser.rst:620
msgid ""
"In config parsers, values can span multiple lines as long as they are "
"indented more than the key that holds them. By default parsers also let "
"empty lines to be parts of values. At the same time, keys can be "
"arbitrarily indented themselves to improve readability. In consequence, "
"when configuration files get big and complex, it is easy for the user to "
"lose track of the file structure. Take for instance:"
msgstr ""
"在配置解析器中,值可以包含多行,只要它们的缩进级别低于它们所对应的键。 默认情况下解析器还会将空行视为值的一部分。 "
"于此同时,键本身也可以任意缩进以提升可读性。 因此,当配置文件变得非常庞大而复杂时,用户很容易失去对文件结构的掌控。 例如:"
#: ../../library/configparser.rst:635
msgid ""
"This can be especially problematic for the user to see if she's using a "
"proportional font to edit the file. That is why when your application does "
"not need values with empty lines, you should consider disallowing them. "
"This will make empty lines split keys every time. In the example above, it "
"would produce two keys, ``key`` and ``this``."
msgstr ""
"在用户查看时这可能会特别有问题,如果她是使用比例字体来编辑文件的话。 这就是为什么当你的应用不需要带有空行的值时,你应该考虑禁用它们。 "
"这将使得空行每次都会作为键之间的分隔。 在上面的示例中,空行产生了两个键,``key`` 和 ``this``。"
#: ../../library/configparser.rst:641
msgid ""
"*default_section*, default value: ``configparser.DEFAULTSECT`` (that is: "
"``\"DEFAULT\"``)"
msgstr "*default_section*,默认值: ``configparser.DEFAULTSECT`` (即: ``\"DEFAULT\"``)"
#: ../../library/configparser.rst:644
msgid ""
"The convention of allowing a special section of default values for other "
"sections or interpolation purposes is a powerful concept of this library, "
"letting users create complex declarative configurations. This section is "
"normally called ``\"DEFAULT\"`` but this can be customized to point to any "
"other valid section name. Some typical values include: ``\"general\"`` or "
"``\"common\"``. The name provided is used for recognizing default sections "
"when reading from any source and is used when writing configuration back to "
"a file. Its current value can be retrieved using the "
"``parser_instance.default_section`` attribute and may be modified at runtime"
" (i.e. to convert files from one format to another)."
msgstr ""
"允许设置一个保存默认值的特殊节在其他节或插值等目的中使用的惯例是这个库所拥有的一个强大概念,使得用户能够创建复杂的声明性配置。 这种特殊节通常称为 "
"``\"DEFAULT\"`` 但也可以被定制为指向任何其他有效的节名称。 一些典型的值包括: ``\"general\"`` 或 "
"``\"common\"``。 所提供的名称在从任意节读取的时候被用于识别默认的节,而且也会在将配置写回文件时被使用。 它的当前值可以使用 "
"``parser_instance.default_section`` 属性来获取,并且可以在运行时被修改(即将文件从一种格式转换为另一种格式)。"
#: ../../library/configparser.rst:655
msgid "*interpolation*, default value: ``configparser.BasicInterpolation``"
msgstr "*interpolation*,默认值: ``configparser.BasicInterpolation``"
#: ../../library/configparser.rst:657
msgid ""
"Interpolation behaviour may be customized by providing a custom handler "
"through the *interpolation* argument. ``None`` can be used to turn off "
"interpolation completely, ``ExtendedInterpolation()`` provides a more "
"advanced variant inspired by ``zc.buildout``. More on the subject in the "
"`dedicated documentation section <#interpolation-of-values>`_. "
":class:`RawConfigParser` has a default value of ``None``."
msgstr ""
"插值行为可以用通过提供 *interpolation* 参数提供自定义处理程序的方式来定制。 ``None`` "
"可用来完全禁用插值,``ExtendedInterpolation()`` 提供了一种更高级的变体形式,它的设计受到了 ``zc.buildout`` "
"的启发。 有关该主题的更多信息请参见 `专门的文档章节 <#interpolation-of-values>`_。 "
":class:`RawConfigParser` 具有默认的值 ``None``。"
#: ../../library/configparser.rst:664
msgid "*converters*, default value: not set"
msgstr "*converters*,默认值: 不设置"
#: ../../library/configparser.rst:666
msgid ""
"Config parsers provide option value getters that perform type conversion. "
"By default :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat`, and"
" :meth:`~ConfigParser.getboolean` are implemented. Should other getters be "
"desirable, users may define them in a subclass or pass a dictionary where "
"each key is a name of the converter and each value is a callable "
"implementing said conversion. For instance, passing ``{'decimal': "
"decimal.Decimal}`` would add :meth:`getdecimal` on both the parser object "
"and all section proxies. In other words, it will be possible to write both "
"``parser_instance.getdecimal('section', 'key', fallback=0)`` and "
"``parser_instance['section'].getdecimal('key', 0)``."
msgstr ""
"配置解析器提供了可选的值获取方法用来执行类型转换。 默认实现包括 :meth:`~ConfigParser.getint`, "
":meth:`~ConfigParser.getfloat` 以及 :meth:`~ConfigParser.getboolean`。 "
"如果还需要其他获取方法,用户可以在子类中定义它们,或者传入一个字典,其中每个键都是一个转换器的名称而每个值都是一个实现了特定转换的可调用对象。 "
"例如,传入 ``{'decimal': decimal.Decimal}`` 将对解释器对象和所有节代理添加 :meth:`getdecimal`。 "
"换句话说,可以同时编写 ``parser_instance.getdecimal('section', 'key', fallback=0)`` 和 "
"``parser_instance['section'].getdecimal('key', 0)``。"
#: ../../library/configparser.rst:677
msgid ""
"If the converter needs to access the state of the parser, it can be "
"implemented as a method on a config parser subclass. If the name of this "
"method starts with ``get``, it will be available on all section proxies, in "
"the dict-compatible form (see the ``getdecimal()`` example above)."
msgstr ""
"如果转换器需要访问解析器的状态,可以在配置解析器子类上作为一个方法来实现。 如果该方法的名称是以 ``get`` "
"打头的,它将在所有节代理上以兼容字典的形式提供(参见上面的 ``getdecimal()`` 示例)。"
#: ../../library/configparser.rst:682
msgid ""
"More advanced customization may be achieved by overriding default values of "
"these parser attributes. The defaults are defined on the classes, so they "
"may be overridden by subclasses or by attribute assignment."
msgstr "更多高级定制选项可通过重写这些解析器属性的默认值来达成。 默认值是在类中定义的,因此它们可以通过子类或属性赋值来重写。"
#: ../../library/configparser.rst:688
msgid ""
"By default when using :meth:`~ConfigParser.getboolean`, config parsers "
"consider the following values ``True``: ``'1'``, ``'yes'``, ``'true'``, "
"``'on'`` and the following values ``False``: ``'0'``, ``'no'``, ``'false'``,"
" ``'off'``. You can override this by specifying a custom dictionary of "
"strings and their Boolean outcomes. For example:"
msgstr ""
"默认情况下当使用 :meth:`~ConfigParser.getboolean` 时,配置解析器会将下列值视为 ``True``: ``'1'``, "
"``'yes'``, ``'true'``, ``'on'`` 而将下列值视为 ``False``: ``'0'``, ``'no'``, "
"``'false'``, ``'off'``。 你可以通过指定一个自定义的字符串键及其对应的布尔值字典来覆盖此行为。 例如:"
#: ../../library/configparser.rst:706
msgid ""
"Other typical Boolean pairs include ``accept``/``reject`` or "
"``enabled``/``disabled``."
msgstr "其他典型的布尔值对包括 ``accept``/``reject`` 或 ``enabled``/``disabled``。"
#: ../../library/configparser.rst:712
msgid ""
"This method transforms option names on every read, get, or set operation. "
"The default converts the name to lowercase. This also means that when a "
"configuration file gets written, all keys will be lowercase. Override this "
"method if that's unsuitable. For example:"
msgstr ""
"这个方法会转换每次 read, get, 或 set 操作的选项名称。 默认会将名称转换为小写形式。 "
"这也意味着当一个配置文件被写入时,所有键都将为小写形式。 如果此行为不合适则要重写此方法。 例如:"
#: ../../library/configparser.rst:742
msgid ""
"The optionxform function transforms option names to a canonical form. This "
"should be an idempotent function: if the name is already in canonical form, "
"it should be returned unchanged."
msgstr "optionxform 函数会将选项名称转换为规范形式。 这应该是一个幂等函数:如果名称已经为规范形式,则应不加修改地将其返回。"
#: ../../library/configparser.rst:749
msgid ""
"A compiled regular expression used to parse section headers. The default "
"matches ``[section]`` to the name ``\"section\"``. Whitespace is considered"
" part of the section name, thus ``[ larch ]`` will be read as a section of"
" name ``\" larch \"``. Override this attribute if that's unsuitable. For"
" example:"
msgstr ""
"一个已编译正则表达式会被用来解析节标头。 默认将 ``[section]`` 匹配到名称 ``\"section\"``。 "
"空格会被视为节名称的一部分,因此 ``[ larch ]`` 将被读取为一个名称为 ``\" larch \"`` 的节。 "
"如果此行为不合适则要覆盖此属性。 例如:"
#: ../../library/configparser.rst:777
msgid ""
"While ConfigParser objects also use an ``OPTCRE`` attribute for recognizing "
"option lines, it's not recommended to override it because that would "
"interfere with constructor options *allow_no_value* and *delimiters*."
msgstr ""
"虽然 ConfigParser 对象也使用 ``OPTCRE`` 属性来识别选项行,但并不推荐重写它,因为这会与构造器选项 "
"*allow_no_value* 和 *delimiters* 产生冲突。"
#: ../../library/configparser.rst:783
msgid "Legacy API Examples"
msgstr "旧式 API 示例"
#: ../../library/configparser.rst:785
msgid ""
"Mainly because of backwards compatibility concerns, :mod:`configparser` "
"provides also a legacy API with explicit ``get``/``set`` methods. While "
"there are valid use cases for the methods outlined below, mapping protocol "
"access is preferred for new projects. The legacy API is at times more "
"advanced, low-level and downright counterintuitive."
msgstr ""
"主要出于向下兼容性的考虑,:mod:`configparser` 还提供了一种采用显式 ``get``/``set`` 方法的旧式 API。 "
"虽然以下介绍的方法存在有效的用例,但对于新项目仍建议采用映射协议访问。 旧式 API 在多数时候都更复杂、更底层并且完全违反直觉。"
#: ../../library/configparser.rst:791
msgid "An example of writing to a configuration file::"
msgstr "一个写入配置文件的示例::"
#: ../../library/configparser.rst:814
msgid "An example of reading the configuration file again::"
msgstr "一个再次读取配置文件的示例::"
#: ../../library/configparser.rst:832
msgid "To get interpolation, use :class:`ConfigParser`::"
msgstr "要获取插值,请使用 :class:`ConfigParser`::"
#: ../../library/configparser.rst:865
msgid ""
"Default values are available in both types of ConfigParsers. They are used "
"in interpolation if an option used is not defined elsewhere. ::"
msgstr "默认值在两种类型的 ConfigParser 中均可用。 它们将在当某个选项未在别处定义时被用于插值。 ::"
#: ../../library/configparser.rst:883
msgid "ConfigParser Objects"
msgstr "ConfigParser 对象"
#: ../../library/configparser.rst:887
msgid ""
"The main configuration parser. When *defaults* is given, it is initialized "
"into the dictionary of intrinsic defaults. When *dict_type* is given, it "
"will be used to create the dictionary objects for the list of sections, for "
"the options within a section, and for the default values."
msgstr ""
"主配置解析器。 当给定 *defaults* 时,它会被初始化为包含固有默认值的字典。 当给定 *dict_type* "
"时,它将被用来创建包含节、节中的选项以及默认值的字典。"
#: ../../library/configparser.rst:892
msgid ""
"When *delimiters* is given, it is used as the set of substrings that divide "
"keys from values. When *comment_prefixes* is given, it will be used as the "
"set of substrings that prefix comments in otherwise empty lines. Comments "
"can be indented. When *inline_comment_prefixes* is given, it will be used "
"as the set of substrings that prefix comments in non-empty lines."
msgstr ""
"当给定 *delimiters* 时,它会被用作分隔键与值的子字符串的集合。 当给定 *comment_prefixes* "
"时,它将被用作在否则为空行的注释的前缀子字符串的集合。 注释可以被缩进。 当给定 *inline_comment_prefixes* "
"时,它将被用作非空行的注释的前缀子字符串的集合。"
#: ../../library/configparser.rst:898
msgid ""
"When *strict* is ``True`` (the default), the parser won't allow for any "
"section or option duplicates while reading from a single source (file, "
"string or dictionary), raising :exc:`DuplicateSectionError` or "
":exc:`DuplicateOptionError`. When *empty_lines_in_values* is ``False`` "
"(default: ``True``), each empty line marks the end of an option. Otherwise,"
" internal empty lines of a multiline option are kept as part of the value. "
"When *allow_no_value* is ``True`` (default: ``False``), options without "
"values are accepted; the value held for these is ``None`` and they are "
"serialized without the trailing delimiter."
msgstr ""
"当 *strict* 为 ``True`` (默认值) 时,解析器在从单个源(文件、字符串或字典)读取时将不允许任何节或选项出现重复,否则会引发 "
":exc:`DuplicateSectionError` 或 :exc:`DuplicateOptionError`。 当 "
"*empty_lines_in_values* 为 ``False`` (默认值: ``True``) 时,每个空行均表示一个选项的结束。 "
"在其他情况下,一个多行选项内部的空行会被保留为值的一部分。 当 *allow_no_value* 为 ``True`` (默认值: ``False``)"
" 时,将接受没有值的选项;此种选项的值将为 ``None`` 并且它们会以不带末尾分隔符的形式被序列化。"
#: ../../library/configparser.rst:908
msgid ""
"When *default_section* is given, it specifies the name for the special "
"section holding default values for other sections and interpolation purposes"
" (normally named ``\"DEFAULT\"``). This value can be retrieved and changed "
"on runtime using the ``default_section`` instance attribute."
msgstr ""
"当给定 *default_section* 时,它将指定存放其他节的默认值和用于插值的特殊节的名称 (通常命名为 ``\"DEFAULT\"``)。 "
"该值可通过使用 ``default_section`` 实例属性在运行时被读取或修改。"
#: ../../library/configparser.rst:913
msgid ""
"Interpolation behaviour may be customized by providing a custom handler "
"through the *interpolation* argument. ``None`` can be used to turn off "
"interpolation completely, ``ExtendedInterpolation()`` provides a more "
"advanced variant inspired by ``zc.buildout``. More on the subject in the "
"`dedicated documentation section <#interpolation-of-values>`_."
msgstr ""
"插值行为可通过给出 *interpolation* 参数提供自定义处理程序的方式来定制。 ``None`` "
"可用来完全禁用插值,``ExtendedInterpolation()`` 提供了一种更高级的变体形式,它的设计受到了 ``zc.buildout`` "
"的启发。 有关该主题的更多信息请参见 `专门的文档章节 <#interpolation-of-values>`_。"
#: ../../library/configparser.rst:919
msgid ""
"All option names used in interpolation will be passed through the "
":meth:`optionxform` method just like any other option name reference. For "
"example, using the default implementation of :meth:`optionxform` (which "
"converts option names to lower case), the values ``foo %(bar)s`` and ``foo "
"%(BAR)s`` are equivalent."
msgstr ""
"插值中使用的所有选项名称将像任何其他选项名称引用一样通过 :meth:`optionxform` 方法来传递。 例如,使用 "
":meth:`optionxform` 的默认实现(它会将选项名称转换为小写形式)时,值 ``foo %(bar)s`` 和 ``foo "
"%(BAR)s`` 是等价的。"
#: ../../library/configparser.rst:925
msgid ""
"When *converters* is given, it should be a dictionary where each key "
"represents the name of a type converter and each value is a callable "
"implementing the conversion from string to the desired datatype. Every "
"converter gets its own corresponding :meth:`get*()` method on the parser "
"object and section proxies."
msgstr ""
"当给定 *converters* 时,它应当为一个字典,其中每个键代表一个类型转换器的名称而每个值则为实现从字符串到目标数据类型的转换的可调用对象。 "
"每个转换器会获得其在解析器对象和节代理上对应的 :meth:`get*()` 方法。"
#: ../../library/configparser.rst:931
msgid "The default *dict_type* is :class:`collections.OrderedDict`."
msgstr "默认的 *dict_type* 为 :class:`collections.OrderedDict`。"
#: ../../library/configparser.rst:934
msgid ""
"*allow_no_value*, *delimiters*, *comment_prefixes*, *strict*, "
"*empty_lines_in_values*, *default_section* and *interpolation* were added."
msgstr ""
"添加了 *allow_no_value*, *delimiters*, *comment_prefixes*, *strict*, "
"*empty_lines_in_values*, *default_section* 以及 *interpolation*。"
#: ../../library/configparser.rst:939
msgid "The *converters* argument was added."
msgstr "添加了 *converters* 参数。"
#: ../../library/configparser.rst:942
msgid ""
"The *defaults* argument is read with :meth:`read_dict()`, providing "
"consistent behavior across the parser: non-string keys and values are "
"implicitly converted to strings."
msgstr ""
"*defaults* 参数会通过 :meth:`read_dict()` "
"来读取,提供全解析器范围内一致的行为:非字符串类型的键和值会被隐式地转换为字符串。"
#: ../../library/configparser.rst:947 ../../library/configparser.rst:1232
msgid ""
"The default *dict_type* is :class:`dict`, since it now preserves insertion "
"order."
msgstr "默认的 *dict_type* 为 :class:`dict`,因为它现在会保留插入顺序。"
#: ../../library/configparser.rst:953
msgid "Return a dictionary containing the instance-wide defaults."
msgstr "返回包含实例范围内默认值的字典。"
#: ../../library/configparser.rst:958
msgid ""
"Return a list of the sections available; the *default section* is not "
"included in the list."
msgstr "返回可用节的列表;*default section* 不包括在该列表中。"
#: ../../library/configparser.rst:964
msgid ""
"Add a section named *section* to the instance. If a section by the given "
"name already exists, :exc:`DuplicateSectionError` is raised. If the "
"*default section* name is passed, :exc:`ValueError` is raised. The name of "
"the section must be a string; if not, :exc:`TypeError` is raised."
msgstr ""
"向实例添加一个名为 *section* 的节。 如果给定名称的节已存在,将会引发 :exc:`DuplicateSectionError`。 如果传入了"
" *default section* 名称,则会引发 :exc:`ValueError`。 节名称必须为字符串;如果不是则会引发 "
":exc:`TypeError`。"
#: ../../library/configparser.rst:969
msgid "Non-string section names raise :exc:`TypeError`."
msgstr "非字符串的节名称将引发 :exc:`TypeError`。"
#: ../../library/configparser.rst:975
msgid ""
"Indicates whether the named *section* is present in the configuration. The "
"*default section* is not acknowledged."
msgstr "指明相应名称的 *section* 是否存在于配置中。 *default section* 不包含在内。"
#: ../../library/configparser.rst:981
msgid "Return a list of options available in the specified *section*."
msgstr "返回指定 *section* 中可用选项的列表。"
#: ../../library/configparser.rst:986
msgid ""
"If the given *section* exists, and contains the given *option*, return "
":const:`True`; otherwise return :const:`False`. If the specified *section* "
"is :const:`None` or an empty string, DEFAULT is assumed."
msgstr ""
"如果给定的 *section* 存在并且包含给定的 *option* 则返回 :const:`True`;否则返回 :const:`False`。 "
"如果指定的 *section* 为 :const:`None` 或空字符串,则会使用 DEFAULT。"
#: ../../library/configparser.rst:993
msgid ""
"Attempt to read and parse an iterable of filenames, returning a list of "
"filenames which were successfully parsed."
msgstr "尝试读取并解析一个包含文件名的可迭代对象,返回一个被成功解析的文件名列表。"
#: ../../library/configparser.rst:996
msgid ""
"If *filenames* is a string, a :class:`bytes` object or a :term:`path-like "
"object`, it is treated as a single filename. If a file named in *filenames*"
" cannot be opened, that file will be ignored. This is designed so that you "
"can specify an iterable of potential configuration file locations (for "
"example, the current directory, the user's home directory, and some system-"
"wide directory), and all existing configuration files in the iterable will "
"be read."
msgstr ""
"如果 *filenames* 为字符串、:class:`bytes` 对象或 :term:`path-like "
"object`,它会被当作单个文件来处理。 如果 *filenames* 中名称对应的某个文件无法被打开,该文件将被忽略。 "
"这样的设计使得你可以指定包含多个潜在配置文件位置的可迭代对象(例如当前目录、用户家目录以及某个系统级目录),存在于该可迭代对象中的所有配置文件都将被读取。"
#: ../../library/configparser.rst:1005
msgid ""
"If none of the named files exist, the :class:`ConfigParser` instance will "
"contain an empty dataset. An application which requires initial values to "
"be loaded from a file should load the required file or files using "
":meth:`read_file` before calling :meth:`read` for any optional files::"
msgstr ""
"如果名称对应的文件全都不存在,则 :class:`ConfigParser` 实例将包含一个空数据集。 一个要求从文件加载初始值的应用应当在调用 "
":meth:`read` 来获取任何可选文件之前使用 :meth:`read_file` 来加载所要求的一个或多个文件::"
#: ../../library/configparser.rst:1018
msgid ""
"The *encoding* parameter. Previously, all files were read using the default"
" encoding for :func:`open`."
msgstr "*encoding* 形参。 在之前的版本中,所有文件都将使用 :func:`open` 的默认编码格式来读取。"
#: ../../library/configparser.rst:1022
msgid "The *filenames* parameter accepts a :term:`path-like object`."
msgstr "*filenames* 形参接受一个 :term:`path-like object`。"
#: ../../library/configparser.rst:1025
msgid "The *filenames* parameter accepts a :class:`bytes` object."
msgstr "*filenames* 形参接受一个 :class:`bytes` 对象。"
#: ../../library/configparser.rst:1031
msgid ""
"Read and parse configuration data from *f* which must be an iterable "
"yielding Unicode strings (for example files opened in text mode)."
msgstr "从 *f* 读取并解析配置数据,它必须是一个产生 Unicode 字符串的可迭代对象(例如以文本模式打开的文件)。"
#: ../../library/configparser.rst:1034
msgid ""
"Optional argument *source* specifies the name of the file being read. If "
"not given and *f* has a :attr:`name` attribute, that is used for *source*; "
"the default is ``'<???>'``."
msgstr ""
"可选参数 *source* 指定要读取的文件名称。 如果未给出并且 *f* 具有 :attr:`name` 属性,则该属性会被用作 "
"*source*;默认值为 ``'<???>'``。"
#: ../../library/configparser.rst:1038
msgid "Replaces :meth:`readfp`."
msgstr "替代 :meth:`readfp`。"
#: ../../library/configparser.rst:1043
msgid "Parse configuration data from a string."
msgstr "从字符串中解析配置数据。"
#: ../../library/configparser.rst:1045
msgid ""
"Optional argument *source* specifies a context-specific name of the string "
"passed. If not given, ``'<string>'`` is used. This should commonly be a "
"filesystem path or a URL."