Mercurial > sypikslang
comparison gamelib/data.py @ 31:51ff46f42ed2
Add pth seperator normalisation to data helpers
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sun, 06 May 2012 20:54:03 +0200 |
parents | c90a6586cd66 |
children | 53277724645b |
comparison
equal
deleted
inserted
replaced
30:746af82c36b3 | 31:51ff46f42ed2 |
---|---|
12 | 12 |
13 | 13 |
14 def filepath(filename): | 14 def filepath(filename): |
15 '''Determine the path to a file in the data directory. | 15 '''Determine the path to a file in the data directory. |
16 ''' | 16 ''' |
17 filename = os.path.join(*filename.split('/')) | |
17 return os.path.join(data_dir, filename) | 18 return os.path.join(data_dir, filename) |
18 | 19 |
19 | 20 |
20 def load(filename, mode='rb'): | 21 def load(filename, mode='rb'): |
21 '''Open a file in the data directory. | 22 '''Open a file in the data directory. |
22 | 23 |
23 "mode" is passed as the second arg to open(). | 24 "mode" is passed as the second arg to open(). |
24 ''' | 25 ''' |
25 return open(os.path.join(data_dir, filename), mode) | 26 return open(filepath(filename), mode) |