@@ -0,0 +1,1902 @@
+%22%22%22Various functions to help deal with exceptions.%0AReleased under the MIT license (https://opensource.org/licenses/MIT).%0A%22%22%22%0A%0A%0Adef raises(callable, args=(), kwargs=%7B%7D):%0A    %22%22%22Check if %60callable(*args, **kwargs)%60 raises an exception.%0A    Returns %60True%60 if an exception is raised, else %60False%60.%0A%0A    Arguments:%0A    - callable: A callable object.%0A    - args: A list or tuple containing positional arguments to %60callable%60.%0A      Defaults to an empty tuple.%0A    - kwargs: A dictionary containing keyword arguments to %60callable%60.%0A      Defaults to an empty dictionary.%0A    %22%22%22%0A    try:%0A        callable(*args, **kwargs)%0A    except Exception as exc:%0A        return True%0A    return False%0A%0A%0Adef suppress(*exceptions):%0A    %22%22%22Suppress %60exceptions%60 when calling a function.%0A    If an exception is raised and it is not contained in %60exceptions%60,%0A    it is propagated back to the caller without context. If no exceptions%0A    are raised, return %60callable(*args, **kwargs)%60.%0A%0A    Arguments:%0A    - *exceptions: The exceptions to suppress.%0A      All exceptions must derive from %60BaseException%60.%0A    - callable: A callable object.%0A    - *args: Positional arguments to %60callable%60.%0A    - **kwargs: Keyword arguments to %60callable%60.%0A    %22%22%22%0A    def wrap(callable):%0A        def call(*args, **kwargs):%0A            try:%0A                return callable(*args, **kwargs)%0A            except exceptions:%0A                pass%0A            except Exception as exc:%0A                raise_from_context(exc)%0A        return call%0A    return wrap%0A%0A%0Adef raise_from_context(exception, context=None):%0A    %22%22%22Raise %60exception%60 from %60context%60.%0A    This function is compatible with Python 2 as it sets %60__context__%60.%0A%0A    Arguments:%0A    - exception: An exception (derived from %60BaseException%60).%0A    - context: The context from which to raise %60exception%60.%0A      Defaults to %60None%60.%0A    %22%22%22%0A    exception.__context__ = context%0A    raise exception%0A

Create main file