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: |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 5 | _ENCODE = sys.getfilesystemencoding() |
Nobuaki Sukegawa | 2de2700 | 2015-11-22 01:13:48 +0900 | [diff] [blame] | 6 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 7 | def path_join(*args): |
| 8 | bin_args = map(lambda a: a.decode(_ENCODE), args) |
| 9 | return os.path.join(*bin_args).encode(_ENCODE) |
Nobuaki Sukegawa | 2de2700 | 2015-11-22 01:13:48 +0900 | [diff] [blame] | 10 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 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) |
Nobuaki Sukegawa | 2de2700 | 2015-11-22 01:13:48 +0900 | [diff] [blame] | 15 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 16 | logfile_open = open |
Nobuaki Sukegawa | a6ab1f5 | 2015-11-28 15:04:39 +0900 | [diff] [blame] | 17 | |
Nobuaki Sukegawa | 2de2700 | 2015-11-22 01:13:48 +0900 | [diff] [blame] | 18 | else: |
| 19 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 20 | path_join = os.path.join |
| 21 | str_join = str.join |
Nobuaki Sukegawa | 2de2700 | 2015-11-22 01:13:48 +0900 | [diff] [blame] | 22 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 23 | def logfile_open(*args): |
| 24 | return open(*args, errors='replace') |