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
d9034195
Commit
d9034195
authored
Jul 20, 2010
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support of unicode type
parent
b7a8d1d8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
xml_marshaller/xml_marshaller.py
xml_marshaller/xml_marshaller.py
+13
-2
No files found.
xml_marshaller/xml_marshaller.py
View file @
d9034195
...
...
@@ -48,6 +48,7 @@ class Marshaller(object):
self
.
tag_float
=
E
.
float
self
.
tag_long
=
E
.
long
self
.
tag_string
=
E
.
string
self
.
tag_unicode
=
E
.
unicode
self
.
tag_tuple
=
E
.
tuple
self
.
tag_list
=
E
.
list
self
.
tag_dictionary
=
E
.
dictionary
...
...
@@ -136,6 +137,8 @@ class Marshaller(object):
def
m_string
(
self
,
value
,
kw
):
return
self
.
tag_string
(
escape
(
str
(
value
)))
def
m_unicode
(
self
,
value
,
kw
):
return
self
.
tag_unicode
(
value
)
# Since Python 2.2, the string type has a name of 'str'
# To avoid having to rewrite all classes that implement m_string
# we delegate m_str to m_string.
...
...
@@ -259,6 +262,7 @@ class Unmarshaller(ElementTreeContentHandler):
'float'
:
(
'um_start_float'
,
'um_end_float'
),
'long'
:
(
'um_start_long'
,
'um_end_long'
),
'string'
:
(
'um_start_string'
,
'um_end_string'
),
'unicode'
:
(
'um_start_unicode'
,
'um_end_unicode'
),
'tuple'
:
(
'um_start_tuple'
,
'um_end_tuple'
),
'list'
:
(
'um_start_list'
,
'um_end_list'
),
'dictionary'
:
(
'um_start_dictionary'
,
'um_end_dictionary'
),
...
...
@@ -408,7 +412,7 @@ class Unmarshaller(ElementTreeContentHandler):
self
.
data_stack
.
append
([])
self
.
accumulating_chars
=
1
um_start_float
=
um_start_long
=
um_start_string
=
um_start_generic
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
...
...
@@ -418,6 +422,12 @@ class Unmarshaller(ElementTreeContentHandler):
ds
[
-
1
]
=
unescape
(
''
.
join
(
ds
[
-
1
]))
self
.
accumulating_chars
=
0
def
um_end_unicode
(
self
,
name
):
ds
=
self
.
data_stack
# might need to convert unicode string to byte string
ds
[
-
1
]
=
unescape
(
''
.
join
(
ds
[
-
1
]))
self
.
accumulating_chars
=
0
def
um_end_int
(
self
,
name
):
ds
=
self
.
data_stack
ds
[
-
1
]
=
''
.
join
(
ds
[
-
1
])
...
...
@@ -599,7 +609,8 @@ def runtests(namespace_uri=None):
"here is a string & a <fake tag>"
,
(
1
,
2
,
3
),
[
'alpha'
,
'beta'
,
'gamma'
],
{
'key'
:
'value'
,
1
:
2
}
{
'key'
:
'value'
,
1
:
2
},
'éàù^ç'
.
decode
(
'utf-8'
),
]
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