[ADD]Hy base : add xml-write macro
This commit is contained in:
parent
8eb4c0e294
commit
b8462951e0
@ -48,3 +48,12 @@
|
||||
(defmacro field-model [model] `(field {"name" "model"} [~model]))
|
||||
(defmacro field-inherit [xmlid] `(field {"name" "inherit_id" "ref" ~xmlid} []))
|
||||
(defmacro field-arch [&rest args] `(field {"name" "arch" "type" "xml"} ~@args))
|
||||
|
||||
(defmacro xml-write [filename tree]
|
||||
"Write XML file according to filename and given tree"
|
||||
`(do
|
||||
(import [os [path]])
|
||||
(setv elementtree ~tree)
|
||||
(setv output (.tostring ET elementtree))
|
||||
(setv fpath (+ (.dirname path (.abspath path __file__)) "/" ~filename))
|
||||
(with [f (open fpath "w")] (.write f output))))
|
||||
|
Loading…
Reference in New Issue
Block a user