def parse_prior_params(bt_config, code_config, key, default, prior='pre'):
    """
    Parse parameters with priority.

    Args:
        bt_config(dict): bt config
        code_config(dict): code config
        key(string): parameter name
        default(default): default value
        prior(string): use bt_config in prior if 'pre' otherwise code_config

    Returns:
        value
    """
    if prior == 'pre':
        return bt_config.get(key, code_config.get(key, default))
    else:
        return code_config.get(key, bt_config.get(key, default))