Last active
November 3, 2020 14:54
-
-
Save rplevka/36917d4415aa2816433d1162b780b01d to your computer and use it in GitHub Desktop.
Revisions
-
rplevka revised this gist
Nov 3, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,8 @@ for fi in files: 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: -
rplevka revised this gist
Nov 3, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,6 @@ for fi in files: t = foo['testsuites']['testsuite']['@timestamp'] to = time.strptime(t.split('.')[0]+'_+0200', '%Y-%m-%dT%H:%M:%S_%z') 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)) -
rplevka revised this gist
Oct 22, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,14 +3,14 @@ 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') 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']['properties'] = {'property':[{'@name': 'start_time', '@value': tn}]} with open(f'new/{fi}', 'w') as g: g.write(xmltodict.unparse(foo)) -
rplevka created this gist
Oct 22, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ 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') 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']['properties'] = {'property':[{'@name': 'start_time', '@value': tn}]} with open(f'new/{fi}', 'w') as g: g.write(xmltodict.unparse(foo))