2017-05-03 16:13:08 +08:00
|
|
|
import sys
|
2018-11-04 20:13:34 -08:00
|
|
|
from libs.constants import DEFAULT_ENCODING
|
2017-05-03 16:13:08 +08:00
|
|
|
|
|
|
|
|
def ustr(x):
|
|
|
|
|
'''py2/py3 unicode helper'''
|
|
|
|
|
|
|
|
|
|
if sys.version_info < (3, 0, 0):
|
|
|
|
|
from PyQt4.QtCore import QString
|
|
|
|
|
if type(x) == str:
|
2018-11-04 20:13:34 -08:00
|
|
|
return x.decode(DEFAULT_ENCODING)
|
2017-05-03 16:13:08 +08:00
|
|
|
if type(x) == QString:
|
2018-12-01 00:20:46 -08:00
|
|
|
return unicode(x)
|
2017-05-03 16:13:08 +08:00
|
|
|
return x
|
|
|
|
|
else:
|
2018-11-04 20:13:34 -08:00
|
|
|
return x
|