New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move aiida-fleur xml_util #23
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… be used in the old way `create_tag_xpath` or utilizing the schema_dictionary functionality `create_tag`
Split up into functions that can create missing tags on the fly and basic functions that rely on the tags being there and which do not have access to the schema_dict Added: - replace tag, delete tag/attribute - setting attributes/text (Thes functions were unified under one and only provided the first as a special alias)
Added: - set_simple_tag for single/multiple tags with only attributes - set_complex_tag Recursive handling for all kinds of inputs (ATTENTION: will delete all tags in several before rewriting) - set_species/set_inpchanges moved unchanged from aiida_fleur (masci_tools parser branch) TODO: - move conversion of attribute/text into strings into the xml_set_attrib_value and xml_set_text value - settle on a more consistent function name scheme to indicate the interface in the function name (schema_dict+name; schema_dict+base xpath; concrete xpaths with minimal requirements)
- This is essentially FleurinpModifier without provenance Could be used as a superclass for FleurinpModifier. We just would need to call apply_modifications For ease of integration with FleurinpModifier the files to be modified are only provided once the modifications are supposed to happen `modify_xmlfile`
Notes: - change_atomgr_att -> set_atomgroup - change_atomgr_att_label -> set_atomgroup_label - add_num_to_att -> add_number_to_attrib (now also supports occurrences) - add_number_to_first_attrib (behaviour of add_num_to_att) - attribute/text setting from attributename with support for occurrences and complex xpaths - new function rotate_nmmpmat modifies exisiting density matrix block and rotates it according to the given angles - FleurXMLModifier.apply_modifications supports passing of extra functions for subclasses of this. This can be used for example to integrate functions using aiida nodes in to the same function without introducing aiida dependencies
… application to a xml file)
if a method starts with xml_ it REQUIRES atleast one xpath as argument
I don't know id I should use these functions in the parsers, since they are essentially the initial loading phase of these, but this could introduce some ugly dependencies
and add docstrings
All these functions will always return success since it does not make sense to make them obvious to use fro the outside (since inside they are always used without suc_return=False). There should always be a more high level function using the schema_dict, which will call these converters in the background
We might have to restructure the source code reference to be more structured since its becoming quite large
… organized and searchable/browseable
…nce these things should be tested in the xml_setters tests)
Some outschemas were missing and the '0.29' output schema still had '0.30' as version since it was copied from this schema
There were two errors in the outside_actions dict
…edge cases of enforced order without complicating the structure of the schema dict Essentially if a tag_order is encountered, which has no invalid/unknown tags and they are just out of order a new tag is built with the tags entered in the expected order
…r attributes and text (This way we can enter special cases in the schema_dict, where precision needs to be lower/higher)
…ida_fleur_xml_setters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull requests moves (and redesigns if necessary) most of the content of the tools/xml_util module in aiida_fleur (status of the masci_tools_parsers branch)
One fundamental change I made is that I introduced more splitting of responsibilities of these XML modifying functions. There are now 3 (or 4) categories of XML setter functions
xml_create_tag
can only create a tag if all parent tags are already present)[@name='species-name']
). This simple xpath is used in the schema dictionary to find out more information about the operation to perform. For example it can find out the enforced order of subtags or the types an attribute can have. These functions can create parent if they are not presentcomplex_xpath
to customize behaviour). These are essentially all the user-friendly methods from aiida-fleur with some extensionsIn addition I implemented an equivalent for the Fleurinpmodifier in aiida-fleur, which operates on a concrete
inp.xml
(andn_mmp_mat
if necessary) file. The usage is almost the same (except for initialisation and application to the file)Other small changes:
load_inpxml
andload_outxml
for easy access to an xmltree and version specific schema dictTODO:
xml_setters_names
xml_setters_nmmpmat
common_xml_util
load_inpxml
,load_outxml
andFleurXMLModifier