Auto-generated patch by python-black
[integration/test.git] / csit / scripts / generate_searchSourceJSON.py
index c8a78d82a9ceabe2d313e6e9af4c8bb29883c929..8a709597821f68a7468b5a550b5b93ace46cfbad 100644 (file)
@@ -1,18 +1,16 @@
 from copy import deepcopy as dc
 
 # Template for search source format
-SEARCH_SOURCE_FORMAT = {"index": None, "filter": [],
-                        "query": {"language": "lucene", "query": ""}}
+SEARCH_SOURCE_FORMAT = {
+    "index": None,
+    "filter": [],
+    "query": {"language": "lucene", "query": ""},
+}
 
 # Template for filter format
 FILTER_FORMAT = {
     "query": {
-        "match": {
-            "placeholder_field": {
-                "query": "query_phrase",
-                "type": "phrase"
-            }
-        }
+        "match": {"placeholder_field": {"query": "query_phrase", "type": "phrase"}}
     }
 }
 
@@ -30,39 +28,37 @@ def generate(dash_config, viz_config, index_pattern):
     #           match-with: pattern
 
     try:
-        filters = dash_config['filter']
+        filters = dash_config["filter"]
         for _, value in filters.items():
             try:
                 temp = dc(FILTER_FORMAT)
-                temp['query']['match'][value['field']
-                                       ] = \
-                    temp['query']['match']['placeholder_field']
-                temp['query']['match'][value['field']
-                                       ]['query'] = value['match-with']
-                del temp['query']['match']['placeholder_field']
-                search_source['filter'].append(temp)
+                temp["query"]["match"][value["field"]] = temp["query"]["match"][
+                    "placeholder_field"
+                ]
+                temp["query"]["match"][value["field"]]["query"] = value["match-with"]
+                del temp["query"]["match"]["placeholder_field"]
+                search_source["filter"].append(temp)
             except KeyError:
                 continue
     except KeyError:
         pass
 
     try:
-        filters = viz_config['filter']
+        filters = viz_config["filter"]
         for _, value in filters.items():
             try:
                 temp = dc(FILTER_FORMAT)
-                temp['query']['match'][value['field']
-                                       ] = \
-                    temp['query']['match']['placeholder_field']
-                temp['query']['match'][value['field']
-                                       ]['query'] = value['match-with']
-                del temp['query']['match']['placeholder_field']
-                search_source['filter'].append(temp)
+                temp["query"]["match"][value["field"]] = temp["query"]["match"][
+                    "placeholder_field"
+                ]
+                temp["query"]["match"][value["field"]]["query"] = value["match-with"]
+                del temp["query"]["match"]["placeholder_field"]
+                search_source["filter"].append(temp)
             except KeyError:
                 continue
     except KeyError:
         pass
 
-    search_source['index'] = index_pattern
+    search_source["index"] = index_pattern
 
     return search_source