[FIX]hytopy handling of unicode characters
This commit is contained in:
parent
305d17609f
commit
4cccf0e084
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user