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
def4728f
Kaydet (Commit)
def4728f
authored
Kas 18, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
#4147: merge with 3.2.
üst
4d5d4e28
8008f2ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
10 deletions
+45
-10
test_minidom.py
Lib/test/test_minidom.py
+32
-5
minidom.py
Lib/xml/dom/minidom.py
+9
-5
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/test/test_minidom.py
Dosyayı görüntüle @
def4728f
...
...
@@ -467,12 +467,39 @@ class MinidomTest(unittest.TestCase):
dom
.
unlink
()
self
.
confirm
(
domstr
==
str
.
replace
(
"
\n
"
,
"
\r\n
"
))
def
test_toprettyxml_with_text_nodes
(
self
):
# see issue #4147, text nodes are not indented
decl
=
'<?xml version="1.0" ?>
\n
'
self
.
assertEqual
(
parseString
(
'<B>A</B>'
)
.
toprettyxml
(),
decl
+
'<B>A</B>
\n
'
)
self
.
assertEqual
(
parseString
(
'<C>A<B>A</B></C>'
)
.
toprettyxml
(),
decl
+
'<C>
\n\t
A
\n\t
<B>A</B>
\n
</C>
\n
'
)
self
.
assertEqual
(
parseString
(
'<C><B>A</B>A</C>'
)
.
toprettyxml
(),
decl
+
'<C>
\n\t
<B>A</B>
\n\t
A
\n
</C>
\n
'
)
self
.
assertEqual
(
parseString
(
'<C><B>A</B><B>A</B></C>'
)
.
toprettyxml
(),
decl
+
'<C>
\n\t
<B>A</B>
\n\t
<B>A</B>
\n
</C>
\n
'
)
self
.
assertEqual
(
parseString
(
'<C><B>A</B>A<B>A</B></C>'
)
.
toprettyxml
(),
decl
+
'<C>
\n\t
<B>A</B>
\n\t
A
\n\t
<B>A</B>
\n
</C>
\n
'
)
def
test_toprettyxml_with_adjacent_text_nodes
(
self
):
# see issue #4147, adjacent text nodes are indented normally
dom
=
Document
()
elem
=
dom
.
createElement
(
'elem'
)
elem
.
appendChild
(
dom
.
createTextNode
(
'TEXT'
))
elem
.
appendChild
(
dom
.
createTextNode
(
'TEXT'
))
dom
.
appendChild
(
elem
)
decl
=
'<?xml version="1.0" ?>
\n
'
self
.
assertEqual
(
dom
.
toprettyxml
(),
decl
+
'<elem>
\n\t
TEXT
\n\t
TEXT
\n
</elem>
\n
'
)
def
test_toprettyxml_preserves_content_of_text_node
(
self
):
str
=
'<A>B</A>'
dom
=
parseString
(
str
)
dom2
=
parseString
(
dom
.
toprettyxml
())
self
.
assertEqual
(
dom
.
childNodes
[
0
]
.
childNodes
[
0
]
.
toxml
(),
dom2
.
childNodes
[
0
]
.
childNodes
[
0
]
.
toxml
())
# see issue #4147
for
str
in
(
'<B>A</B>'
,
'<A><B>C</B></A>'
):
dom
=
parseString
(
str
)
dom2
=
parseString
(
dom
.
toprettyxml
())
self
.
assertEqual
(
dom
.
getElementsByTagName
(
'B'
)[
0
]
.
childNodes
[
0
]
.
toxml
(),
dom2
.
getElementsByTagName
(
'B'
)[
0
]
.
childNodes
[
0
]
.
toxml
())
def
testProcessingInstruction
(
self
):
dom
=
parseString
(
'<e><?mypi
\t\n
data
\t\n
?></e>'
)
...
...
Lib/xml/dom/minidom.py
Dosyayı görüntüle @
def4728f
...
...
@@ -837,11 +837,15 @@ class Element(Node):
writer
.
write
(
"
\"
"
)
if
self
.
childNodes
:
writer
.
write
(
">"
)
if
self
.
childNodes
[
0
]
.
nodeType
!=
Node
.
TEXT_NODE
:
if
(
len
(
self
.
childNodes
)
==
1
and
self
.
childNodes
[
0
]
.
nodeType
==
Node
.
TEXT_NODE
):
self
.
childNodes
[
0
]
.
writexml
(
writer
,
''
,
''
,
''
)
else
:
writer
.
write
(
newl
)
for
node
in
self
.
childNodes
:
node
.
writexml
(
writer
,
indent
+
addindent
,
addindent
,
newl
)
writer
.
write
(
"
%
s</
%
s>
%
s"
%
(
indent
,
self
.
tagName
,
newl
))
for
node
in
self
.
childNodes
:
node
.
writexml
(
writer
,
indent
+
addindent
,
addindent
,
newl
)
writer
.
write
(
indent
)
writer
.
write
(
"</
%
s>
%
s"
%
(
self
.
tagName
,
newl
))
else
:
writer
.
write
(
"/>
%
s"
%
(
newl
))
...
...
@@ -1063,7 +1067,7 @@ class Text(CharacterData):
return
newText
def
writexml
(
self
,
writer
,
indent
=
""
,
addindent
=
""
,
newl
=
""
):
_write_data
(
writer
,
self
.
data
)
_write_data
(
writer
,
"
%
s
%
s
%
s"
%
(
indent
,
self
.
data
,
newl
)
)
# DOM Level 3 (WD 9 April 2002)
...
...
Misc/NEWS
Dosyayı görüntüle @
def4728f
...
...
@@ -377,6 +377,10 @@ Core and Builtins
Library
-------
-
Issue
#
4147
:
minidom
's toprettyxml no longer adds whitespace around a text
node when it is the only child of an element. Initial patch by Dan
Kenigsberg.
- Issue #13374: The Windows bytes API has been deprecated in the os module. Use
Unicode filenames instead of bytes filenames to not depend on the ANSI code
page anymore and to support any filename.
...
...
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