From 67e1f5bd51cb9c6d11d3c5c1a8b98da78fe4bc20 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 14 Apr 2013 13:57:45 +0200 Subject: [PATCH] Normalise file paths in data.py --- erdslangetjie/data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) -- 2.34.1