"""apppath.py

This module provides files for working with Extracto apps.

Functions:
find    Find the full pathname of a app.

"""
import os

def find(name, searchpath=None):
    """find(name[, searchpath]) -> filename or None

    Find the full path of a datafile named name.  Returns None if not
    found.

    """
    if not searchpath:
        searchpath = []
    p, f = os.path.split(__file__)
    searchpath.append(os.path.join(p, "apps"))

    for p in searchpath:
        filename = os.path.join(p, name)
        if os.path.exists(filename):
            return filename
    raise ValueError, "I cannot find the path for %s" % name
