From: Neil Date: Sun, 14 Apr 2013 11:57:45 +0000 (+0200) Subject: Normalise file paths in data.py X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=67e1f5bd51cb9c6d11d3c5c1a8b98da78fe4bc20;p=erdslangetjie.git Normalise file paths in data.py --- diff --git a/erdslangetjie/data.py b/erdslangetjie/data.py index 66b66bb..d33d47a 100644 --- a/erdslangetjie/data.py +++ b/erdslangetjie/data.py @@ -13,15 +13,17 @@ import os data_py = os.path.abspath(os.path.dirname(__file__)) data_dir = os.path.normpath(os.path.join(data_py, '..', 'data')) + def filepath(filename): '''Determine the path to a file in the data directory. ''' + filename = os.path.join(*filename.split('/')) return os.path.join(data_dir, filename) + def load(filename, mode='rb'): '''Open a file in the data directory. "mode" is passed as the second arg to open(). ''' - return open(os.path.join(data_dir, filename), mode) - + return open(filepath(filename), mode)