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
8d5dd98a
Kaydet (Commit)
8d5dd98a
authored
Ara 30, 2002
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
- added InterpolationSyntaxError to __all__
- added docstring to exceptions
üst
81e4aa70
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
ConfigParser.py
Lib/ConfigParser.py
+25
-4
No files found.
Lib/ConfigParser.py
Dosyayı görüntüle @
8d5dd98a
...
@@ -89,9 +89,10 @@ ConfigParser -- responsible for for parsing a list of
...
@@ -89,9 +89,10 @@ ConfigParser -- responsible for for parsing a list of
import
re
import
re
__all__
=
[
"NoSectionError"
,
"DuplicateSectionError"
,
"NoOptionError"
,
__all__
=
[
"NoSectionError"
,
"DuplicateSectionError"
,
"NoOptionError"
,
"InterpolationError"
,
"InterpolationDepthError"
,
"ParsingError"
,
"InterpolationError"
,
"InterpolationDepthError"
,
"MissingSectionHeaderError"
,
"ConfigParser"
,
"InterpolationSyntaxError"
,
"ParsingError"
,
"MissingSectionHeaderError"
,
"ConfigParser"
,
"DEFAULTSECT"
,
"MAX_INTERPOLATION_DEPTH"
]
"DEFAULTSECT"
,
"MAX_INTERPOLATION_DEPTH"
]
DEFAULTSECT
=
"DEFAULT"
DEFAULTSECT
=
"DEFAULT"
...
@@ -102,24 +103,34 @@ MAX_INTERPOLATION_DEPTH = 10
...
@@ -102,24 +103,34 @@ MAX_INTERPOLATION_DEPTH = 10
# exception classes
# exception classes
class
Error
(
Exception
):
class
Error
(
Exception
):
"""Base class for ConfigParser exceptions."""
def
__init__
(
self
,
msg
=
''
):
def
__init__
(
self
,
msg
=
''
):
self
.
_msg
=
msg
self
.
_msg
=
msg
Exception
.
__init__
(
self
,
msg
)
Exception
.
__init__
(
self
,
msg
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
_msg
return
self
.
_msg
__str__
=
__repr__
__str__
=
__repr__
class
NoSectionError
(
Error
):
class
NoSectionError
(
Error
):
"""Raised when no section matches a requested option."""
def
__init__
(
self
,
section
):
def
__init__
(
self
,
section
):
Error
.
__init__
(
self
,
'No section:
%
s'
%
section
)
Error
.
__init__
(
self
,
'No section:
%
s'
%
section
)
self
.
section
=
section
self
.
section
=
section
class
DuplicateSectionError
(
Error
):
class
DuplicateSectionError
(
Error
):
"""Raised when a section is multiply-created."""
def
__init__
(
self
,
section
):
def
__init__
(
self
,
section
):
Error
.
__init__
(
self
,
"Section
%
s already exists"
%
section
)
Error
.
__init__
(
self
,
"Section
%
s already exists"
%
section
)
self
.
section
=
section
self
.
section
=
section
class
NoOptionError
(
Error
):
class
NoOptionError
(
Error
):
"""A requested option was not found."""
def
__init__
(
self
,
option
,
section
):
def
__init__
(
self
,
option
,
section
):
Error
.
__init__
(
self
,
"No option `
%
s' in section:
%
s"
%
Error
.
__init__
(
self
,
"No option `
%
s' in section:
%
s"
%
(
option
,
section
))
(
option
,
section
))
...
@@ -127,6 +138,8 @@ class NoOptionError(Error):
...
@@ -127,6 +138,8 @@ class NoOptionError(Error):
self
.
section
=
section
self
.
section
=
section
class
InterpolationError
(
Error
):
class
InterpolationError
(
Error
):
"""A string substitution required a setting which was not available."""
def
__init__
(
self
,
reference
,
option
,
section
,
rawval
):
def
__init__
(
self
,
reference
,
option
,
section
,
rawval
):
Error
.
__init__
(
self
,
Error
.
__init__
(
self
,
"Bad value substitution:
\n
"
"Bad value substitution:
\n
"
...
@@ -139,9 +152,13 @@ class InterpolationError(Error):
...
@@ -139,9 +152,13 @@ class InterpolationError(Error):
self
.
option
=
option
self
.
option
=
option
self
.
section
=
section
self
.
section
=
section
class
InterpolationSyntaxError
(
Error
):
pass
class
InterpolationSyntaxError
(
Error
):
"""Raised when the source text into which substitutions are made
does not conform to the required syntax."""
class
InterpolationDepthError
(
Error
):
class
InterpolationDepthError
(
Error
):
"""Raised when substitutions are nested too deeply."""
def
__init__
(
self
,
option
,
section
,
rawval
):
def
__init__
(
self
,
option
,
section
,
rawval
):
Error
.
__init__
(
self
,
Error
.
__init__
(
self
,
"Value interpolation too deeply recursive:
\n
"
"Value interpolation too deeply recursive:
\n
"
...
@@ -153,6 +170,8 @@ class InterpolationDepthError(Error):
...
@@ -153,6 +170,8 @@ class InterpolationDepthError(Error):
self
.
section
=
section
self
.
section
=
section
class
ParsingError
(
Error
):
class
ParsingError
(
Error
):
"""Raised when a configuration file does not follow legal syntax."""
def
__init__
(
self
,
filename
):
def
__init__
(
self
,
filename
):
Error
.
__init__
(
self
,
'File contains parsing errors:
%
s'
%
filename
)
Error
.
__init__
(
self
,
'File contains parsing errors:
%
s'
%
filename
)
self
.
filename
=
filename
self
.
filename
=
filename
...
@@ -163,6 +182,8 @@ class ParsingError(Error):
...
@@ -163,6 +182,8 @@ class ParsingError(Error):
self
.
_msg
=
self
.
_msg
+
'
\n\t
[line
%2
d]:
%
s'
%
(
lineno
,
line
)
self
.
_msg
=
self
.
_msg
+
'
\n\t
[line
%2
d]:
%
s'
%
(
lineno
,
line
)
class
MissingSectionHeaderError
(
ParsingError
):
class
MissingSectionHeaderError
(
ParsingError
):
"""Raised when a key-value pair is found before any section header."""
def
__init__
(
self
,
filename
,
lineno
,
line
):
def
__init__
(
self
,
filename
,
lineno
,
line
):
Error
.
__init__
(
Error
.
__init__
(
self
,
self
,
...
...
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