# HG changeset patch # User Ludovic Chabant # Date 1438145457 25200 # Node ID fa9eb8f866cd5f1fe3c8d14d5e3b3fccec7e497c # Parent 9b8b47fb1068ed5cc41acd372c43437ca8cb99b0 bug: Fix file-system wrappers for non-Mac systems. diff -r 9b8b47fb1068 -r fa9eb8f866cd piecrust/osutil.py --- a/piecrust/osutil.py Tue Jul 28 21:36:59 2015 -0700 +++ b/piecrust/osutil.py Tue Jul 28 21:50:57 2015 -0700 @@ -1,23 +1,28 @@ import os import sys -import glob as _glob +import glob as _system_glob import unicodedata +walk = os.walk +listdir = os.listdir +glob = _system_glob.glob + + if sys.platform == 'darwin': - def walk(top, **kwargs): + def _walk(top, **kwargs): for dirpath, dirnames, filenames in os.walk(top, **kwargs): dirpath = _from_osx_fs(dirpath) dirnames = list(map(_from_osx_fs, dirnames)) filenames = list(map(_from_osx_fs, filenames)) yield dirpath, dirnames, filenames - def listdir(path='.'): + def _listdir(path='.'): for name in os.listdir(path): name = _from_osx_fs(name) yield name - def glob(pathname): + def _glob(pathname): pathname = _to_osx_fs(pathname) matches = _glob.glob(pathname) return list(map(_from_osx_fs, matches)) @@ -28,8 +33,7 @@ def _to_osx_fs(s): return unicodedata.ucd_3_2_0.normalize('NFD', s) -else: - walk = sys.walk - listdir = sys.listdir - glob = _glob.glob + walk = _walk + listdir = _listdir + glob = _glob