# Path: falsy/loader/func.py
# def load(function_name):
#     if not function_name:
#         return None
# 
#     if function_name in func_map.keys():
#         return func_map[function_name]
# 
#     module_name, attr_path = function_name.rsplit('.', 1)
#     module = None
#     last_import_error = None
# 
#     while not module:
# 
#         try:
#             module = importlib.import_module(module_name)
#         except ImportError as import_error:
#             last_import_error = import_error
#             if '.' in module_name:
#                 module_name, attr_path1 = module_name.rsplit('.', 1)
#                 attr_path = '{0}.{1}'.format(attr_path1, attr_path)
#             else:
#                 raise
#     try:
#         function = deep_getattr(module, attr_path)
#     except AttributeError:
#         if last_import_error:
#             raise last_import_error
#         else:
#             raise
#     func_map[str(function_name)] = function
#     return function


import pprint
import falcon
import json
import logging
from falcon.routing import compile_uri_template
from falsy.loader.func import load
            self.load_methods(method, method_content, path, swagger_spec)

    def load_methods(self, method, method_content, path, swagger_spec):
        uri_fields, uri_regex = compile_uri_template(
            '/' + method.lower() + swagger_spec['basePath'] + path)
        self.specs[uri_regex] = {'uri_fields': uri_fields}
        for attribute, attribute_content in method_content.items():
            if attribute in ['beforeId', 'afterId', 'operationId', 'validationId', 'exceptionId', 'finalId']:
                attribute_content = self.load_handler(attribute_content)
            self.load_attributes(attribute, attribute_content, swagger_spec, uri_regex)
            self.specs[uri_regex]['path'] = path

    def load_attributes(self, attribute, attribute_content, swagger_spec, uri_regex):
        self.specs[uri_regex][attribute] = attribute_content
        if attribute == 'parameters':
            for i, param in enumerate(attribute_content):
                if param.get('in') == 'body':
                    schema = param.get('schema')
                    ref = schema.get('$ref')
                    if ref:
                        self.specs[uri_regex]['schema'] = swagger_spec['definitions'][
                            ref[ref.rfind('/') + 1:]]
                    else:
                        self.specs[uri_regex]['schema'] = schema

                self.specs[uri_regex][attribute][i]['validationId'] = self.load_handler(param.get('validationId'))

    def load_handler(self, name):
        if name is None:
            return None

# Path: falsy/loader/func.py
# def load(function_name):
#     if not function_name:
#         return None
# 
#     if function_name in func_map.keys():
#         return func_map[function_name]
# 
#     module_name, attr_path = function_name.rsplit('.', 1)
#     module = None
#     last_import_error = None
# 
#     while not module:
# 
#         try:
#             module = importlib.import_module(module_name)
#         except ImportError as import_error:
#             last_import_error = import_error
#             if '.' in module_name:
#                 module_name, attr_path1 = module_name.rsplit('.', 1)
#                 attr_path = '{0}.{1}'.format(attr_path1, attr_path)
#             else:
#                 raise
#     try:
#         function = deep_getattr(module, attr_path)
#     except AttributeError:
#         if last_import_error:
#             raise last_import_error
#         else:
#             raise
#     func_map[str(function_name)] = function
#     return function


# Path: falsy/swagger_proxy/spec_loader.py
import pprint
import falcon
import json
import logging
from falcon.routing import compile_uri_template
from falsy.loader.func import load

            self.load_methods(method, method_content, path, swagger_spec)

    def load_methods(self, method, method_content, path, swagger_spec):
        uri_fields, uri_regex = compile_uri_template(
            '/' + method.lower() + swagger_spec['basePath'] + path)
        self.specs[uri_regex] = {'uri_fields': uri_fields}
        for attribute, attribute_content in method_content.items():
            if attribute in ['beforeId', 'afterId', 'operationId', 'validationId', 'exceptionId', 'finalId']:
                attribute_content = self.load_handler(attribute_content)
            self.load_attributes(attribute, attribute_content, swagger_spec, uri_regex)
            self.specs[uri_regex]['path'] = path

    def load_attributes(self, attribute, attribute_content, swagger_spec, uri_regex):
        self.specs[uri_regex][attribute] = attribute_content
        if attribute == 'parameters':
            for i, param in enumerate(attribute_content):
                if param.get('in') == 'body':
                    schema = param.get('schema')
                    ref = schema.get('$ref')
                    if ref:
                        self.specs[uri_regex]['schema'] = swagger_spec['definitions'][
                            ref[ref.rfind('/') + 1:]]
                    else:
                        self.specs[uri_regex]['schema'] = schema

                self.specs[uri_regex][attribute][i]['validationId'] = self.load_handler(param.get('validationId'))

    def load_handler(self, name):
        if name is None:
            return None

        return load(name)