def read_batchfile(pythonpath, file_ending='.py'):
    """
    This reads the contents of a batch-file.  Filename is considered
    to be a python path to a batch file relative the directory
    specified in `settings.py`.

    file_ending specify which batchfile ending should be assumed (.ev
    or .py). The ending should not be included in the python path.

    Args:
        pythonpath (str): A dot-python path to a file.
        file_ending (str): The file ending of this file (.ev or .py)

    Returns:
        text (str): The text content of the batch file.

    Raises:
        IOError: If problems reading file.

    """

    # open the file
    abspaths = []
    for basepath in settings.BASE_BATCHPROCESS_PATHS:
        # note that pypath_to_realpath has already checked the file for existence
        if basepath.startswith("evennia"):
            basepath = basepath.split("evennia", 1)[-1]
        abspaths.extend(utils.pypath_to_realpath("%s.%s" % (basepath, pythonpath), file_ending))
    if not abspaths:
        raise IOError
    text = None
    decoderr = []
    for abspath in abspaths:
        # try different paths, until we get a match
        # we read the file directly into unicode.
        for file_encoding in ENCODINGS:
            # try different encodings, in order
            try:
                with codecs.open(abspath, 'r', encoding=file_encoding) as fobj:
                    text = fobj.read()
            except (__HOLE__, UnicodeDecodeError) as e:
                # this means an encoding error; try another encoding
                decoderr.append(str(e))
                continue
            break
    if not text and decoderr:
        raise UnicodeDecodeError("\n".join(decoderr))

    return text


#------------------------------------------------------------
#
# Batch-command processor
#
#------------------------------------------------------------
dataset/ETHPy150Open evennia/evennia/evennia/utils/batchprocessors.py/read_batchfile