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
b9b6ce6f
Kaydet (Commit)
b9b6ce6f
authored
Agu 04, 2013
tarafından
Eli Bendersky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge fix for Issue #17011 from 3.3
üst
739e7500
2acc525a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
test_xml_etree.py
Lib/test/test_xml_etree.py
+14
-0
ElementPath.py
Lib/xml/etree/ElementPath.py
+4
-2
No files found.
Lib/test/test_xml_etree.py
Dosyayı görüntüle @
b9b6ce6f
...
@@ -1839,6 +1839,20 @@ class ElementFindTest(unittest.TestCase):
...
@@ -1839,6 +1839,20 @@ class ElementFindTest(unittest.TestCase):
summarize_list
(
e
.
findall
(
".//{http://effbot.org/ns}tag"
)),
summarize_list
(
e
.
findall
(
".//{http://effbot.org/ns}tag"
)),
[
'{http://effbot.org/ns}tag'
]
*
3
)
[
'{http://effbot.org/ns}tag'
]
*
3
)
def
test_findall_different_nsmaps
(
self
):
root
=
ET
.
XML
(
'''
<a xmlns:x="X" xmlns:y="Y">
<x:b><c/></x:b>
<b/>
<c><x:b/><b/></c><y:b/>
</a>'''
)
nsmap
=
{
'xx'
:
'X'
}
self
.
assertEqual
(
len
(
root
.
findall
(
".//xx:b"
,
namespaces
=
nsmap
)),
2
)
self
.
assertEqual
(
len
(
root
.
findall
(
".//b"
,
namespaces
=
nsmap
)),
2
)
nsmap
=
{
'xx'
:
'Y'
}
self
.
assertEqual
(
len
(
root
.
findall
(
".//xx:b"
,
namespaces
=
nsmap
)),
1
)
self
.
assertEqual
(
len
(
root
.
findall
(
".//b"
,
namespaces
=
nsmap
)),
2
)
def
test_bad_find
(
self
):
def
test_bad_find
(
self
):
e
=
ET
.
XML
(
SAMPLE_XML
)
e
=
ET
.
XML
(
SAMPLE_XML
)
with
self
.
assertRaisesRegex
(
SyntaxError
,
'cannot use absolute path'
):
with
self
.
assertRaisesRegex
(
SyntaxError
,
'cannot use absolute path'
):
...
...
Lib/xml/etree/ElementPath.py
Dosyayı görüntüle @
b9b6ce6f
...
@@ -249,10 +249,12 @@ class _SelectorContext:
...
@@ -249,10 +249,12 @@ class _SelectorContext:
def
iterfind
(
elem
,
path
,
namespaces
=
None
):
def
iterfind
(
elem
,
path
,
namespaces
=
None
):
# compile selector pattern
# compile selector pattern
cache_key
=
(
path
,
None
if
namespaces
is
None
else
tuple
(
sorted
(
namespaces
.
items
())))
if
path
[
-
1
:]
==
"/"
:
if
path
[
-
1
:]
==
"/"
:
path
=
path
+
"*"
# implicit all (FIXME: keep this?)
path
=
path
+
"*"
# implicit all (FIXME: keep this?)
try
:
try
:
selector
=
_cache
[
path
]
selector
=
_cache
[
cache_key
]
except
KeyError
:
except
KeyError
:
if
len
(
_cache
)
>
100
:
if
len
(
_cache
)
>
100
:
_cache
.
clear
()
_cache
.
clear
()
...
@@ -272,7 +274,7 @@ def iterfind(elem, path, namespaces=None):
...
@@ -272,7 +274,7 @@ def iterfind(elem, path, namespaces=None):
token
=
next
()
token
=
next
()
except
StopIteration
:
except
StopIteration
:
break
break
_cache
[
path
]
=
selector
_cache
[
cache_key
]
=
selector
# execute selector pattern
# execute selector pattern
result
=
[
elem
]
result
=
[
elem
]
context
=
_SelectorContext
(
elem
)
context
=
_SelectorContext
(
elem
)
...
...
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