Beispiel #1
0
def cli_acl_spec2_format(xml_spec, v):
    key_f = clidisplay.keyword(xml_spec)
    if xml_spec == "xpath":
        (shortcut, spec_l) = find_acl_shortcut(v)
        if shortcut:
            key_f = clidisplay.keyword(shortcut)
            v_f = ':'.join([clidisplay.attr_value(x) for x in spec_l])
        else:
            v_f = clidisplay.attr_value(quote_wrap(v))
    else:  # ref, type and attr
        v_f = clidisplay.attr_value(v)
    return v_f and '%s:%s' % (key_f, v_f) or key_f
Beispiel #2
0
def cli_acl_spec2_format(xml_spec, v):
    key_f = clidisplay.keyword(xml_spec)
    if xml_spec == "xpath":
        (shortcut, spec_l) = find_acl_shortcut(v)
        if shortcut:
            key_f = clidisplay.keyword(shortcut)
            v_f = ':'.join([clidisplay.attr_value(x) for x in spec_l])
        else:
            v_f = clidisplay.attr_value(quote_wrap(v))
    else:  # ref, type and attr
        v_f = clidisplay.attr_value(v)
    return v_f and '%s:%s' % (key_f, v_f) or key_f
Beispiel #3
0
def acl_spec_format(xml_spec, v):
    key_f = clidisplay.keyword(constants.acl_spec_map[xml_spec])
    if xml_spec == "xpath":
        (shortcut, spec_l) = find_acl_shortcut(v)
        if shortcut:
            key_f = clidisplay.keyword(shortcut)
            v_f = ':'.join([clidisplay.attr_value(x) for x in spec_l])
        else:
            v_f = clidisplay.attr_value(quote_wrap(v))
    elif xml_spec == "ref":
        v_f = '%s' % clidisplay.attr_value(v)
    else:  # tag and attribute
        v_f = '%s' % clidisplay.attr_value(v)
    return v_f and '%s:%s' % (key_f, v_f) or key_f
Beispiel #4
0
def acl_spec_format(xml_spec, v):
    key_f = clidisplay.keyword(constants.acl_spec_map[xml_spec])
    if xml_spec == "xpath":
        (shortcut, spec_l) = find_acl_shortcut(v)
        if shortcut:
            key_f = clidisplay.keyword(shortcut)
            v_f = ':'.join([clidisplay.attr_value(x) for x in spec_l])
        else:
            v_f = clidisplay.attr_value(quote_wrap(v))
    elif xml_spec == "ref":
        v_f = '%s' % clidisplay.attr_value(v)
    else:  # tag and attribute
        v_f = '%s' % clidisplay.attr_value(v)
    return v_f and '%s:%s' % (key_f, v_f) or key_f
Beispiel #5
0
def date_exp2cli(node):
    kwmap = {'in_range': 'in', 'date_spec': 'spec'}
    l = []
    operation = node.get("operation")
    l.append(clidisplay.keyword("date"))
    l.append(clidisplay.keyword(kwmap.get(operation, operation)))
    if operation in utils.olist(constants.simple_date_ops):
        value = node.get(utils.keyword_cmp(operation, 'lt') and "end" or "start")
        l.append(clidisplay.attr_value(quote_wrap(value)))
    else:
        if operation == 'in_range':
            for name in constants.in_range_attrs:
                if name in node.attrib:
                    l.append(nvpair_format(name, node.attrib[name]))
        for c in node.iterchildren():
            if c.tag in ("duration", "date_spec"):
                l.extend([nvpair_format(name, c.get(name))
                          for name in c.keys() if name != 'id'])
    return ' '.join(l)
Beispiel #6
0
def date_exp2cli(node):
    kwmap = {'in_range': 'in', 'date_spec': 'spec'}
    l = []
    operation = node.get("operation")
    l.append(clidisplay.keyword("date"))
    l.append(clidisplay.keyword(kwmap.get(operation, operation)))
    if operation in utils.olist(constants.simple_date_ops):
        value = node.get(utils.keyword_cmp(operation, 'lt') and "end" or "start")
        l.append(clidisplay.attr_value(quote_wrap(value)))
    else:
        if operation == 'in_range':
            for name in constants.in_range_attrs:
                if name in node.attrib:
                    l.append(nvpair_format(name, node.attrib[name]))
        for c in node.iterchildren():
            if c.tag in ("duration", "date_spec"):
                l.extend([nvpair_format(name, c.get(name))
                          for name in c.keys() if name != 'id'])
    return ' '.join(l)
Beispiel #7
0
def nvpair_format(n, v):
    if v is None:
        return clidisplay.attr_name(n)
    else:
        return '='.join((clidisplay.attr_name(n),
                         clidisplay.attr_value(quote_wrap(v))))
Beispiel #8
0
def cli_acl_role(node):
    return clidisplay.attr_value(node.get("id"))
Beispiel #9
0
def cli_acl_roleref(node, format=1):
    return "%s:%s" % (clidisplay.keyword("role"),
                      clidisplay.attr_value(node.get("id")))
Beispiel #10
0
def head_id_format(nodeid):
    "Special format for property list / node id"
    if utils.noquotes(nodeid):
        return "%s:" % (clidisplay.attr_value(nodeid))
    return '%s="%s"' % (clidisplay.attr_name('$id'),
                        clidisplay.attr_value(nodeid))
Beispiel #11
0
def nvpair_format(n, v):
    if v is None:
        return clidisplay.attr_name(n)
    else:
        return '='.join((clidisplay.attr_name(n),
                         clidisplay.attr_value(quote_wrap(v))))
Beispiel #12
0
def cli_acl_role(node):
    return clidisplay.attr_value(node.get("id"))
Beispiel #13
0
def cli_acl_roleref(node, format=1):
    return "%s:%s" % (clidisplay.keyword("role"),
                      clidisplay.attr_value(node.get("id")))
Beispiel #14
0
def head_id_format(nodeid):
    "Special format for property list / node id"
    if utils.noquotes(nodeid):
        return "%s:" % (clidisplay.id(nodeid))
    return '%s="%s"' % (clidisplay.id('$id'),
                        clidisplay.attr_value(nodeid))