From b8462951e06aed950d949fb6d7a45a50ce1d8ae0 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Sep 2019 16:47:29 +0200 Subject: [PATCH] [ADD]Hy base : add xml-write macro --- hy_base/odoo.hy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hy_base/odoo.hy b/hy_base/odoo.hy index 6c98967..f2aa17e 100644 --- a/hy_base/odoo.hy +++ b/hy_base/odoo.hy @@ -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))))