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
6b2e63c4
Commit
6b2e63c4
authored
May 31, 2010
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add load_tree function
parent
a5981724
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
setup.py
setup.py
+1
-1
xml_marshaller/xml_marshaller.py
xml_marshaller/xml_marshaller.py
+14
-1
No files found.
setup.py
View file @
6b2e63c4
from
setuptools
import
setup
,
find_packages
import
sys
,
os
version
=
'0.9'
version
=
'0.9
a
'
setup
(
name
=
'xml_marshaller'
,
version
=
version
,
...
...
xml_marshaller/xml_marshaller.py
View file @
6b2e63c4
...
...
@@ -13,7 +13,7 @@ from types import ClassType
import
sys
from
xml.sax
import
make_parser
from
xml.sax.saxutils
import
escape
,
unescape
from
lxml.sax
import
ElementTreeContentHandler
from
lxml.sax
import
ElementTreeContentHandler
,
saxify
from
lxml
import
etree
from
lxml.builder
import
ElementMaker
from
cStringIO
import
StringIO
...
...
@@ -300,6 +300,18 @@ class Unmarshaller(ElementTreeContentHandler):
m
=
self
.
__class__
()
return
m
.
_load
(
file_object
)
def
load_tree
(
self
,
tree
):
"""Unmarshal element_tree object and return
python object.
"""
parser
=
make_parser
()
parser
.
setFeature
(
'http://xml.org/sax/features/namespaces'
,
True
)
parser
.
setContentHandler
(
self
)
saxify
(
tree
,
self
)
result
=
self
.
data_stack
[
0
]
self
.
_clear
()
return
result
def
loads
(
self
,
string
):
"Unmarshal one value from a string"
# Instantiate a new object; unmarshalling isn't thread-safe
...
...
@@ -552,6 +564,7 @@ dumps_ns = _m_ns.dumps
_um
=
Unmarshaller
()
load
=
_um
.
load
loads
=
_um
.
loads
load_tree
=
_um
.
load_tree
del
_m
,
_um
,
_m_ns
...
...
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