From 07150497ab3469967f82e481e15292937dacd172 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Fri, 2 Oct 2009 14:36:32 +0100 Subject: [PATCH] cli.CalculateOSNames Given an os and its variants, return a list of "full" os names. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Olivier Tharan <olive@google.com> --- lib/cli.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/cli.py b/lib/cli.py index 698f03f30..d4dfee675 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -158,6 +158,7 @@ __all__ = [ "OPT_COMPL_ONE_OS", "cli_option", "SplitNodeOption", + "CalculateOSNames", ] NO_PREFIX = "no_" @@ -971,6 +972,23 @@ def SplitNodeOption(value): return (value, None) +def CalculateOSNames(os_name, os_variants): + """Calculates all the names an OS can be called, according to its variants. + + @type os_name: string + @param os_name: base name of the os + @type os_variants: list or None + @param os_variants: list of supported variants + @rtype: list + @return: list of valid names + + """ + if os_variants: + return ['%s+%s' % (os_name, v) for v in os_variants] + else: + return [os_name] + + def UsesRPC(fn): def wrapper(*args, **kwargs): rpc.Init() -- GitLab