[entropy.const] introduce const_dir_readable()

This commit is contained in:
Fabio Erculiani
2013-09-08 19:45:14 +02:00
parent 4cc4908a11
commit 58d68118d4
+16
View File
@@ -1114,6 +1114,22 @@ def const_file_readable(path):
except (OSError, IOError):
return False
def const_dir_readable(dir_path):
"""
Return whether path points to a readable directory.
Readable directory is one that you can read the content.
@param path: path to a directory
@type path: string
@return: True, if directory exists and is readable
@rtype: bool
"""
try:
os.listdir(dir_path)
return True
except (OSError, IOError):
return False
def const_get_entropy_gid():
"""
This function tries to retrieve the "entropy" user group