From 52ff408651813f4c82b0ce76c2f32031028cc41e Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 13 Jun 2019 19:32:35 -0400 Subject: [PATCH] Better exporting/importing of depletion_chain in DataLibrary Use str(path) in the path attribute when registering. This preserves the full path, not just the basename. Give special depletion_chain tag when exporting a library of type depletion_chain, rather than using previous library tag --- openmc/data/library.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openmc/data/library.py b/openmc/data/library.py index d1a0d778d9..d5f18aa170 100644 --- a/openmc/data/library.py +++ b/openmc/data/library.py @@ -72,7 +72,7 @@ class DataLibrary(EqualityMixin): "File type {} not supported by {}" .format(path.name, self.__class__.__name__)) - library = {'path': path.name, 'type': filetype, 'materials': materials} + library = {'path': str(path), 'type': filetype, 'materials': materials} self.libraries.append(library) def export_to_xml(self, path='cross_sections.xml'): @@ -97,8 +97,10 @@ class DataLibrary(EqualityMixin): dir_element.text = os.path.realpath(common_dir) for library in self.libraries: - lib_element = ET.SubElement(root, "library") - if library['materials']: + if library['type'] == "depletion_chain": + lib_element = ET.SubElement(root, "depletion_chain") + else: + lib_element = ET.SubElement(root, "library") lib_element.set('materials', ' '.join(library['materials'])) lib_element.set('path', os.path.relpath(library['path'], common_dir)) lib_element.set('type', library['type'])