summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Dahlin <zilch@src.gnome.org>2003-01-19 17:41:57 +0000
committerJohan Dahlin <zilch@src.gnome.org>2003-01-19 17:41:57 +0000
commit66707b642692514a002393db9b547690041d0c44 (patch)
tree3b5057e008e94c7613b857fa2fb3a949534f9be3
parente4fe93cd953c57976ed28363df2fdf1526881e5d (diff)
downloadpygobject-66707b642692514a002393db9b547690041d0c44.tar.gz
pygobject-66707b642692514a002393db9b547690041d0c44.tar.xz
pygobject-66707b642692514a002393db9b547690041d0c44.zip
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).
-rw-r--r--pygtk.py12
1 files 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