def main(conf, args, opts): if opts.dump: conf.write(sys.stdout) return 0 if opts.all: for sec in args: if conf.has_section(sec): print("[%s]" % (sec)) items = conf.items(sec) items.sort() for (n, v) in items: print("%s = %s" % (n, v)) print() return 0 sep = ',' if opts.list: sep = ' ' option = args[0] for sec in args[1:]: if conf.has_section(sec): if conf.has_option(sec, option): configtools.print_list( configtools.get_list(conf.get(sec, option)), sep) return 0 return 1
def main(conf, args, opts): if not conf: return 1 if opts.dump: conf.write(sys.stdout) return 0 if opts.all: for sec in args: if conf.has_section(sec): print("[%s]" % (sec)) items = conf.items(sec) items.sort() for (n, v) in items: print("%s = %s" % (n, v)) print() return 0 sep = ',' if opts.list: sep = ' ' if args: option = args[0] for sec in args[1:]: if conf.has_section(sec): if conf.has_option(sec, option): configtools.print_list(configtools.get_list(conf.get(sec, option)), sep) return 0 return 1
def main(conf, args, opts): sep = ',' if opts.list: sep = ' ' hostclasses = configtools.get_host_classes(conf) if opts.listclasses: configtools.print_list(hostclasses, sep) return 0 # all hosts if len(args) == 1 and args[0] == 'all': opts.all = True if opts.all: hosts = [] for hostclass in hostclasses: hosts.extend(configtools.get_list(conf.get("hosts", hostclass))) configtools.print_list(hosts, sep) return 0 # hosts in a single class if opts.listclass in hostclasses: hosts = configtools.get_list(conf.get("hosts", opts.listclass)) configtools.print_list(hosts, sep) return 0 # otherwise all the args should be classes: gather up their hosts: hosts = [] for a in args: if a in hostclasses: hosts.extend(configtools.get_list(conf.get("hosts", a))) else: return 1 configtools.print_list(hosts, sep) return 0