Provider an is_readable path validator.

This commit is contained in:
Pedro Algarvio 2014-04-10 00:03:01 +01:00
parent f009dabd8d
commit eb70e227e3

View File

@ -49,3 +49,19 @@ def is_writeable(path, check_parent=False):
# Finally, return if we're allowed to write in the parent directory of the
# provided path
return os.access(parent_dir, os.W_OK)
def is_readable(path):
'''
Check if a given path is readable by the current user.
:param path: The path to check
:returns: True or False
'''
if os.access(path, os.F_OK) and os.access(path, os.R_OK):
# The path exists and is readable
return True
# The path does not exist
return False