Revision 31050dcb
b/ncclient/content/builders.py | ||
---|---|---|
75 | 75 |
def build_from_spec(msgid, opspec, encoding='utf-8'): |
76 | 76 |
if isinstance(opspec, dict): |
77 | 77 |
opspec = [opspec] |
78 |
return TreeBuilder({ |
|
79 |
'tag': _('rpc', BASE_NS), |
|
80 |
'attributes': {'message-id': msgid}, |
|
81 |
'children': opspec |
|
82 |
}).to_string(encoding) |
|
78 |
spec = { |
|
79 |
'tag': _('rpc', BASE_NS), |
|
80 |
'attributes': {'message-id': msgid}, |
|
81 |
'children': opspec |
|
82 |
} |
|
83 |
return TreeBuilder(spec).to_string(encoding) |
|
83 | 84 |
|
84 | 85 |
@staticmethod |
85 | 86 |
def build_from_string(msgid, opstr, encoding='utf-8'): |
86 | 87 |
decl = '<?xml version="1.0" encoding="%s"?>' % encoding |
87 | 88 |
doc = (u'''<rpc message-id="%s" xmlns="%s">%s</rpc>''' % |
88 |
(msgid, RPC.NS, opstr)).encode(encoding)
|
|
89 |
(msgid, BASE_NS, opstr)).encode(encoding)
|
|
89 | 90 |
return (decl + doc) |
Also available in: Unified diff