2023-10-14 13:56:21 +00:00
|
|
|
import sys
|
2024-03-03 17:15:23 +00:00
|
|
|
PY2=sys.version_info[0]==2
|
|
|
|
if PY2:from StringIO import StringIO
|
|
|
|
else:from io import StringIO
|
2023-10-14 13:56:21 +00:00
|
|
|
def is_type_checking():
|
2024-03-03 17:15:23 +00:00
|
|
|
try:from typing import TYPE_CHECKING as A
|
|
|
|
except ImportError:return False
|
|
|
|
return A
|
|
|
|
IS_TYPE_CHECKING=is_type_checking()
|
|
|
|
if IS_TYPE_CHECKING:from typing import Text
|
2023-10-14 13:56:21 +00:00
|
|
|
def to_env(text):
|
2024-03-03 17:15:23 +00:00
|
|
|
if PY2:return text.encode(sys.getfilesystemencoding()or'utf-8')
|
|
|
|
else:return text
|
2023-10-14 13:56:21 +00:00
|
|
|
def to_text(string):
|
2024-03-03 17:15:23 +00:00
|
|
|
A=string
|
|
|
|
if PY2:return A.decode('utf-8')
|
|
|
|
else:return A
|