black: re-format

black and isort are enabled in the openbmc-build-scripts on Python files
to have a consistent formatting.  Re-run the formatter on the whole
repository.

Change-Id: If1010ead857d41364c024bf8145a979a9377d382
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/lib/bmc_redfish.py b/lib/bmc_redfish.py
index 2ae405a..0e97af7 100644
--- a/lib/bmc_redfish.py
+++ b/lib/bmc_redfish.py
@@ -4,17 +4,16 @@
 See class prolog below for details.
 """
 
-import sys
-import re
 import json
-from redfish_plus import redfish_plus
-from robot.libraries.BuiltIn import BuiltIn
+import re
+import sys
 from json.decoder import JSONDecodeError
-from redfish.rest.v1 import InvalidCredentialsError
 
 import func_args as fa
 import gen_print as gp
-
+from redfish.rest.v1 import InvalidCredentialsError
+from redfish_plus import redfish_plus
+from robot.libraries.BuiltIn import BuiltIn
 
 MTLS_ENABLED = BuiltIn().get_variable_value("${MTLS_ENABLED}")
 
@@ -44,7 +43,7 @@
         """
         self.__inited__ = False
         try:
-            if MTLS_ENABLED == 'True':
+            if MTLS_ENABLED == "True":
                 self.__inited__ = True
             else:
                 super(bmc_redfish, self).__init__(*args, **kwargs)
@@ -70,7 +69,7 @@
         kwargs                      See parent class method prolog for details.
         """
 
-        if MTLS_ENABLED == 'True':
+        if MTLS_ENABLED == "True":
             return None
         if not self.__inited__:
             message = "bmc_redfish.__init__() was never successfully run.  It "
@@ -82,11 +81,12 @@
         openbmc_password = BuiltIn().get_variable_value("${OPENBMC_PASSWORD}")
         username, args, kwargs = fa.pop_arg(openbmc_username, *args, **kwargs)
         password, args, kwargs = fa.pop_arg(openbmc_password, *args, **kwargs)
-        auth, args, kwargs = fa.pop_arg('session', *args, **kwargs)
+        auth, args, kwargs = fa.pop_arg("session", *args, **kwargs)
 
         try:
-            super(bmc_redfish, self).login(username, password, auth,
-                                           *args, **kwargs)
+            super(bmc_redfish, self).login(
+                username, password, auth, *args, **kwargs
+            )
         # Handle InvalidCredentialsError.
         # (raise redfish.rest.v1.InvalidCredentialsError if not [200, 201, 202, 204])
         except InvalidCredentialsError:
@@ -96,8 +96,9 @@
             e_message = "Re-try login due to exception and "
             e_message += "it is likely error response from server side."
             BuiltIn().log_to_console(e_message)
-            super(bmc_redfish, self).login(username, password, auth,
-                                           *args, **kwargs)
+            super(bmc_redfish, self).login(
+                username, password, auth, *args, **kwargs
+            )
         # Handle JSONDecodeError and others.
         except JSONDecodeError:
             except_type, except_value, except_traceback = sys.exc_info()
@@ -106,8 +107,9 @@
             e_message = "Re-try login due to JSONDecodeError exception and "
             e_message += "it is likely error response from server side."
             BuiltIn().log_to_console(e_message)
-            super(bmc_redfish, self).login(username, password, auth,
-                                           *args, **kwargs)
+            super(bmc_redfish, self).login(
+                username, password, auth, *args, **kwargs
+            )
         except ValueError:
             except_type, except_value, except_traceback = sys.exc_info()
             BuiltIn().log_to_console(str(except_type))
@@ -116,8 +118,7 @@
             BuiltIn().log_to_console(e_message)
 
     def logout(self):
-
-        if MTLS_ENABLED == 'True':
+        if MTLS_ENABLED == "True":
             return None
         else:
             super(bmc_redfish, self).logout()
@@ -150,7 +151,7 @@
         """
 
         resp = self.get(*args, **kwargs)
-        return resp.dict if hasattr(resp, 'dict') else {}
+        return resp.dict if hasattr(resp, "dict") else {}
 
     def get_attribute(self, path, attribute, default=None, *args, **kwargs):
         r"""
@@ -183,8 +184,9 @@
         kwargs                      See parent class get() prolog for details.
         """
 
-        return self.get_properties(path, *args, **kwargs).get(attribute,
-                                                              default)
+        return self.get_properties(path, *args, **kwargs).get(
+            attribute, default
+        )
 
     def get_session_info(self):
         r"""
@@ -194,7 +196,9 @@
 
         return self.get_session_key(), self.get_session_location()
 
-    def enumerate(self, resource_path, return_json=1, include_dead_resources=False):
+    def enumerate(
+        self, resource_path, return_json=1, include_dead_resources=False
+    ):
         r"""
         Perform a GET enumerate request and return available resource paths.
 
@@ -224,38 +228,61 @@
                 # Example: '/redfish/v1/JsonSchemas/' and sub resources.
                 #          '/redfish/v1/SessionService'
                 #          '/redfish/v1/Managers/bmc#/Oem'
-                if ('JsonSchemas' in resource) or ('SessionService' in resource) or ('#' in resource):
+                if (
+                    ("JsonSchemas" in resource)
+                    or ("SessionService" in resource)
+                    or ("#" in resource)
+                ):
                     continue
 
-                self._rest_response_ = self.get(resource, valid_status_codes=[200, 404, 500])
+                self._rest_response_ = self.get(
+                    resource, valid_status_codes=[200, 404, 500]
+                )
                 # Enumeration is done for available resources ignoring the ones for which response is not
                 # obtained.
                 if self._rest_response_.status != 200:
                     if include_dead_resources:
                         try:
-                            dead_resources[self._rest_response_.status].append(resource)
+                            dead_resources[self._rest_response_.status].append(
+                                resource
+                            )
                         except KeyError:
-                            dead_resources[self._rest_response_.status] = [resource]
+                            dead_resources[self._rest_response_.status] = [
+                                resource
+                            ]
                     continue
                 self.walk_nested_dict(self._rest_response_.dict, url=resource)
 
             enumerated_resources.update(set(resources_to_be_enumerated))
-            resources_to_be_enumerated = tuple(self.__pending_enumeration - enumerated_resources)
+            resources_to_be_enumerated = tuple(
+                self.__pending_enumeration - enumerated_resources
+            )
 
         if return_json:
             if include_dead_resources:
-                return json.dumps(self.__result, sort_keys=True,
-                                  indent=4, separators=(',', ': ')), dead_resources
+                return (
+                    json.dumps(
+                        self.__result,
+                        sort_keys=True,
+                        indent=4,
+                        separators=(",", ": "),
+                    ),
+                    dead_resources,
+                )
             else:
-                return json.dumps(self.__result, sort_keys=True,
-                                  indent=4, separators=(',', ': '))
+                return json.dumps(
+                    self.__result,
+                    sort_keys=True,
+                    indent=4,
+                    separators=(",", ": "),
+                )
         else:
             if include_dead_resources:
                 return self.__result, dead_resources
             else:
                 return self.__result
 
-    def walk_nested_dict(self, data, url=''):
+    def walk_nested_dict(self, data, url=""):
         r"""
         Parse through the nested dictionary and get the resource id paths.
 
@@ -263,21 +290,22 @@
         data                        Nested dictionary data from response message.
         url                         Resource for which the response is obtained in data.
         """
-        url = url.rstrip('/')
+        url = url.rstrip("/")
 
         for key, value in data.items():
-
             # Recursion if nested dictionary found.
             if isinstance(value, dict):
                 self.walk_nested_dict(value)
             else:
                 # Value contains a list of dictionaries having member data.
-                if 'Members' == key:
+                if "Members" == key:
                     if isinstance(value, list):
                         for memberDict in value:
-                            self.__pending_enumeration.add(memberDict['@odata.id'])
-                if '@odata.id' == key:
-                    value = value.rstrip('/')
+                            self.__pending_enumeration.add(
+                                memberDict["@odata.id"]
+                            )
+                if "@odata.id" == key:
+                    value = value.rstrip("/")
                     # Data for the given url.
                     if value == url:
                         self.__result[url] = data
@@ -323,7 +351,9 @@
         """
 
         member_list = []
-        self._rest_response_ = self.get(resource_path, valid_status_codes=[200])
+        self._rest_response_ = self.get(
+            resource_path, valid_status_codes=[200]
+        )
 
         try:
             for member in self._rest_response_.dict["Members"]:
@@ -334,7 +364,7 @@
 
         # Filter elements in the list and return matched elements.
         if filter is not None:
-            regex = '.*/' + filter + '[^/]*$'
+            regex = ".*/" + filter + "[^/]*$"
             return [x for x in member_list if re.match(regex, x)]
 
         return member_list