# Path: errors.py
# class UnauthorizedAPIAccessError(YodaError):
#     pass


import json
from traceback import print_exc
from flask import Blueprint, g, jsonify, request
from irods import rule
from errors import UnauthorizedAPIAccessError
                '''.format(arg_str_expr, fn)

    x = rule.Rule(
        g.irods,
        instance_name='irods_rule_engine_plugin-irods_rule_language-instance',
        body=rule_body,
        params={},
        output='ruleExecOut')

    x = x.execute(session_cleanup=False)
    x = bytesbuf_to_str(x._values['MsParam_PI'][0]._values['inOutStruct']._values['stdoutBuf'])

    result = x.decode()

    return json.loads(result)


def authenticated():
    return g.get('user') is not None and g.get('irods') is not None


@api_bp.errorhandler(Exception)
def api_error_handler(error):
    print_exc()
    print('API Error: {}'.format(error))
    status = "internal_error"
    status_info = "Something went wrong"
    data = {}
    code = 500


# Path: errors.py
# class UnauthorizedAPIAccessError(YodaError):
#     pass


# Path: api.py
import json
from traceback import print_exc
from flask import Blueprint, g, jsonify, request
from irods import rule
from errors import UnauthorizedAPIAccessError

                '''.format(arg_str_expr, fn)

    x = rule.Rule(
        g.irods,
        instance_name='irods_rule_engine_plugin-irods_rule_language-instance',
        body=rule_body,
        params={},
        output='ruleExecOut')

    x = x.execute(session_cleanup=False)
    x = bytesbuf_to_str(x._values['MsParam_PI'][0]._values['inOutStruct']._values['stdoutBuf'])

    result = x.decode()

    return json.loads(result)


def authenticated():
    return g.get('user') is not None and g.get('irods') is not None


@api_bp.errorhandler(Exception)
def api_error_handler(error):
    print_exc()
    print('API Error: {}'.format(error))
    status = "internal_error"
    status_info = "Something went wrong"
    data = {}
    code = 500


    if type(error) == UnauthorizedAPIAccessError: