Make migrations scripts#483
Conversation
ThibaultMarzullo
left a comment
There was a problem hiding this comment.
This looks good, thank you! On top of the comments that I made throughout the files, can you also include one file for testing? If we do not have an example XML with the right fields, maybe you can amend a minimalist XML like this L000 pre-simulation XML.
There was a problem hiding this comment.
Can you add an example of usage please?
|
|
||
| def update_usefulLife(tree): | ||
| for usefulLife in tree.findall('.//*{http://buildingsync.net/schemas/bedes-auc/2019}UsefulLife'): | ||
| usefulLife.text = usefulLife.text.split(".", 1)[0] |
There was a problem hiding this comment.
| usefulLife.text = usefulLife.text.split(".", 1)[0] | |
| usefulLife.text = str(int(usefulLife.text)) |
Currently, we only round down, is this right? If so, would this also round up when necessary?
| exit(f"File could not be read \n{e} \naborting...") | ||
|
|
||
| update_usefulLife(tree) | ||
|
|
There was a problem hiding this comment.
Can you log or at least display the instances in which the script changed the number that the user had input in the original XML? For example, if usefulLife was 3.4, it would become 3 after this script updates the field. If we change that number, it would be worth pointing it out to the user to avoid surprises.
|
|
||
| update_usefulLife(tree) | ||
|
|
||
| tree.write(file_path) |
There was a problem hiding this comment.
Can you save the original file under a different name like ye_olde_excemelle or a sober and more appropriate suffix like my_xml_old?
There are mutliple v2.4 files in the repo currently, for example, |
|
This one looks good, but I want to point out that we had something built for version converting by using xsl in here. I'm not sure if xsl is something more generic for xml conversion and might be useful for future development. |
|
oh, this would have been great to know about. I haven't worked with xsl, let me dig into it. |
|
wait, these scripts are for v2 to v3 and it's on develop-v3. Can you give me some context: what happened to v3? |
v3 is a frozen version that was determined not to be released in the near future. I don't think you want to dig into xslt - I suggest we go with pure Python but refer to that v3 xslt tool for the extensibility of this script (e.g. adding a comment note like the one in v3 converter such as "This BuildingSync v2.5 document was generated from a BuildingSync v2.4 document via ...."). |
|
I want to be clear: You want a comment in the generated/updated xml file stating it was modified by the script? |
Yes. Something like this line in the xslt tool for v2-to-v3, which adds a comment on top of the generated xml. |
JieXiong9119
left a comment
There was a problem hiding this comment.
Looks good. Thank you Hannah!
Cute little script to modified BuildingSync files from 2.4 to 2.5