Nobuaki Sukegawa | 2de2700 | 2015-11-22 01:13:48 +0900 | [diff] [blame] | 1 | import os |
| 2 | import sys |
| 3 | |
| 4 | if sys.version_info[0] == 2: |
| 5 | _ENCODE = sys.getfilesystemencoding() |
| 6 | |
| 7 | def path_join(*args): |
| 8 | bin_args = map(lambda a: a.decode(_ENCODE), args) |
| 9 | return os.path.join(*bin_args).encode(_ENCODE) |
| 10 | |
| 11 | def str_join(s, l): |
| 12 | bin_args = map(lambda a: a.decode(_ENCODE), l) |
| 13 | b = s.decode(_ENCODE) |
| 14 | return b.join(bin_args).encode(_ENCODE) |
| 15 | |
Nobuaki Sukegawa | a6ab1f5 | 2015-11-28 15:04:39 +0900 | [diff] [blame^] | 16 | logfile_open = open |
| 17 | |
Nobuaki Sukegawa | 2de2700 | 2015-11-22 01:13:48 +0900 | [diff] [blame] | 18 | else: |
| 19 | |
| 20 | path_join = os.path.join |
Nobuaki Sukegawa | a6ab1f5 | 2015-11-28 15:04:39 +0900 | [diff] [blame^] | 21 | str_join = str.join |
Nobuaki Sukegawa | 2de2700 | 2015-11-22 01:13:48 +0900 | [diff] [blame] | 22 | |
Nobuaki Sukegawa | a6ab1f5 | 2015-11-28 15:04:39 +0900 | [diff] [blame^] | 23 | def logfile_open(*args): |
| 24 | return open(*args, errors='replace') |