Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2ca041fd
Kaydet (Commit)
2ca041fd
authored
Eyl 27, 2002
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
items(): New method, provided by Gustavo Niemeyer in SF bug #545096.
üst
309db061
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
libcfgparser.tex
Doc/lib/libcfgparser.tex
+7
-0
ConfigParser.py
Lib/ConfigParser.py
+33
-0
No files found.
Doc/lib/libcfgparser.tex
Dosyayı görüntüle @
2ca041fd
...
...
@@ -189,6 +189,13 @@ values are checked in a case-insensitive manner. Any other value will
cause it to raise
\exception
{
ValueError
}
.
\end{methoddesc}
\begin{methoddesc}
{
items
}{
section
\optional
{
, raw
\optional
{
, vars
}}}
Create a generator which will return a tuple
\code
{
(name, value)
}
for
each option in the given
\var
{
section
}
. Optional arguments have the
same meaning as for the
\code
{
get()
}
method.
\versionadded
{
2.3
}
\end{methoddesc}
\begin{methoddesc}
{
set
}{
section, option, value
}
If the given section exists, set the given option to the specified value;
otherwise raise
\exception
{
NoSectionError
}
.
...
...
Lib/ConfigParser.py
Dosyayı görüntüle @
2ca041fd
...
...
@@ -70,6 +70,10 @@ ConfigParser -- responsible for for parsing a list of
insensitively defined as 0, false, no, off for 0, and 1, true,
yes, on for 1). Returns 0 or 1.
items(section, raw=0, vars=None)
return a list of tuples with (name, value) for each option
in the section.
remove_section(section)
remove the given file section and all its options
...
...
@@ -278,6 +282,35 @@ class ConfigParser:
return
value
return
self
.
_interpolate
(
section
,
option
,
value
,
d
)
def
items
(
self
,
section
,
raw
=
0
,
vars
=
None
):
"""Return a list of tuples with (name, value) for each option
in the section.
All
%
interpolations are expanded in the return values, based on the
defaults passed into the constructor, unless the optional argument
`raw' is true. Additional substitutions may be provided using the
`vars' argument, which must be a dictionary whose contents overrides
any pre-existing defaults.
The section DEFAULT is special.
"""
d
=
self
.
__defaults
.
copy
()
try
:
d
.
update
(
self
.
__sections
[
section
])
except
KeyError
:
if
section
!=
DEFAULTSECT
:
raise
NoSectionError
(
section
)
# Update with the entry specific variables
if
vars
:
d
.
update
(
vars
)
if
raw
:
for
option
in
self
.
options
(
section
):
yield
(
option
,
d
[
option
])
else
:
for
option
in
self
.
options
(
section
):
yield
(
option
,
self
.
_interpolate
(
section
,
option
,
d
[
option
],
d
))
def
_interpolate
(
self
,
section
,
option
,
rawval
,
vars
):
# do the string interpolation
value
=
rawval
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment