Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
I
inary
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)
1
Konular (issue)
1
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ç
SulinOS
inary
Commits
0da7c4c3
Kaydet (Commit)
0da7c4c3
authored
Eki 26, 2005
tarafından
Eray Özkural
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
* revert the list spec to the old flexible way, specfile requires that
:(
üst
51d35343
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
xmlfile.py
pisi/xmlfile.py
+10
-4
a.xml
tests/a.xml
+0
-2
xmlfiletests.py
tests/xmlfiletests.py
+3
-3
No files found.
pisi/xmlfile.py
Dosyayı görüntüle @
0da7c4c3
...
...
@@ -505,8 +505,12 @@ class autoxml(oo.autosuper):
def
gen_list_tag
(
cls
,
tag
,
spec
):
"""generate a list datatype. stores comps in tag/comp_tag"""
name
,
tag_type
,
req
,
comp_tag
=
cls
.
parse_spec
(
tag
,
spec
)
name
,
tag_type
,
req
,
path
=
cls
.
parse_spec
(
tag
,
spec
)
#head, last = cls.tagpath_head_last(path)
pathcomps
=
path
.
split
(
'/'
)
list_tagpath
=
path
[:
path
.
rfind
(
'/'
)]
comp_tag
=
pathcomps
[
len
(
pathcomps
)
-
1
]
#TODO: make default path ... tag + '/' + comp_tag when comp is class!
if
len
(
tag_type
)
!=
1
:
raise
Error
(
_
(
'List type must contain only one element'
))
...
...
@@ -519,7 +523,7 @@ class autoxml(oo.autosuper):
def
decode
(
node
,
errs
,
where
):
l
=
[]
nodes
=
getAllNodes
(
node
,
tag
+
'/'
+
comp_tag
)
nodes
=
getAllNodes
(
node
,
path
)
#print node, tag + '/' + comp_tag, nodes
if
len
(
nodes
)
is
0
and
req
is
mandatory
:
errs
.
append
(
where
+
_
(
'Mandatory list empty'
))
...
...
@@ -531,11 +535,13 @@ class autoxml(oo.autosuper):
return
l
def
encode
(
xml
,
node
,
l
,
errs
):
dom
=
node
.
ownerDocument
if
l
and
len
(
l
)
>
0
:
listnode
=
xml
.
newNode
(
tag
)
for
item
in
l
:
listnode
=
xml
.
newNode
(
"Dummy"
)
encode_item
(
xml
,
listnode
,
item
,
errs
)
node
.
appendChild
(
listnode
)
node
=
getNode
(
listnode
,
comp_tag
)
addNode
(
dom
,
node
,
path
)
else
:
if
req
is
mandatory
:
errs
.
append
(
_
(
'Mandatory list empty'
))
...
...
tests/a.xml
Dosyayı görüntüle @
0da7c4c3
...
...
@@ -5,11 +5,9 @@
<Number>
868
</Number>
<Description>
Lazy Tin
</Description>
<Description
xml:lang=
"tr"
>
Tembel Teneke
</Description>
<Projects>
<Project>
pisi
</Project>
<Project>
noatun
</Project>
<Project>
kdevelop
</Project>
</Projects>
<OtherInfo>
<BirthDate>
18071976
</BirthDate>
<Interest>
AI
</Interest>
...
...
tests/xmlfiletests.py
Dosyayı görüntüle @
0da7c4c3
...
...
@@ -32,7 +32,7 @@ class XmlFileTestCase(unittest.TestCase):
__metaclass__
=
xmlfile
.
autoxml
t_BirthDate
=
[
types
.
StringType
,
xmlfile
.
mandatory
]
t_Interest
=
[
types
.
StringType
,
xmlfile
.
optional
]
t_CodesWith
=
[
[
types
.
StringType
],
xmlfile
.
optional
,
'Person'
]
t_CodesWith
=
[
[
types
.
StringType
],
xmlfile
.
optional
,
'
CodesWith/
Person'
]
class
A
(
xmlfile
.
XmlFile
):
__metaclass__
=
xmlfile
.
autoxml
...
...
@@ -41,14 +41,14 @@ class XmlFileTestCase(unittest.TestCase):
t_Number
=
[
types
.
IntType
,
xmlfile
.
optional
]
t_Email
=
[
types
.
StringType
,
xmlfile
.
optional
]
a_href
=
[
types
.
StringType
,
xmlfile
.
mandatory
]
t_Projects
=
[
[
types
.
StringType
],
xmlfile
.
mandatory
,
'Project'
,
''
]
t_Projects
=
[
[
types
.
StringType
],
xmlfile
.
mandatory
,
'Project'
]
t_OtherInfo
=
[
OtherInfo
,
xmlfile
.
optional
]
a
=
A
()
self
.
assertEqual
(
a
.
href
,
None
)
dom
=
mdom
.
parse
(
'tests/a.xml'
)
node
=
getNode
(
dom
,
'A'
)
self
.
assert
_
(
len
(
A
.
decoders
)
>
0
)
self
.
assert
Equal
(
len
(
A
.
decoders
),
4
)
errs
=
[]
print
'errs'
,
errs
a
.
decode
(
node
,
errs
)
...
...
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