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
b6a6f5f8
Kaydet (Commit)
b6a6f5f8
authored
Ara 03, 2010
tarafından
Łukasz Langa
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 10499: Modular interpolation in configparser
üst
ecace28e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
2 deletions
+83
-2
configparser.rst
Doc/library/configparser.rst
+0
-0
fileformats.rst
Doc/library/fileformats.rst
+1
-1
configparser.py
Lib/configparser.py
+0
-0
test_cfgparser.py
Lib/test/test_cfgparser.py
+74
-1
NEWS
Misc/NEWS
+8
-0
No files found.
Doc/library/configparser.rst
Dosyayı görüntüle @
b6a6f5f8
This diff is collapsed.
Click to expand it.
Doc/library/fileformats.rst
Dosyayı görüntüle @
b6a6f5f8
...
...
@@ -5,7 +5,7 @@ File Formats
************
The modules described in this chapter parse various miscellaneous file formats
that aren't markup languages
or are
related to e-mail.
that aren't markup languages
and are not
related to e-mail.
.. toctree::
...
...
Lib/configparser.py
Dosyayı görüntüle @
b6a6f5f8
This diff is collapsed.
Click to expand it.
Lib/test/test_cfgparser.py
Dosyayı görüntüle @
b6a6f5f8
...
...
@@ -4,6 +4,7 @@ import io
import
os
import
unittest
import
textwrap
import
warnings
from
test
import
support
...
...
@@ -32,6 +33,7 @@ class CfgParserTestCaseClass(unittest.TestCase):
dict_type
=
configparser
.
_default_dict
strict
=
False
default_section
=
configparser
.
DEFAULTSECT
interpolation
=
configparser
.
_UNSET
def
newconfig
(
self
,
defaults
=
None
):
arguments
=
dict
(
...
...
@@ -43,8 +45,12 @@ class CfgParserTestCaseClass(unittest.TestCase):
dict_type
=
self
.
dict_type
,
strict
=
self
.
strict
,
default_section
=
self
.
default_section
,
interpolation
=
self
.
interpolation
,
)
return
self
.
config_class
(
**
arguments
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
category
=
DeprecationWarning
)
instance
=
self
.
config_class
(
**
arguments
)
return
instance
def
fromstring
(
self
,
string
,
defaults
=
None
):
cf
=
self
.
newconfig
(
defaults
)
...
...
@@ -847,6 +853,70 @@ class SafeConfigParserTestCase(ConfigParserTestCase):
cf
=
self
.
newconfig
()
self
.
assertRaises
(
ValueError
,
cf
.
add_section
,
self
.
default_section
)
class
SafeConfigParserTestCaseExtendedInterpolation
(
BasicTestCase
):
config_class
=
configparser
.
SafeConfigParser
interpolation
=
configparser
.
ExtendedInterpolation
()
default_section
=
'common'
def
test_extended_interpolation
(
self
):
cf
=
self
.
fromstring
(
textwrap
.
dedent
(
"""
[common]
favourite Beatle = Paul
favourite color = green
[tom]
favourite band = ${favourite color} day
favourite pope = John ${favourite Beatle} II
sequel = ${favourite pope}I
[ambv]
favourite Beatle = George
son of Edward VII = ${favourite Beatle} V
son of George V = ${son of Edward VII}I
[stanley]
favourite Beatle = ${ambv:favourite Beatle}
favourite pope = ${tom:favourite pope}
favourite color = black
favourite state of mind = paranoid
favourite movie = soylent ${common:favourite color}
favourite song = ${favourite color} sabbath - ${favourite state of mind}
"""
)
.
strip
())
eq
=
self
.
assertEqual
eq
(
cf
[
'common'
][
'favourite Beatle'
],
'Paul'
)
eq
(
cf
[
'common'
][
'favourite color'
],
'green'
)
eq
(
cf
[
'tom'
][
'favourite Beatle'
],
'Paul'
)
eq
(
cf
[
'tom'
][
'favourite color'
],
'green'
)
eq
(
cf
[
'tom'
][
'favourite band'
],
'green day'
)
eq
(
cf
[
'tom'
][
'favourite pope'
],
'John Paul II'
)
eq
(
cf
[
'tom'
][
'sequel'
],
'John Paul III'
)
eq
(
cf
[
'ambv'
][
'favourite Beatle'
],
'George'
)
eq
(
cf
[
'ambv'
][
'favourite color'
],
'green'
)
eq
(
cf
[
'ambv'
][
'son of Edward VII'
],
'George V'
)
eq
(
cf
[
'ambv'
][
'son of George V'
],
'George VI'
)
eq
(
cf
[
'stanley'
][
'favourite Beatle'
],
'George'
)
eq
(
cf
[
'stanley'
][
'favourite color'
],
'black'
)
eq
(
cf
[
'stanley'
][
'favourite state of mind'
],
'paranoid'
)
eq
(
cf
[
'stanley'
][
'favourite movie'
],
'soylent green'
)
eq
(
cf
[
'stanley'
][
'favourite pope'
],
'John Paul II'
)
eq
(
cf
[
'stanley'
][
'favourite song'
],
'black sabbath - paranoid'
)
def
test_endless_loop
(
self
):
cf
=
self
.
fromstring
(
textwrap
.
dedent
(
"""
[one for you]
ping = ${one for me:pong}
[one for me]
pong = ${one for you:ping}
"""
)
.
strip
())
with
self
.
assertRaises
(
configparser
.
InterpolationDepthError
):
cf
[
'one for you'
][
'ping'
]
class
SafeConfigParserTestCaseNonStandardDelimiters
(
SafeConfigParserTestCase
):
delimiters
=
(
':='
,
'$'
)
comment_prefixes
=
(
'//'
,
'"'
)
...
...
@@ -910,6 +980,8 @@ class Issue7005TestCase(unittest.TestCase):
def
prepare
(
self
,
config_class
):
# This is the default, but that's the point.
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
category
=
DeprecationWarning
)
cp
=
config_class
(
allow_no_value
=
False
)
cp
.
add_section
(
"section"
)
cp
.
set
(
"section"
,
"option"
,
None
)
...
...
@@ -978,6 +1050,7 @@ def test_main():
RawConfigParserTestCaseNonStandardDelimiters
,
RawConfigParserTestSambaConf
,
SafeConfigParserTestCase
,
SafeConfigParserTestCaseExtendedInterpolation
,
SafeConfigParserTestCaseNonStandardDelimiters
,
SafeConfigParserTestCaseNoValue
,
SafeConfigParserTestCaseTrickyFile
,
...
...
Misc/NEWS
Dosyayı görüntüle @
b6a6f5f8
...
...
@@ -149,6 +149,14 @@ Library
- Issue #10467: Fix BytesIO.readinto() after seeking into a position after the
end of the file.
- configparser: the ConfigParser class has been deprecated in favor of
SafeConfigParser. Usage of RawConfigParser is now discouraged for new
projects in favor of SafeConfigParser(interpolation=None).
- Issue #10499: configparser supports pluggable interpolation handlers. New
interpolation handler added (ExtendedInterpolation) which supports the syntax
used by zc.buildout (e.g. interpolation between sections).
- Issue #1682942: configparser supports alternative option/value delimiters.
- Issue #5412: configparser supports mapping protocol access.
...
...
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