Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xml_marshaller
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
xml_marshaller
Commits
830cb13b
Commit
830cb13b
authored
Oct 07, 2010
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support boolean transformation
parent
7865e237
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
xml_marshaller/xml_marshaller.py
xml_marshaller/xml_marshaller.py
+13
-0
No files found.
xml_marshaller/xml_marshaller.py
View file @
830cb13b
...
...
@@ -58,6 +58,7 @@ class Marshaller(object):
self
.
tag_none
=
E
.
none
self
.
tag_instance
=
E
.
object
self
.
tag_set
=
E
.
set
self
.
tag_bool
=
E
.
bool
# The four basic functions that form the caller's interface
def
dump
(
self
,
value
,
file
):
...
...
@@ -200,6 +201,9 @@ class Marshaller(object):
xml_tree
.
append
(
self
.
_marshal
(
elem
,
kw
))
return
xml_tree
def
m_bool
(
self
,
value
,
kw
):
return
self
.
tag_bool
(
value
and
'1'
or
'0'
)
# Python 2.2 renames dictionary to dict.
def
m_dict
(
self
,
value
,
kw
):
return
self
.
m_dictionary
(
value
,
kw
)
...
...
@@ -284,6 +288,7 @@ class Unmarshaller(ElementTreeContentHandler):
'none'
:
(
'um_start_none'
,
'um_end_none'
),
'object'
:
(
'um_start_instance'
,
'um_end_instance'
),
'set'
:
(
'um_start_set'
,
'um_end_set'
),
'bool'
:
(
'um_start_bool'
,
'um_end_bool'
),
}
def
__init__
(
self
):
...
...
@@ -428,6 +433,7 @@ class Unmarshaller(ElementTreeContentHandler):
um_start_float
=
um_start_long
=
um_start_string
=
um_start_unicode
=
um_start_generic
um_start_complex
=
um_start_code
=
um_start_none
=
um_start_generic
um_start_int
=
um_start_generic
um_start_bool
=
um_start_generic
def
um_end_string
(
self
,
name
):
ds
=
self
.
data_stack
...
...
@@ -497,6 +503,11 @@ class Unmarshaller(ElementTreeContentHandler):
self
.
kw
[
id
]
=
S
self
.
data_stack
.
append
(
S
)
def
um_end_bool
(
self
,
name
):
ds
=
self
.
data_stack
ds
[
-
1
]
=
bool
(
int
(
''
.
join
(
ds
[
-
1
])))
self
.
accumulating_chars
=
0
def
um_end_list
(
self
,
name
):
ds
=
self
.
data_stack
for
index
in
range
(
len
(
ds
)
-
1
,
-
1
,
-
1
):
...
...
@@ -644,6 +655,8 @@ def runtests(namespace_uri=None):
{
'key'
:
'value'
,
1
:
2
},
'éàù^ç'
.
decode
(
'utf-8'
),
set
((
'a'
,
1
,)),
True
,
False
]
if
namespace_uri
:
test
(
load
,
loads
,
dump_ns
,
dumps_ns
,
L
)
...
...
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