File: compat.py

package info (click to toggle)
python-dynaconf 3.2.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,900 kB
  • sloc: python: 21,464; sh: 9; makefile: 4
file content (17 lines) | stat: -rw-r--r-- 473 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import sys
PY2=sys.version_info[0]==2
if PY2:from StringIO import StringIO
else:from io import StringIO
def is_type_checking():
	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
def to_env(text):
	if PY2:return text.encode(sys.getfilesystemencoding()or'utf-8')
	else:return text
def to_text(string):
	A=string
	if PY2:return A.decode('utf-8')
	else:return A