# Path: modernrpc/core.py
# def rpc_method(
#     func=None,
#     name: str = None,
#     entry_point: str = ALL,
#     protocol: Protocol = Protocol.ALL,
# ):
#     """
#     Mark a standard python function as RPC method.
# 
#     All arguments are optional
# 
#     :param func: A standard function
#     :param name: Used as RPC method name instead of original function name
#     :param entry_point: Default: ALL. Used to limit usage of the RPC method for a specific set of entry points
#     :param protocol: Default: ALL. Used to limit usage of the RPC method for a specific protocol (JSONRPC or XMLRPC)
#     """
# 
#     def decorated(_func):
#         _func.modernrpc_enabled = True
#         _func.modernrpc_name = name or _func.__name__
#         _func.modernrpc_entry_point = entry_point
#         _func.modernrpc_protocol = protocol
# 
#         return _func
# 
#     # If @rpc_method() is used with parenthesis (with or without argument)
#     if func is None:
#         return decorated
# 
#     # If @rpc_method is used without parenthesis
#     return decorated(func)
# 
# PROTOCOL_KEY = settings.MODERNRPC_KWARGS_PROTOCOL_KEY
# 
# Path: modernrpc/exceptions.py
# class RPCException(Exception):
#     """
#     This is the base class of all RPC exception. Custom exceptions raised by your RPC methods
#     should inherits from RPCException.
#     """
# 
#     def __init__(self, code: int, message: str, data: Any = None):
#         super().__init__("[{}] {}".format(code, message))
#         self.code = code
#         self.message = message
#         self.data = data
# 
# RPC_CUSTOM_ERROR_BASE = -32099
# 
# Path: modernrpc/helpers.py
# def get_builtin_date(
#     date: Union[str, datetime.datetime, xmlrpc_client.DateTime],
#     date_format: str = "%Y-%m-%dT%H:%M:%S",
#     raise_exception: bool = False,
# ) -> Optional[datetime.datetime]:
#     """
#     Try to convert a date to a builtin instance of ``datetime.datetime``.
#     The input date can be a ``str``, a ``datetime.datetime``, a ``xmlrpc.client.Datetime`` or a ``xmlrpclib.Datetime``
#     instance. The returned object is a ``datetime.datetime``.
# 
#     :param date: The date object to convert.
#     :param date_format: If the given date is a str, format is passed to strptime to parse it
#     :param raise_exception: If set to True, an exception will be raised if the input string cannot be parsed
#     :return: A valid ``datetime.datetime`` instance
#     """
#     if isinstance(date, datetime.datetime):
#         # Default XML-RPC handler is configured to decode dateTime.iso8601 type
#         # to builtin datetime.datetim instance
#         return date
#     if isinstance(date, xmlrpc_client.DateTime):
#         # If constant settings.MODERNRPC_XMLRPC_USE_BUILTIN_TYPES has been set to True
#         # the date is decoded as DateTime object
#         return datetime.datetime.strptime(date.value, "%Y%m%dT%H:%M:%S")
# 
#     # If date is given as str. This is the normal behavior for JSON-RPC
#     try:
#         return datetime.datetime.strptime(date, date_format)
#     except ValueError:
#         if raise_exception:
#             raise
#         return None


import datetime
from modernrpc.core import rpc_method, PROTOCOL_KEY
from modernrpc.exceptions import RPCException, RPC_CUSTOM_ERROR_BASE
from modernrpc.helpers import get_builtin_date
    from django.http.response import HttpResponse
    :type denominator: int or double
    :type x: str
    :type y: bytes
    :type z: list
    :type a: float
    :type b: int
    :type c: int
    :return:
    :rtype: int or double
    """
    return numerator / denominator


@rpc_method(name="customized_name")
def another_name():
    """This one will help to test method registration
    when name has been customized"""
    pass


class MyCustomException(RPCException):
    def __init__(self):
        super().__init__(RPC_CUSTOM_ERROR_BASE + 5, "This is a test error")


@rpc_method
def raise_custom_exception():
    raise MyCustomException()



# Path: modernrpc/core.py
# def rpc_method(
#     func=None,
#     name: str = None,
#     entry_point: str = ALL,
#     protocol: Protocol = Protocol.ALL,
# ):
#     """
#     Mark a standard python function as RPC method.
# 
#     All arguments are optional
# 
#     :param func: A standard function
#     :param name: Used as RPC method name instead of original function name
#     :param entry_point: Default: ALL. Used to limit usage of the RPC method for a specific set of entry points
#     :param protocol: Default: ALL. Used to limit usage of the RPC method for a specific protocol (JSONRPC or XMLRPC)
#     """
# 
#     def decorated(_func):
#         _func.modernrpc_enabled = True
#         _func.modernrpc_name = name or _func.__name__
#         _func.modernrpc_entry_point = entry_point
#         _func.modernrpc_protocol = protocol
# 
#         return _func
# 
#     # If @rpc_method() is used with parenthesis (with or without argument)
#     if func is None:
#         return decorated
# 
#     # If @rpc_method is used without parenthesis
#     return decorated(func)
# 
# PROTOCOL_KEY = settings.MODERNRPC_KWARGS_PROTOCOL_KEY
# 
# Path: modernrpc/exceptions.py
# class RPCException(Exception):
#     """
#     This is the base class of all RPC exception. Custom exceptions raised by your RPC methods
#     should inherits from RPCException.
#     """
# 
#     def __init__(self, code: int, message: str, data: Any = None):
#         super().__init__("[{}] {}".format(code, message))
#         self.code = code
#         self.message = message
#         self.data = data
# 
# RPC_CUSTOM_ERROR_BASE = -32099
# 
# Path: modernrpc/helpers.py
# def get_builtin_date(
#     date: Union[str, datetime.datetime, xmlrpc_client.DateTime],
#     date_format: str = "%Y-%m-%dT%H:%M:%S",
#     raise_exception: bool = False,
# ) -> Optional[datetime.datetime]:
#     """
#     Try to convert a date to a builtin instance of ``datetime.datetime``.
#     The input date can be a ``str``, a ``datetime.datetime``, a ``xmlrpc.client.Datetime`` or a ``xmlrpclib.Datetime``
#     instance. The returned object is a ``datetime.datetime``.
# 
#     :param date: The date object to convert.
#     :param date_format: If the given date is a str, format is passed to strptime to parse it
#     :param raise_exception: If set to True, an exception will be raised if the input string cannot be parsed
#     :return: A valid ``datetime.datetime`` instance
#     """
#     if isinstance(date, datetime.datetime):
#         # Default XML-RPC handler is configured to decode dateTime.iso8601 type
#         # to builtin datetime.datetim instance
#         return date
#     if isinstance(date, xmlrpc_client.DateTime):
#         # If constant settings.MODERNRPC_XMLRPC_USE_BUILTIN_TYPES has been set to True
#         # the date is decoded as DateTime object
#         return datetime.datetime.strptime(date.value, "%Y%m%dT%H:%M:%S")
# 
#     # If date is given as str. This is the normal behavior for JSON-RPC
#     try:
#         return datetime.datetime.strptime(date, date_format)
#     except ValueError:
#         if raise_exception:
#             raise
#         return None


# Path: tests/testsite/rpc_methods_stub/generic.py
import datetime
from modernrpc.core import rpc_method, PROTOCOL_KEY
from modernrpc.exceptions import RPCException, RPC_CUSTOM_ERROR_BASE
from modernrpc.helpers import get_builtin_date
    from django.http.response import HttpResponse

    :type denominator: int or double
    :type x: str
    :type y: bytes
    :type z: list
    :type a: float
    :type b: int
    :type c: int
    :return:
    :rtype: int or double
    """
    return numerator / denominator


@rpc_method(name="customized_name")
def another_name():
    """This one will help to test method registration
    when name has been customized"""
    pass


class MyCustomException(RPCException):
    def __init__(self):
        super().__init__(RPC_CUSTOM_ERROR_BASE + 5, "This is a test error")


@rpc_method
def raise_custom_exception():
    raise MyCustomException()



class MyCustomExceptionWithData(RPCException):