From 66707b642692514a002393db9b547690041d0c44 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sun, 19 Jan 2003 17:41:57 +0000 Subject: Check if a directory is empty before adding it to the path. Also added a * pygtk.py (_get_available_versions): Check if a directory is empty before adding it to the path. Also added a few comments. Fixes #103876 (Ross Burton). --- pygtk.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pygtk.py b/pygtk.py index 8f3dcd5..4ef6eec 100644 --- a/pygtk.py +++ b/pygtk.py @@ -35,16 +35,24 @@ def _get_available_versions(): for dir in sys.path: if not dir: dir = os.getcwd() + if not os.path.isdir(dir): continue + # if the dir is a pygtk dir, skip it if fnmatch.fnmatchcase(os.path.basename(dir), _pygtk_dir_pat): - continue # if the dir is a pygtk dir, skip it + continue for filename in glob.glob(os.path.join(dir, _pygtk_dir_pat)): pathname = os.path.join(dir, filename) + + # skip non directories if not os.path.isdir(pathname): - continue # skip non directories + continue + + # skip empty directories + if not os.listdir(pathname): + continue if not versions.has_key(filename[-3:]): versions[filename[-3:]] = pathname -- cgit