def readFile(file, defStr = None, mode = "r"):
    """ read a file and return its contents """
    ret = defStr
    try:
        with open(file, mode) as f:
            ret = f.read()
    except Exception as e:
        if defStr is not None:
            ret = defStr
            pass
        else:
            raise e
    return ret