@staticmethod
def __check_file(directory, fname, read=True, write=False):
    """
        Verifies that a file exists in the specified directory and has the requested permissions.

        :param directory: directory to look in for the file.
        :type directory: str.
        :param fname: file name to check.
        :type fname: str.
        :param read: check to see if file is readable (default: True).
        :type read: bool.
        :param write: check to see if the file is writable (default: False).
        :type write: bool.
        :return: True if file exists with expected permissions, else False.
        :rtype: bool.
        """
    __full_name = directory + '/' + fname
    if read and write:
        __mode = 'r+'
    elif read:
        __mode = 'r'
    elif write:
        __mode = 'w'
    else:
        return False
    try:
        __fp = open(__full_name, mode=__mode)
        __fp.close()
    except IOError:
        return False
    return True
