From 7894a3e8b932018090f73a7864d38e1a5f2ac244 Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Fri, 28 Jun 2019 21:08:02 -0400 Subject: [PATCH] Fix handling of --dump-config when there is no existing config file and when the existing config file is empty --- cmake_format/__main__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake_format/__main__.py b/cmake_format/__main__.py index 48b105c..c7a7b50 100644 --- a/cmake_format/__main__.py +++ b/cmake_format/__main__.py @@ -245,6 +245,9 @@ def dump_config(args, config_dict, outfile): outfmt = args.dump_config + if config_dict is None: + config_dict = {} + for key, value in vars(args).items(): if (key in configuration.Configuration.get_field_names() and value is not None): @@ -422,6 +425,8 @@ def main(): and value is not None): config_dict[key] = value + if config_dict is None: + config_dict = {} cfg = configuration.Configuration(**config_dict) if args.in_place: ofd, tempfile_path = tempfile.mkstemp(suffix='.txt', prefix='CMakeLists-')