[FIX]hytopy handling of unicode characters

This commit is contained in:
Fabien BOURGEOIS 2020-04-27 12:30:20 +02:00
parent 305d17609f
commit 4cccf0e084
2 changed files with 11 additions and 4 deletions

View File

@ -17,6 +17,7 @@
" Odoo macros "
(require [hy-odoo.xml [if-python2]])
(import [os [path]])
(import [hy-odoo.xml [xmlroot xmln]])
@ -174,6 +175,7 @@
"Transforms hy to py for translation purpose"
(import astor)
(import [os.path [dirname]]
[io [open :as iopen]]
[hy.lex [hy-parse]]
[hy.compiler [hy-compile]]
[hy.errors [filtered-hy-exceptions]])
@ -186,10 +188,15 @@
(for [hy-file hy-files]
(setv hy-path (% "%s/%s.hy" (, (dirname module-path) hy-file))
hy-source (with [o (open hy-path "r")] (.read o))
hy-source (with [o (iopen hy-path "r" :encoding "utf-8")] (.read o))
output-path (.replace hy-path ".hy" ".py")
output-py (% "# %s\n%s" (, "Generate from Hy AST, for Babel translation purpose only. For real source code, please see and use HY source" (hytopy hy-source hy-path))))
(with [f (open output-path "w")] (.write f output-py))))
content ["# Generate from Hy AST, for Babel translation purpose only."
"# For real source code, please see and use HY source."
(hytopy hy-source hy-path)])
(if-python2
(.insert content 0 "# -*- coding: utf-8 -*-") (continue))
(setv output-py (.join "\n" content))
(with [f (iopen output-path "w")] (.write f output-py))))
; Migrations

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name="hy_odoo",
version="0.5.0",
version="0.5.1",
packages=find_packages(),
package_data={
'hy_odoo': ['*.hy'],