Mercurial > piecrust2
comparison piecrust/osutil.py @ 638:a4ac464a45b3
internal: Remove SyntaxWarning from MacOS wrappers.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 14 Feb 2016 19:44:25 -0800 |
parents | 6ef89b31ddda |
children | ea6cbd6d2af5 |
comparison
equal
deleted
inserted
replaced
637:7940861ff9bc | 638:a4ac464a45b3 |
---|---|
7 walk = os.walk | 7 walk = os.walk |
8 listdir = os.listdir | 8 listdir = os.listdir |
9 glob = _system_glob.glob | 9 glob = _system_glob.glob |
10 | 10 |
11 | 11 |
12 if sys.platform == 'darwin': | 12 def _wrap_fs_funcs(): |
13 global walk | |
14 global listdir | |
15 global glob | |
16 | |
13 def _walk(top, **kwargs): | 17 def _walk(top, **kwargs): |
14 for dirpath, dirnames, filenames in os.walk(top, **kwargs): | 18 for dirpath, dirnames, filenames in os.walk(top, **kwargs): |
15 dirpath = _from_osx_fs(dirpath) | 19 dirpath = _from_osx_fs(dirpath) |
16 dirnames[:] = list(map(_from_osx_fs, dirnames)) | 20 dirnames[:] = list(map(_from_osx_fs, dirnames)) |
17 filenames[:] = list(map(_from_osx_fs, filenames)) | 21 filenames[:] = list(map(_from_osx_fs, filenames)) |
31 return unicodedata.normalize('NFC', s) | 35 return unicodedata.normalize('NFC', s) |
32 | 36 |
33 def _to_osx_fs(s): | 37 def _to_osx_fs(s): |
34 return unicodedata.ucd_3_2_0.normalize('NFD', s) | 38 return unicodedata.ucd_3_2_0.normalize('NFD', s) |
35 | 39 |
36 global walk, listdir, glob | |
37 | |
38 walk = _walk | 40 walk = _walk |
39 listdir = _listdir | 41 listdir = _listdir |
40 glob = _glob | 42 glob = _glob |
41 | 43 |
44 | |
45 if sys.platform == 'darwin': | |
46 _wrap_fs_funcs() | |
47 |