[SEBA-412] Automated reformat of Python code

Passes of modernize, autopep8, black, then check with flake8

flake8 + manual fixes:
  lib/xos-config
  lib/xos-kafka
  lib/xos-util
  xos/coreapi
  xos/api
  xos/xos_client

Change-Id: Ib23cf84cb13beb3c6381fa0d79594dc9131dc815
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions/tosca.py b/lib/xos-genx/xosgenx/jinja2_extensions/tosca.py
index 996d63d..d8eada7 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions/tosca.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions/tosca.py
@@ -14,12 +14,14 @@
 
 from xosgenx.jinja2_extensions import xproto_field_graph_components
 
+
 def xproto_tosca_required(null, blank, default=None):
 
-    if null == 'True' or blank == 'True' or default != 'False':
+    if null == "True" or blank == "True" or default != "False":
         return "false"
     return "true"
 
+
 def xproto_tosca_field_type(type):
     """
     TOSCA requires fields of type 'bool' to be 'boolean'
@@ -33,30 +35,41 @@
     else:
         return type
 
+
 def xproto_fields_to_tosca_keys(fields, m):
     keys = []
 
     # look for one_of keys
-    _one_of = xproto_field_graph_components(fields, m, 'tosca_key_one_of')
+    _one_of = xproto_field_graph_components(fields, m, "tosca_key_one_of")
     one_of = [list(i) for i in _one_of]
 
     # look for explicit keys
     for f in fields:
-        if 'tosca_key' in f['options'] and f['options']['tosca_key'] and 'link' not in f:
-            keys.append(f['name'])
-        if 'tosca_key' in f['options'] and f['options']['tosca_key'] and ('link' in f and f['link']):
-            keys.append("%s_id" % f['name'])
+        if (
+            "tosca_key" in f["options"]
+            and f["options"]["tosca_key"]
+            and "link" not in f
+        ):
+            keys.append(f["name"])
+        if (
+            "tosca_key" in f["options"]
+            and f["options"]["tosca_key"]
+            and ("link" in f and f["link"])
+        ):
+            keys.append("%s_id" % f["name"])
     # if not keys are specified and there is a name field, use that as key.
-    if len(keys) == 0 and 'name' in map(lambda f: f['name'], fields):
-        keys.append('name')
+    if len(keys) == 0 and "name" in map(lambda f: f["name"], fields):
+        keys.append("name")
 
     for of in one_of:
         # check if the field is a link, and in case add _id
         for index, f in enumerate(of):
             try:
-                field = [x for x in fields if x['name'] == f and ('link' in x and x['link'])][0]
+                field = [
+                    x for x in fields if x["name"] == f and ("link" in x and x["link"])
+                ][0]
                 of[index] = "%s_id" % f
-            except IndexError, e:
+            except IndexError as e:
                 # the field is not a link
                 pass