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
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
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)
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))))
def cli_acl_role(node): return clidisplay.attr_value(node.get("id"))
def cli_acl_roleref(node, format=1): return "%s:%s" % (clidisplay.keyword("role"), clidisplay.attr_value(node.get("id")))
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))
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))