From 9a7027622f9f9d7d0851ea28c98122c566507648 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Sep 2019 18:21:29 +0200 Subject: [PATCH] [IMP]Hy base : use gensym for safer xml-write macro --- hy_base/odoo.hy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hy_base/odoo.hy b/hy_base/odoo.hy index b6e2009..87b9522 100644 --- a/hy_base/odoo.hy +++ b/hy_base/odoo.hy @@ -50,11 +50,11 @@ (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] +(defmacro/g! xml-write [filename tree] "Write XML file according to filename and given tree" `(do - (import [os [path]]) - (setv output-xml (.tostring ET tree) - output-path (.dirname path (.abspath path __file__)) - fpath f"{output-path}/{filename}") - (with [f (open fpath "w")] (.write f output-xml)))) + (import [os [path]]) + (setv ~g!output-xml (.tostring ET tree) + ~g!output-path (.dirname path (.abspath path __file__)) + ~g!fpath (+ ~g!output-path "/" ~g!filename)) + (with [f (open ~g!fpath "w")] (.write f ~g!output-xml))))