MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / __check_encoding

Method __check_encoding

client/codepuppy.py:83–101  ·  view source on GitHub ↗

检查默认编码,如果为空,设置为en_US.UTF-8 :return:

(self)

Source from the content-addressed store, hash-verified

81 LogPrinter.info(f"Tencent Cloud Code Analysis ({settings.EDITION.name} Beta)")
82
83 def __check_encoding(self):
84 """检查默认编码,如果为空,设置为en_US.UTF-8
85
86 :return:
87 """
88 # 默认编码检查
89 try:
90 code, encoding = locale.getdefaultlocale()
91 # LogPrinter.debug('locale is %s.%s' % (code, encoding))
92 except Exception as err:
93 LogPrinter.error('locale.getdefaultlocale() encounter err: %s' % str(err))
94 encoding = None
95
96 if encoding is None:
97 LogPrinter.warning('locale default encoding is None. LANG env may not set correctly! Set LANG env now.')
98 os.environ["LC_ALL"] = "en_US.UTF-8"
99 os.environ["LANG"] = "en_US.UTF-8"
100 code, encoding = locale.getdefaultlocale()
101 LogPrinter.info('Setting Lang env done, locale is %s.%s' % (code, encoding))
102
103 def main(self):
104 args = self._params

Callers 1

__init__Method · 0.95

Calls 3

errorMethod · 0.80
warningMethod · 0.80
infoMethod · 0.45

Tested by

no test coverage detected