Last active
November 3, 2020 14:54
-
-
Save rplevka/36917d4415aa2816433d1162b780b01d to your computer and use it in GitHub Desktop.
fix junit.xml start_time properties
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
import os | |
import time | |
import xmltodict | |
files = os.listdir('.') | |
for fi in files: | |
if fi == 'new': | |
continue | |
with open(fi, 'r') as f: | |
foo = xmltodict.parse(f.read()) | |
t = foo['testsuites']['testsuite']['@timestamp'] | |
to = time.strptime(t.split('.')[0]+'_+0200', '%Y-%m-%dT%H:%M:%S_%z') | |
epoch = time.mktime(to) - 7200 | |
to = time.gmtime(epoch) | |
tn = f'{to.tm_year}-{to.tm_mon}-{to.tm_mday}T{to.tm_hour-2}:{to.tm_min}:{to.tm_sec}' | |
foo['testsuites']['testsuite'].update({'properties': [{'property': {'@name': 'start_time', '@value': tn}}]}) | |
with open(f'new/{fi}', 'w') as g: | |
g.write(xmltodict.unparse(foo)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment