fix gbk bug on windows
@@ -68,7 +68,8 @@ class ConvertCommand(BaseCommand):
self.init_file, arcname=os.path.join(self.module, INIT_FILE))
def create_module_py(self):
- template_file = open(os.path.join(TMPL_DIR, 'x_model.tmpl'), 'r')
+ template_file = open(
+ os.path.join(TMPL_DIR, 'x_model.tmpl'), 'r', encoding='utf-8')
tmpl = Template(template_file.read())
lines = []
@@ -87,7 +88,7 @@ class ConvertCommand(BaseCommand):
'File `{MODULE_FILE}` is already exists in src dir.'.format(
MODULE_FILE))
- with open(self.model_file, 'w') as fp:
+ with open(self.model_file, 'w', encoding='utf-8') as fp:
fp.writelines(lines)
def create_init_py(self):
@@ -98,7 +99,8 @@ class ConvertCommand(BaseCommand):
shutil.copyfile(os.path.join(TMPL_DIR, 'init_py.tmpl'), self.init_file)
def create_serving_demo_py(self):
- template_file = open(os.path.join(TMPL_DIR, 'serving_demo.tmpl'), 'r')
+ template_file = open(
+ os.path.join(TMPL_DIR, 'serving_demo.tmpl'), 'r', encoding='utf-8')
tmpl = Template(template_file.read())
lines = []
@@ -109,7 +111,7 @@ class ConvertCommand(BaseCommand):
raise RuntimeError(
'File `{}` is already exists in src dir.'.format(SERVING_FILE))
- with open(self.serving_file, 'w') as fp:
+ with open(self.serving_file, 'w', encoding='utf-8') as fp:
fp.writelines(lines)
@staticmethod
