From ae8eec484f07a92cac7d5462769873ad6af980e3 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Wed, 8 Apr 2015 15:47:02 +0200 Subject: utils_cib: make rg2hb_xsl a bit more versatile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...avoid repeating the same argument if dst and src params are identical, if src is not defined, it derives value of dst automatically. Signed-off-by: Jan Pokorný --- utils_cib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils_cib.py b/utils_cib.py index 76a5012..b26c186 100644 --- a/utils_cib.py +++ b/utils_cib.py @@ -1,5 +1,5 @@ # -*- coding: UTF-8 -*- -# Copyright 2014 Red Hat, Inc. +# Copyright 2015 Red Hat, Inc. # Part of clufter project # Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) """CIB helpers, mainly used in the filter definitions""" @@ -64,13 +64,17 @@ class ResourceSpec(object): return ret -def rg2hb_xsl(dst, src, req=False, op=False): +def rg2hb_xsl(dst, src=None, req=False, op=False): """Emit XSL snippet yielding nvpair-encoded HB RA parameter from RG one Parameters: + dst destination parameter (name in the nvpair) + src source parameter (if not provided, use dst ~ 1:1 match) req valid values: False, True, abs (use raw `src` instead) + op whether this is relevant for "operations" section """ assert req in (False, True, abs), "Invalid `req` param" + src = src or dst return (('''\ ''' if not req else '') + (('''\ -- cgit