[FIX]Hy Base : handle python2 case
This commit is contained in:
parent
f1ae84bc77
commit
b61c49d1e6
@ -19,6 +19,13 @@
|
||||
|
||||
(require [odoo.addons.hy_base.xml [*]])
|
||||
|
||||
(defmacro if-python2 [python2-form python3-form]
|
||||
"If running on python2, execute python2-form, else, execute python3-form"
|
||||
(import sys)
|
||||
(if (< (get sys.version_info 0) 3)
|
||||
python2-form
|
||||
python3-form))
|
||||
|
||||
(defmacro ox-odoo [&rest args] `(xmlr "odoo" ~@args))
|
||||
(defmacro ox-data [&rest args] `(xmlnc "data" ~@args))
|
||||
(defmacro ox-record [&rest args] `(xmlnc "record" ~@args))
|
||||
@ -63,7 +70,9 @@
|
||||
"Write XML file according to filename and given tree"
|
||||
`(do
|
||||
(import [os [path]])
|
||||
(setv ~g!output-xml (.tostring ET ~tree)
|
||||
~g!output-path (.dirname path (.abspath path __file__))
|
||||
(if-python2
|
||||
(setv ~g!output-xml (.tostring ET ~tree))
|
||||
(setv ~g!output-xml (.decode (.tostring ET ~tree) "utf-8")))
|
||||
(setv ~g!output-path (.dirname path (.abspath path __file__))
|
||||
~g!fpath (+ ~g!output-path "/" ~filename))
|
||||
(with [f (open ~g!fpath "w")] (.write f ~g!output-xml))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user