# Path: crabpy/client.py
# def crab_request(client, action, *args):
#     """
#     Utility function that helps making requests to the CRAB service.
# 
#     :param client: A :class:`suds.client.Client` for the CRAB service.
#     :param string action: Which method to call, eg. `ListGewesten`
#     :returns: Result of the SOAP call.
# 
#     .. versionadded:: 0.3.0
#     """
#     log.debug("Calling %s on CRAB service.", action)
#     return getattr(client.service, action)(*args)
# 
# Path: crabpy/gateway/exception.py
# class GatewayResourceNotFoundException(GatewayException):
#     """
#     An exception that signifies that no results where found.
#     """
#     def __init__(self):
#         GatewayException.__init__(self, 'This resource was not found.')
# 
# Path: crabpy/gateway/exception.py
# class GatewayRuntimeException(GatewayException):
#     """
#     An exception that signifies a soap request went wrong.
# 
#     """
# 
#     soapfault = None
#     """
#     The soapfault that was generated by the service.
#     """
# 
#     def __init__(self, message, soapfault):
#         GatewayException.__init__(self, message)
#         self.soapfault = soapfault


import json
import logging
import math
import os
from dogpile.cache import make_region
from suds import WebFault
from crabpy.client import crab_request
from crabpy.gateway.exception import GatewayResourceNotFoundException
from crabpy.gateway.exception import GatewayRuntimeException

.. versionadded:: 0.3.0
"""




log = logging.getLogger(__name__)
parent_dir = os.path.dirname(__file__)
data_dir = os.path.join(os.path.dirname(__file__), '..', 'data')
deelgemeenten_json = json.load(
    open(os.path.join(data_dir, "deelgemeenten.json"),
    encoding='utf-8')
)


def crab_gateway_request(client, method, *args):
    """
    Utility function that helps making requests to the CRAB service.

    This is a specialised version of :func:`crabpy.client.crab_request` that
    allows adding extra functionality for the calls made by the gateway.

    :param client: A :class:`suds.client.Client` for the CRAB service.
    :param string action: Which method to call, eg. `ListGewesten`
    :returns: Result of the SOAP call.
    """
    try:
        return crab_request(client, method, *args)
    except WebFault as wf:

# Path: crabpy/client.py
# def crab_request(client, action, *args):
#     """
#     Utility function that helps making requests to the CRAB service.
# 
#     :param client: A :class:`suds.client.Client` for the CRAB service.
#     :param string action: Which method to call, eg. `ListGewesten`
#     :returns: Result of the SOAP call.
# 
#     .. versionadded:: 0.3.0
#     """
#     log.debug("Calling %s on CRAB service.", action)
#     return getattr(client.service, action)(*args)
# 
# Path: crabpy/gateway/exception.py
# class GatewayResourceNotFoundException(GatewayException):
#     """
#     An exception that signifies that no results where found.
#     """
#     def __init__(self):
#         GatewayException.__init__(self, 'This resource was not found.')
# 
# Path: crabpy/gateway/exception.py
# class GatewayRuntimeException(GatewayException):
#     """
#     An exception that signifies a soap request went wrong.
# 
#     """
# 
#     soapfault = None
#     """
#     The soapfault that was generated by the service.
#     """
# 
#     def __init__(self, message, soapfault):
#         GatewayException.__init__(self, message)
#         self.soapfault = soapfault


# Path: crabpy/gateway/crab.py
import json
import logging
import math
import os
from dogpile.cache import make_region
from suds import WebFault
from crabpy.client import crab_request
from crabpy.gateway.exception import GatewayResourceNotFoundException
from crabpy.gateway.exception import GatewayRuntimeException


.. versionadded:: 0.3.0
"""




log = logging.getLogger(__name__)
parent_dir = os.path.dirname(__file__)
data_dir = os.path.join(os.path.dirname(__file__), '..', 'data')
deelgemeenten_json = json.load(
    open(os.path.join(data_dir, "deelgemeenten.json"),
    encoding='utf-8')
)


def crab_gateway_request(client, method, *args):
    """
    Utility function that helps making requests to the CRAB service.

    This is a specialised version of :func:`crabpy.client.crab_request` that
    allows adding extra functionality for the calls made by the gateway.

    :param client: A :class:`suds.client.Client` for the CRAB service.
    :param string action: Which method to call, eg. `ListGewesten`
    :returns: Result of the SOAP call.
    """
    try:
        return crab_request(client, method, *args)
    except WebFault as wf:

        err = GatewayRuntimeException(