On Feb 23, 2004, at 2:02 AM, Jack Jansen wrote:
Implementation is going to be peanuts, design is what we want.
We should investigate the paradigms people use nowadays to get at
their datafiles, and come up with something that is as close as
possible to that.
How does pygame find its datafiles?
When we were involved in development with pygtk we stored data files in
subdirectories of the toplevel Python package for ease of distribution.
We found the data files by searching on the Python path.
The technique is documented in this article:
http://www2.linuxjournal.com/lj-issues/issue87/4702.html
I have updated the module PathFinder.py described in the article. The
new version recognizes zip files in the Python path. If one of the zip
files contains the data file being sought, then the data file is
extracted to a temporary directory, preserving filename suffix. The
location of the extracted file is remembered in case another client
seeks it. At the end of the Python session the temporary files are
removed.
Use of the module is pretty simple:
import PathFinder
try:
jpegPathname = PathFinder.find("images/sample.jpg")
except PathFinder.Error, info:
...
If any of this sounds relevant I can post a tarball containing the
module and a regression test.
Extracting data from zip files is not strictly desired or necessary as
we have bundles on OS X, temp files suck, most data files probably
aren't going to compress very well anyhow.