#
# Kiwi: a Framework and Enhanced Widgets for Python
#
# Copyright (C) 2003-2005 Async Open Source
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
# USA
# 
# Author(s): Christian Reis <kiko@async.com.br>
#            Lorenzo Gil Sanchez <lgs@sicem.biz>
#            Johan Dahlin <jdahlin@async.com.br>
#         

import os
import string

#
# Gladepath handling
#

gladepath = []

if os.environ.has_key('KIWI_GLADE_PATH'):
    gladepath = os.environ['KIWI_GLADE_PATH'].split(':')

def set_gladepath(path):
    """Sets a new path to be used to search for glade files when creating
    GladeViews or it's subclasses
    """
    global gladepath
    gladepath = path

def get_gladepath():
    global gladepath
    return gladepath

def find_in_gladepath(filename):
    """Looks in gladepath for the file specified"""

    gladepath = get_gladepath()
    
    # check to see if gladepath is a list or tuple
    if not isinstance(gladepath, (tuple, list)):
        msg ="gladepath should be a list or tuple, found %s"
        raise ValueError(msg % type(gladepath))
    if os.sep in filename or not gladepath:
        if os.path.isfile(filename):
            return filename
        else:
            raise IOError("%s not found" % filename)

    for path in gladepath:
        # append slash to dirname
        if not path:
            continue
        # if absolute path
        fname = os.path.join(path, filename)
        if os.path.isfile(fname):
            return fname

    raise IOError("%s not found in path %s.  You probably need to "
                  "kiwi.environ.set_gladepath() correctly" % (filename,
                                                              gladepath))

#
# Image path resolver
#

imagepath = ''

if os.environ.has_key ('KIWI_IMAGE_PATH'):
    imagepath = string.split(os.environ['KIWI_IMAGE_PATH'])

def set_imagepath(path):
    global imagepath
    imagepath = path

def get_imagepath():
    global imagepath
    return imagepath

def image_path_resolver(filename):
    imagepath = get_imagepath()

    # check to see if imagepath is a list or tuple
    if not isinstance(imagepath, (list, tuple)):
        msg ="imagepath should be a list or tuple, found %s"
        raise ValueError(msg % type(imagepath))

    if not imagepath:
        if os.path.isfile(filename):
            return filename
        else:
            raise IOError("%s not found" % filename)

    basefilename = os.path.basename(filename)
    
    for path in imagepath:
        if not path:
            continue
        fname = os.path.join(path, basefilename)
        if os.path.isfile(fname):
            return fname

    raise IOError("%s not found in path %s. You probably need to "
                  "kiwi.environ.set_imagepath() correctly" % (filename,
                                                              imagepath))


require_gazpacho_loader = False

def require_gazpacho():
    global require_gazpacho_loader
    require_gazpacho_loader = True


@@ -1007,16 +1007,182 @@
 string%0A%0A
+__all__ = %5B'set_gladepath', 'get_gladepath', 'find_in_gladepath',%0A           'set_imagepath', 'get_imagepath', 'image_path_resolver',%0A           'require_gazpacho',%5D%0A
 #%0A# Glad
@@ -1199,16 +1199,17 @@
 ling%0A#%0A%0A
+_
 gladepat
@@ -1258,24 +1258,25 @@
 PATH'):%0A    
+_
 gladepath = 
@@ -1461,32 +1461,33 @@
  %22%22%22%0A    global 
+_
 gladepath%0A    gl
@@ -1480,24 +1480,25 @@
 adepath%0A    
+_
 gladepath = 
@@ -1535,16 +1535,17 @@
  global 
+_
 gladepat
@@ -1557,16 +1557,17 @@
  return 
+_
 gladepat
@@ -2555,16 +2555,17 @@
 lver%0A#%0A%0A
+_
 imagepat
@@ -2615,24 +2615,25 @@
 PATH'):%0A    
+_
 imagepath = 
@@ -2705,32 +2705,33 @@
 th):%0A    global 
+_
 imagepath%0A    im
@@ -2724,24 +2724,25 @@
 agepath%0A    
+_
 imagepath = 
@@ -2779,16 +2779,17 @@
  global 
+_
 imagepat
@@ -2801,16 +2801,17 @@
  return 
+_
 imagepat
@@ -3690,16 +3690,17 @@
 ath))%0A%0A%0A
+_
 require_
@@ -3759,16 +3759,17 @@
  global 
+_
 require_
@@ -3788,16 +3788,17 @@
 der%0A    
+_
 require_

Make global variables private and set __all__