From 6b49ee69f42bf0226d95b2fd96a1676fe8d4e58c Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Wed, 2 Nov 2022 10:39:12 +0100 Subject: [PATCH] [IMP]Yaltik DSL : suffix better than xml type --- yaltik_dsl/__manifest__.py | 2 +- yaltik_dsl/src/xml_base.py | 5 ++--- yaltik_dsl/tests/test_xml_base.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/yaltik_dsl/__manifest__.py b/yaltik_dsl/__manifest__.py index 11ff301..871b014 100644 --- a/yaltik_dsl/__manifest__.py +++ b/yaltik_dsl/__manifest__.py @@ -19,7 +19,7 @@ 'name': 'Yaltik Odoo DSL base module and fns', 'summary': 'Yaltik Odoo Domain Specific Language base module and functions', 'description': """ Yaltik Odoo Domain Specific Language base module and functions """, - 'version': '16.0.0.4.4', + 'version': '16.0.0.4.5', 'category': 'Yaltik', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/yaltik_dsl/src/xml_base.py b/yaltik_dsl/src/xml_base.py index f7289f7..15c0876 100644 --- a/yaltik_dsl/src/xml_base.py +++ b/yaltik_dsl/src/xml_base.py @@ -62,15 +62,14 @@ def xmln(tag='', attrs={}, children=[]): raise TypeError('Invalid arguments for xmln') -def xml_write(filepath, tree, pretty=True, xml_type='view'): +def xml_write(filepath, tree, pretty=True, suffix='_views'): """ Write XML file according to filename and given tree """ if filepath.endswith('.py'): # if .pyc, no need to generate XML output_xml = ET.tostring(tree) if pretty: output_xml = minidom.parseString(output_xml).toprettyxml(indent=' ') - suffix = '_views.xml' if xml_type == 'view' else '_data.xml' output_path = path.abspath(filepath).split('/') - output_path[-1] = output_path[-1].replace('.py', suffix) + output_path[-1] = output_path[-1].replace('.py', '%s.xml' % suffix) output_path = '/'.join(output_path) with open(output_path, 'w') as output_file: output_file.write(output_xml) diff --git a/yaltik_dsl/tests/test_xml_base.py b/yaltik_dsl/tests/test_xml_base.py index 00a69d6..e3ff2d0 100644 --- a/yaltik_dsl/tests/test_xml_base.py +++ b/yaltik_dsl/tests/test_xml_base.py @@ -115,7 +115,7 @@ class TestXMLBase(unittest.TestCase): self.assertIn('', output_xml) self.assertIn('Some text', output_xml) unlink(filepath) - xml_write(__file__, tree, xml_type='data') + xml_write(__file__, tree, suffix='_data') filepath = __file__.replace('.py', '_data.xml') with open(filepath, 'r') as output_file: output_xml = output_file.read()