def get_datapackage_resource(resource_path, datapkg):
    """Return the resource correspondent to `resource_path` from datapackage or raise"""

    matching_resources = [res for res in datapkg.resources
                          if res.local_data_path == resource_path]
    if len(matching_resources) > 1:
        raise ValueError(('The resource with path "{0}" appears multiple times '
                          'in your datapackage.').format(resource_path))
    elif not matching_resources:
        raise ValueError(('The resource with path "{0}" can\'t be found in '
                          'your datapackage. Please include it or '
                          'use the "dq init" command.').format(resource_path))
    else:
        return matching_resources[0]