blob: f1ca91bb35fd6eae6f6cf89ec690c322e64a8172 [file] [log] [blame]
Nobuaki Sukegawa2de27002015-11-22 01:13:48 +09001import os
2import sys
3
4if sys.version_info[0] == 2:
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +09005 _ENCODE = sys.getfilesystemencoding()
Nobuaki Sukegawa2de27002015-11-22 01:13:48 +09006
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +09007 def path_join(*args):
8 bin_args = map(lambda a: a.decode(_ENCODE), args)
9 return os.path.join(*bin_args).encode(_ENCODE)
Nobuaki Sukegawa2de27002015-11-22 01:13:48 +090010
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090011 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 Sukegawa2de27002015-11-22 01:13:48 +090015
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090016 logfile_open = open
Nobuaki Sukegawaa6ab1f52015-11-28 15:04:39 +090017
Nobuaki Sukegawa2de27002015-11-22 01:13:48 +090018else:
19
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090020 path_join = os.path.join
21 str_join = str.join
Nobuaki Sukegawa2de27002015-11-22 01:13:48 +090022
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090023 def logfile_open(*args):
24 return open(*args, errors='replace')