Revision ebf2bbc6 ncclient/content.py

b/ncclient/content.py
16 16

  
17 17
from xml.etree import cElementTree as ET
18 18

  
19
from ncclient import NCClientError
20

  
21
class ContentError(NCClientError): pass
19 22

  
20 23
### Namespace-related ###
21 24

  
......
124 127

  
125 128
iselement = ET.iselement
126 129

  
127
def isdom(x): return True # TODO
130
# def isdom(x): return True # TODO
128 131

  
129
def root_ensured(rep, tag):
132
def ensured(rep, req_tag, req_attrs=None):
130 133
    if isinstance(rep, basestring):
131 134
        rep = ET.XML(rep)
132
    err = False
133
    if ((iselement(rep) and (rep.tag not in (tag, qualify(tag))) or (isdom(x)))): 
134
        raise ArgumentError("Expected root element [%s] not found" % tag)
135
    else:
136
        return rep
135
    if iselement(rep) and (rep.tag not in (req_tag, qualify(req_tag): 
136
        raise ContentError("Required root element [%s] not found" % req_tag)
137
    if req_attrs is not None:
138
        pass # TODO
139
    return rep

Also available in: Unified diff