Added pulling of 'update fields' as columns

master
Griffiths Lott 3 years ago
parent 1654c9de66
commit c285863dd5
  1. 20
      parse_xml.py
  2. 12
      test.py

@ -20,8 +20,14 @@ try:
seq = seqMatch[1:-1]
dbg(f"\nSeq: {seq}")
CONDITION_REGEX = "<Condition Id=\"\w+\" Group=\"\w+\" CompareTo=\"(Value|Range)\">((?!</C)(.|\n))*</Condition>"
CONDITION_REGEX = r"<Condition Id=\"\w+\" Group=\"\w+\" CompareTo=\"(Value|Range)\">((?!</C)(.|\n))*</Condition>"
UPDATE_REGEX = r"<UpdateField Id=\"\w+\" Group=\"\w+\" UIRequired=\"\d+\" UIDisabled=\"\d+\" ForceUpdate=\"\d+\">\n?((?!</U)(.|\n))*</Up"
c = list(re.finditer(CONDITION_REGEX,senarioGroup))
dbg(f"\n\nSenario Group: {senarioGroup}")
updates = list(re.finditer(UPDATE_REGEX, senarioGroup))
dbg(f"{seq} | Updates: {updates}")
dbg(f"conditions:\n{[cond for cond in c]}")
senarioDict = {}
senarioDict["SEQ"] = int(seq)
@ -39,6 +45,18 @@ try:
dbg(f"SEQ: {seq} | {valueGroup}")
dbg(f"SEQ: {seq} | {value}")
senarioDict[id] = value
update: re.Match
for update in updates:
update = update.group()
dbg(f"{seq} | Update: {update}")
idMatch = re.search(r"\"\w+\"",update).span()
dbg(f"ID: {idMatch}")
id = update[idMatch[0]+1:idMatch[1]-1]
valueMatch = re.search(">(\w+|\.)+</Value>", update).span()
dbg(f"value: {valueMatch}")
value = update[valueMatch[0]+1:valueMatch[1]-8]
dbg(f"{seq} UPDATE | {id} : {value}")
senarioDict[id] = value
# Now merge the values from that senario into the main dict
seen = []
for key in dataDict.keys():

@ -0,0 +1,12 @@
import re
UPDATE_REGEX = r"<UpdateField Id=\"\w+\" Group=\"\w+\" UIRequired=\"\d+\" UIDisabled=\"\d+\" ForceUpdate=\"\d+\">\n((?!</U)(.|\n))*</Up"
ms = re.finditer(UPDATE_REGEX, S2)
for m in ms:
print(m.group())
idMatch = re.search(r"\"\w+\"",m.group())
print(idMatch)
Loading…
Cancel
Save