# Copyright (C) 2008-2011 Dejan Muhamedagic # Copyright (C) 2013 Kristoffer Gronlund # See COPYING for license information. import os import re import shlex from . import command from . import completers as compl from . import utils from . import config from . import userdir from . import options from .template import LoadTemplate from .cliformat import cli_format from .cibconfig import mkset_obj, cib_factory from . import log logger = log.setup_logger(__name__) logger_utils = log.LoggerUtils(logger) def check_transition(inp, state, possible_l): if state not in possible_l: logger.error("input (%s) in wrong state %s", inp, state) return False return True def _unique_config_name(tmpl): n = 0 while n < 99: c = "%s-%d" % (tmpl, n) if not os.path.isfile("%s/%s" % (userdir.CRMCONF_DIR, c)): return c n += 1 raise ValueError("Failed to generate unique configuration name") class Template(command.UI): ''' Configuration templates. ''' name = "template" def __init__(self): command.UI.__init__(self) self.curr_conf = '' self.init_dir() @command.skill_level('administrator') @command.completers_repeating(compl.null, compl.call(utils.listtemplates)) def do_new(self, context, name, *args): "usage: new []