def envs(self): """List required and optional environment variables.""" if not self.env_vars: puts('No ENV variables have been registered.') puts('To register an ENV variable, use the @env(key, value) ') puts('method decorator of your manager object.') return puts('Registered ENV vars per method.\n') for func_name in self.env_vars: puts('%s:' % func_name) for var, default in self.env_vars[func_name].items(): default = '(%s)' % default if default is not None else '' puts('\t%s%s' % (utils.min_width(var.upper(), 30), default)) puts('')
def puts(r): stdout = sys.stdout.write type_ = type(r) if type_ == list: return [puts(i) for i in r] elif type_ == dict: for key in r: puts(utils.min_width(key, 25) + r[key]) return elif type_ == Error: return puts(str(r)) elif type_ == bool: if r: return puts('OK') return puts('FAILED') elif r is not None: return utils.puts(str(r).rstrip('\n'), stream=stdout)
def format_line(command, w): return "%s%s" % ( utils.min_width(command.name, w), command.description )