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
08f8dd6d
Kaydet (Commit)
08f8dd6d
authored
Tem 19, 2001
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added docstrings based on a patch by Evelyn Mitchell.
This closes SF patch #440153.
üst
a58947f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
sgmllib.py
Lib/sgmllib.py
+16
-11
No files found.
Lib/sgmllib.py
Dosyayı görüntüle @
08f8dd6d
...
...
@@ -65,37 +65,38 @@ class SGMLParseError(RuntimeError):
class
SGMLParser
:
# Interface -- initialize and reset this instance
def
__init__
(
self
,
verbose
=
0
):
"""Initialize and reset this instance."""
self
.
verbose
=
verbose
self
.
reset
()
# Interface -- reset this instance. Loses all unprocessed data
def
reset
(
self
):
"""Reset this instance. Loses all unprocessed data."""
self
.
rawdata
=
''
self
.
stack
=
[]
self
.
lasttag
=
'???'
self
.
nomoretags
=
0
self
.
literal
=
0
# For derived classes only -- enter literal mode (CDATA) till EOF
def
setnomoretags
(
self
):
"""Enter literal mode (CDATA) till EOF. Intended for derived
classes only."""
self
.
nomoretags
=
self
.
literal
=
1
# For derived classes only -- enter literal mode (CDATA)
def
setliteral
(
self
,
*
args
):
"""Enter literal mode (CDATA). Intended for derived classes only."""
self
.
literal
=
1
# Interface -- feed some data to the parser. Call this as
# often as you want, with as little or as much text as you
# want (may include '\n'). (This just saves the text, all the
# processing is done by goahead().)
def
feed
(
self
,
data
):
"""Feed some data to the parser. Call this as often as you
want, with as little or as much text as you want (may include
'
\n
'). (This just saves the text, all the processing is done
by goahead().)"""
self
.
rawdata
=
self
.
rawdata
+
data
self
.
goahead
(
0
)
# Interface -- handle the remaining data
def
close
(
self
):
"""Handle the remaining data."""
self
.
goahead
(
1
)
# Internal -- handle data as far as reasonable. May leave state
...
...
@@ -407,8 +408,8 @@ class SGMLParser:
print
'*** Unbalanced </'
+
tag
+
'>'
print
'*** Stack:'
,
self
.
stack
# Example -- handle character reference, no need to override
def
handle_charref
(
self
,
name
):
"""Handle character reference, no need to override."""
try
:
n
=
int
(
name
)
except
ValueError
:
...
...
@@ -423,8 +424,12 @@ class SGMLParser:
entitydefs
=
\
{
'lt'
:
'<'
,
'gt'
:
'>'
,
'amp'
:
'&'
,
'quot'
:
'"'
,
'apos'
:
'
\'
'
}
# Example -- handle entity reference, no need to override
def
handle_entityref
(
self
,
name
):
"""Handle entity references.
There should be no need to override this method; it can be
tailored by setting up the self.entitydefs mapping appropriately.
"""
table
=
self
.
entitydefs
if
table
.
has_key
(
name
):
self
.
handle_data
(
table
[
name
])
...
...
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