Mercurial > rinkhals
comparison gamelib/data.py @ 89:c0455e6c99f4
Support multiple arguments using os.path.join - better to pass filepath('a', 'b') than filepath('a/b')
author | David Fraser <davidf@sjsoft.com> |
---|---|
date | Wed, 02 Sep 2009 10:33:35 +0000 |
parents | 498e4732bc1f |
children | e12d99215b74 |
comparison
equal
deleted
inserted
replaced
88:a5ce010f9fb4 | 89:c0455e6c99f4 |
---|---|
8 import os | 8 import os |
9 | 9 |
10 data_py = os.path.abspath(os.path.dirname(__file__)) | 10 data_py = os.path.abspath(os.path.dirname(__file__)) |
11 data_dir = os.path.normpath(os.path.join(data_py, '..', 'data')) | 11 data_dir = os.path.normpath(os.path.join(data_py, '..', 'data')) |
12 | 12 |
13 def filepath(filename): | 13 def filepath(*filenames): |
14 '''Determine the path to a file in the data directory. | 14 '''Determine the path to a file in the data directory. |
15 ''' | 15 ''' |
16 return os.path.join(data_dir, filename) | 16 return os.path.join(data_dir, *filenames) |
17 | 17 |
18 def load(filename, mode='rb'): | 18 def load(filename, mode='rb'): |
19 '''Open a file in the data directory. | 19 '''Open a file in the data directory. |
20 | 20 |
21 "mode" is passed as the second arg to open(). | 21 "mode" is passed as the second arg to open(). |