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
26d513cf
Kaydet (Commit)
26d513cf
authored
Kas 10, 2010
tarafından
Łukasz Langa
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #5412: extend configparser to support mapping access
üst
47f637ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
45 deletions
+25
-45
configparser.rst
Doc/library/configparser.rst
+0
-0
configparser.py
Lib/configparser.py
+0
-0
config.py
Lib/logging/config.py
+25
-45
test_cfgparser.py
Lib/test/test_cfgparser.py
+0
-0
No files found.
Doc/library/configparser.rst
Dosyayı görüntüle @
26d513cf
This diff is collapsed.
Click to expand it.
Lib/configparser.py
Dosyayı görüntüle @
26d513cf
This diff is collapsed.
Click to expand it.
Lib/logging/config.py
Dosyayı görüntüle @
26d513cf
...
...
@@ -103,7 +103,7 @@ def _encoded(s):
def
_create_formatters
(
cp
):
"""Create and return formatters"""
flist
=
cp
.
get
(
"formatters"
,
"keys"
)
flist
=
cp
[
"formatters"
][
"keys"
]
if
not
len
(
flist
):
return
{}
flist
=
flist
.
split
(
","
)
...
...
@@ -111,20 +111,12 @@ def _create_formatters(cp):
formatters
=
{}
for
form
in
flist
:
sectname
=
"formatter_
%
s"
%
form
opts
=
cp
.
options
(
sectname
)
if
"format"
in
opts
:
fs
=
cp
.
get
(
sectname
,
"format"
,
1
)
else
:
fs
=
None
if
"datefmt"
in
opts
:
dfs
=
cp
.
get
(
sectname
,
"datefmt"
,
1
)
else
:
dfs
=
None
fs
=
cp
.
get
(
sectname
,
"format"
,
raw
=
True
,
fallback
=
None
)
dfs
=
cp
.
get
(
sectname
,
"datefmt"
,
raw
=
True
,
fallback
=
None
)
c
=
logging
.
Formatter
if
"class"
in
opts
:
class_name
=
cp
.
get
(
sectname
,
"class"
)
if
class_name
:
c
=
_resolve
(
class_name
)
class_name
=
cp
[
sectname
]
.
get
(
"class"
)
if
class_name
:
c
=
_resolve
(
class_name
)
f
=
c
(
fs
,
dfs
)
formatters
[
form
]
=
f
return
formatters
...
...
@@ -132,7 +124,7 @@ def _create_formatters(cp):
def
_install_handlers
(
cp
,
formatters
):
"""Install and return handlers"""
hlist
=
cp
.
get
(
"handlers"
,
"keys"
)
hlist
=
cp
[
"handlers"
][
"keys"
]
if
not
len
(
hlist
):
return
{}
hlist
=
hlist
.
split
(
","
)
...
...
@@ -140,30 +132,23 @@ def _install_handlers(cp, formatters):
handlers
=
{}
fixups
=
[]
#for inter-handler references
for
hand
in
hlist
:
sectname
=
"handler_
%
s"
%
hand
klass
=
cp
.
get
(
sectname
,
"class"
)
opts
=
cp
.
options
(
sectname
)
if
"formatter"
in
opts
:
fmt
=
cp
.
get
(
sectname
,
"formatter"
)
else
:
fmt
=
""
section
=
cp
[
"handler_
%
s"
%
hand
]
klass
=
section
[
"class"
]
fmt
=
section
.
get
(
"formatter"
,
""
)
try
:
klass
=
eval
(
klass
,
vars
(
logging
))
except
(
AttributeError
,
NameError
):
klass
=
_resolve
(
klass
)
args
=
cp
.
get
(
sectname
,
"args"
)
args
=
section
[
"args"
]
args
=
eval
(
args
,
vars
(
logging
))
h
=
klass
(
*
args
)
if
"level"
in
opts
:
level
=
cp
.
get
(
sectname
,
"level"
)
if
"level"
in
section
:
level
=
section
[
"level"
]
h
.
setLevel
(
logging
.
_levelNames
[
level
])
if
len
(
fmt
):
h
.
setFormatter
(
formatters
[
fmt
])
if
issubclass
(
klass
,
logging
.
handlers
.
MemoryHandler
):
if
"target"
in
opts
:
target
=
cp
.
get
(
sectname
,
"target"
)
else
:
target
=
""
target
=
section
.
get
(
"target"
,
""
)
if
len
(
target
):
#the target handler may not be loaded yet, so keep for later...
fixups
.
append
((
h
,
target
))
handlers
[
hand
]
=
h
...
...
@@ -197,20 +182,19 @@ def _install_loggers(cp, handlers, disable_existing):
"""Create and install loggers"""
# configure the root first
llist
=
cp
.
get
(
"loggers"
,
"keys"
)
llist
=
cp
[
"loggers"
][
"keys"
]
llist
=
llist
.
split
(
","
)
llist
=
list
(
map
(
lambda
x
:
x
.
strip
(),
llist
))
llist
.
remove
(
"root"
)
sect
name
=
"logger_root"
sect
ion
=
cp
[
"logger_root"
]
root
=
logging
.
root
log
=
root
opts
=
cp
.
options
(
sectname
)
if
"level"
in
opts
:
level
=
cp
.
get
(
sectname
,
"level"
)
if
"level"
in
section
:
level
=
section
[
"level"
]
log
.
setLevel
(
logging
.
_levelNames
[
level
])
for
h
in
root
.
handlers
[:]:
root
.
removeHandler
(
h
)
hlist
=
cp
.
get
(
sectname
,
"handlers"
)
hlist
=
section
[
"handlers"
]
if
len
(
hlist
):
hlist
=
hlist
.
split
(
","
)
hlist
=
_strip_spaces
(
hlist
)
...
...
@@ -237,13 +221,9 @@ def _install_loggers(cp, handlers, disable_existing):
child_loggers
=
[]
#now set up the new ones...
for
log
in
llist
:
sectname
=
"logger_
%
s"
%
log
qn
=
cp
.
get
(
sectname
,
"qualname"
)
opts
=
cp
.
options
(
sectname
)
if
"propagate"
in
opts
:
propagate
=
cp
.
getint
(
sectname
,
"propagate"
)
else
:
propagate
=
1
section
=
cp
[
"logger_
%
s"
%
log
]
qn
=
section
[
"qualname"
]
propagate
=
section
.
getint
(
"propagate"
,
fallback
=
1
)
logger
=
logging
.
getLogger
(
qn
)
if
qn
in
existing
:
i
=
existing
.
index
(
qn
)
...
...
@@ -255,14 +235,14 @@ def _install_loggers(cp, handlers, disable_existing):
child_loggers
.
append
(
existing
[
i
])
i
=
i
+
1
existing
.
remove
(
qn
)
if
"level"
in
opts
:
level
=
cp
.
get
(
sectname
,
"level"
)
if
"level"
in
section
:
level
=
section
[
"level"
]
logger
.
setLevel
(
logging
.
_levelNames
[
level
])
for
h
in
logger
.
handlers
[:]:
logger
.
removeHandler
(
h
)
logger
.
propagate
=
propagate
logger
.
disabled
=
0
hlist
=
cp
.
get
(
sectname
,
"handlers"
)
hlist
=
section
[
"handlers"
]
if
len
(
hlist
):
hlist
=
hlist
.
split
(
","
)
hlist
=
_strip_spaces
(
hlist
)
...
...
Lib/test/test_cfgparser.py
Dosyayı görüntüle @
26d513cf
This diff is collapsed.
Click to expand it.
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