Exemple #1
0
def dump_config(args, config_dict, outfile):
    """
  Dump the default configuration to stdout
  """

    outfmt = args.dump_config
    config_dict.update(get_argdict(args))
    cfg = configuration.Configuration(**config_dict)
    # Don't dump default per-command configs
    for key in standard_funs.get_default_config():
        cfg.misc.per_command.pop(key, None)

    if outfmt == 'yaml':
        import yaml
        yaml_register_odict(yaml.SafeDumper)
        yaml_register_odict(yaml.Dumper)
        yaml.dump(cfg.as_odict(args.with_help, args.with_defaults),
                  outfile,
                  indent=2,
                  default_flow_style=False,
                  sort_keys=False)
        return
    if outfmt == 'json':
        json.dump(cfg.as_odict(args.with_help, args.with_defaults),
                  outfile,
                  indent=2)
        outfile.write('\n')
        return

    cfg.dump(outfile,
             with_help=args.with_help,
             with_defaults=args.with_defaults)
Exemple #2
0
    def _update_derived(self):
        self.per_command_ = standard_funs.get_default_config()
        for command, cdict in self.per_command.items():
            if not isinstance(cdict, dict):
                logging.warning("Invalid override of type %s for %s",
                                type(cdict), command)
                continue

            command = command.lower()
            if command not in self.per_command_:
                self.per_command_[command] = {}
            self.per_command_[command].update(cdict)