Look at given filenames, decide which is what and try to pair them.

def _process_pair(first_fn, second_fn, error_protocol):
    """
    Look at given filenames, decide which is what and try to pair them.
    """
    ebook = None
    metadata = None

    if _is_meta(first_fn) and not _is_meta(second_fn):    # 1st meta, 2nd data
        logger.debug(
            "Parsed: '%s' as meta, '%s' as data." % (first_fn, second_fn)
        )
        metadata, ebook = first_fn, second_fn
    elif not _is_meta(first_fn) and _is_meta(second_fn):  # 1st data, 2nd meta
        logger.debug(
            "Parsed: '%s' as meta, '%s' as data." % (second_fn, first_fn)
        )
        metadata, ebook = second_fn, first_fn
    elif _is_meta(first_fn) and _is_meta(second_fn):      # both metadata
        logger.debug(
            "Parsed: both '%s' and '%s' as meta." % (first_fn, second_fn)
        )
        return [
            _safe_read_meta_file(first_fn, error_protocol),
            _safe_read_meta_file(second_fn, error_protocol)
        ]
    else:                                                 # both data
        logger.debug(
            "Parsed: both '%s' and '%s' as data." % (first_fn, second_fn)
        )
        return [
            EbookFile(first_fn),
            EbookFile(second_fn)
        ]

    # process pairs, which were created in first two branches of the if
    # statement above
    pair = DataPair(
        metadata_file=_safe_read_meta_file(metadata, error_protocol),
        ebook_file=EbookFile(ebook)
    )
    if not pair.metadata_file:
        logger.error(
            "Can't parse MetadataFile '%s'. Continuing with data file '%s'." % (
                metadata, ebook
            )
        )
        return [pair.ebook_file]

    return [pair]