Skip to content
Snippets Groups Projects
Commit 24b7b8a4 authored by Antoine Millet's avatar Antoine Millet
Browse files

Whitespaces. (tabs -> spaces)

parent d1c7d914
No related branches found
No related tags found
No related merge requests found
......@@ -4,38 +4,38 @@
from sjrpc.core.exceptions import RpcError
class ConnectionProxy(object):
'''
'''
Create a new call proxy for the connection passed in arguments.
Usage example:
>>> proxy = ConnectionProxy(conn)
>>> ret = proxy.existing_function()
If exception is raised by the function, the proxy tries to get the
exception class in *__builtins__* to re-raise it. If exception class
is not found in *__builtins__*, the exception raised is the
original :exc:`RpcError`:
>>> proxy.unknown_function()
[Traceback]
NameError: remote name 'unknown_function' is not defined
'''
def __init__(self, connection):
self._connection = connection
def __getattr__(self, name):
def func(*args, **kwargs):
try:
returned = self._connection.call(name, *args, **kwargs)
except RpcError as err:
expt = __builtins__.get(err.exception)
if expt is not None:
raise expt(err.message)
else:
raise err
else:
return returned
return func
>>> proxy.unknown_function()
[Traceback]
NameError: remote name 'unknown_function' is not defined
'''
def __init__(self, connection):
self._connection = connection
def __getattr__(self, name):
def func(*args, **kwargs):
try:
returned = self._connection.call(name, *args, **kwargs)
except RpcError as err:
expt = __builtins__.get(err.exception)
if expt is not None:
raise expt(err.message)
else:
raise err
else:
return returned
return func
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment