Revision 8b4b9936 ncclient/content/builders.py

b/ncclient/content/builders.py
23 23
    '''
24 24
    
25 25
    def __init__(self, spec):
26
        self._root = Builder.build(spec)
26
        self._root = TreeBuilder.build(spec)
27 27
        
28 28
    def to_string(self, encoding='utf-8'):
29 29
        return ET.tostring(self._root, encoding)
......
39 39
            ele = ET.Element(spec.get('tag'), spec.get('attributes', {}))
40 40
            ele.text = spec.get('text', '')
41 41
            for child in spec.get('children', []):
42
                ele.append(Builder.build(child))
42
                ele.append(TreeBuilder.build(child))
43 43
            return ele
44 44
        elif spec.has_key('comment'):
45 45
            return ET.Comment(spec.get('comment'))
......
53 53
    def build(capabilities, encoding='utf-8'):
54 54
        children = [{'tag': 'capability', 'text': uri } for uri in capabilities]
55 55
        spec = {
56
            'tag': _('hello', Hello.NS),
56
            'tag': _('hello', BASE_NS),
57 57
            'children': [{
58 58
                        'tag': 'capabilities',
59 59
                        'children': children
......
65 65
class RPCBuilder:
66 66
    
67 67
    @staticmethod
68
    def build(msgid, op, encoding='utf-8'):
69
        if isinstance(opspec, basestring):
70
            return build_from_string(msgid, op, encoding)
71
        else:
72
            return build_from_spec(msgid, op, encoding)
73
    
74
    @staticmethod
68 75
    def build_from_spec(msgid, opspec, encoding='utf-8'):
69 76
        if isinstance(opspec, dict):
70 77
            opspec = [opspec]
71 78
        return TreeBuilder({
72
                'tag': _('rpc', RPC.NS),
79
                'tag': _('rpc', BASE_NS),
73 80
                'attributes': {'message-id': msgid},
74 81
                'children': opspec
75 82
                }).to_string(encoding)

Also available in: Unified diff