Skip to content

Commit

Permalink
Update neovi_bus.py
Browse files Browse the repository at this point in the history
Improving docstring
  • Loading branch information
pierreluctg committed Apr 16, 2024
1 parent f45d53f commit fd2eb24
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions can/interfaces/ics_neovi/neovi_bus.py
Expand Up @@ -130,11 +130,18 @@ class ICSOperationError(ICSApiError, CanOperationError):


def check_if_bus_open(func):
"""Decorator that raises :exc:`~can.exceptions.CanOperationError` if the bus is not open."""
"""
Decorator that checks if the bus is open before executing the function.
If the bus is not open, it raises a CanOperationError.
"""
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
"""Raises :exc:`~can.exceptions.CanOperationError` if the bus is not open, else calls the wrapped function."""
"""
Wrapper function that checks if the bus is open before executing the function.
:raises CanOperationError: If the bus is not open.
"""
if self._is_shutdown:
raise CanOperationError("Cannot operate on a closed bus")
return func(self, *args, **kwargs)
Expand Down

0 comments on commit fd2eb24

Please sign in to comment.