import six
import re


def listsearch(query, item):
    """Return match with query on an item from the list of input/output files

    The lists of input and output files can consist either of file names
    (strings), or lists containing the filename and the hash of the file (if
    hashing is enabled). This function provides a transparent interface to
    these two options.

    Parameters:
        query : str
            The search query
        item : str or list containing two strings
            A file name or a list containing a file name and hash

    Returns:
        boolean
    """
    fh = ''
    if not isinstance(item, six.string_types):
        fh = item[1]
        item = item[0]

    return bool(re.search(query, item) or
                re.search(query, fh))