1- """Logic to spot and create ActionErrorExceptions"""
1+ """Logic to spot and create ActionErrorExceptions. """
22
33from sagemcom_api .const import (
44 XMO_ACCESS_RESTRICTION_ERR ,
55 XMO_AUTHENTICATION_ERR ,
66 XMO_LOGIN_RETRY_ERR ,
77 XMO_MAX_SESSION_COUNT_ERR ,
8- XMO_NON_WRITABLE_PARAMETER_ERR ,
98 XMO_NO_ERR ,
9+ XMO_NON_WRITABLE_PARAMETER_ERR ,
1010 XMO_REQUEST_ACTION_ERR ,
11- XMO_UNKNOWN_PATH_ERR
11+ XMO_UNKNOWN_PATH_ERR ,
1212)
1313from sagemcom_api .exceptions import (
1414 AccessRestrictionException ,
1717 MaximumSessionCountException ,
1818 NonWritableParameterException ,
1919 UnknownException ,
20- UnknownPathException
20+ UnknownPathException ,
2121)
2222
2323
2424class ActionErrorHandler :
25- """Raised when a requested action has an error"""
25+ """Raised when a requested action has an error. """
2626
2727 KNOWN_EXCEPTIONS = (
2828 XMO_AUTHENTICATION_ERR ,
2929 XMO_ACCESS_RESTRICTION_ERR ,
3030 XMO_NON_WRITABLE_PARAMETER_ERR ,
3131 XMO_UNKNOWN_PATH_ERR ,
3232 XMO_MAX_SESSION_COUNT_ERR ,
33- XMO_LOGIN_RETRY_ERR
33+ XMO_LOGIN_RETRY_ERR ,
3434 )
3535
3636 @staticmethod
3737 def throw_if (response ):
38- """For anywhere that needs the old single-exception behaviour"""
39-
38+ """For anywhere that needs the old single-exception behaviour."""
4039 if response ["reply" ]["error" ]["description" ] != XMO_REQUEST_ACTION_ERR :
4140 return
4241
4342 actions = response ["reply" ]["actions" ]
4443 for action in actions :
45-
4644 action_error = action ["error" ]
4745 action_error_desc = action_error ["description" ]
4846
@@ -53,17 +51,12 @@ def throw_if(response):
5351
5452 @staticmethod
5553 def is_unknown_exception (desc ):
56- """
57- True/false if the ActionError is one of our known types
58- """
59-
54+ """True/false if the ActionError is one of our known types."""
6055 return False if desc == XMO_NO_ERR else desc not in ActionErrorHandler .KNOWN_EXCEPTIONS
6156
6257 @staticmethod
6358 def from_error_description (action_error , action_error_desc ):
64- """
65- Create the correct exception from an error, for the caller to throw
66- """
59+ """Create the correct exception from an error, for the caller to throw."""
6760 # pylint: disable=too-many-return-statements
6861
6962 if action_error_desc == XMO_AUTHENTICATION_ERR :
0 commit comments