From 58d68118d4b385b65cc286cb49b42e01d7b898bd Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 8 Sep 2013 19:45:14 +0200 Subject: [PATCH] [entropy.const] introduce const_dir_readable() --- lib/entropy/const.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/entropy/const.py b/lib/entropy/const.py index 9d3f36f9a..690b81ddc 100644 --- a/lib/entropy/const.py +++ b/lib/entropy/const.py @@ -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