From 24361d6bcc91f1deafdaa8c3da95e76027eabcca Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Fri, 7 Feb 2020 09:14:26 +0100 Subject: [PATCH] skip fields which are empty in CFG file #210 --- forms/table_manager.py | 3 +++ test/test_table_manager.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/forms/table_manager.py b/forms/table_manager.py index 37c4f22b..9bb2b173 100644 --- a/forms/table_manager.py +++ b/forms/table_manager.py @@ -271,6 +271,9 @@ def to_json(self): else: raise Exception('InputType "{}" not implemented'.format(input_type)) + if layer_data[key] == '': + layer_data.pop(key) + if export_legacy_single_row: if self.definitions.key() == 'atlas': layer_data['atlasEnabled'] = 'True' diff --git a/test/test_table_manager.py b/test/test_table_manager.py index 6cad9cad..5a27c1cd 100644 --- a/test/test_table_manager.py +++ b/test/test_table_manager.py @@ -92,6 +92,7 @@ def test_tool_tip(self): table_manager.from_json(json) self.assertEqual(table_manager.table.rowCount(), 1) data = table_manager.to_json() + json['lines'].pop('colorGeom') self.assertDictEqual(data, json) def test_attribute_table(self): @@ -152,7 +153,7 @@ def test_locate_by_layer(self): }, 'lines_2': { 'fieldName': 'name', - # 'filterFieldName': 'id', DISABLED on purpore. This field is not compulsory. + # 'filterFieldName': 'id', DISABLED on purpose. This field is not compulsory. 'displayGeom': 'False', 'minLength': 0, 'filterOnLocate': 'True', @@ -195,7 +196,6 @@ def test_locate_by_layer(self): expected = { 'lines_2': { 'fieldName': 'name', - 'filterFieldName': '', 'displayGeom': 'False', 'minLength': 0, 'filterOnLocate': 'True',