I am trying to update a plist as follows
Match the string field "What change bugs are fixed in this submission?" and update the corresponding string field for<key>response</key>
The issue right now the code updates the string field What change bugs are fixed in this submission?
,how do I update the corresponding response string field?I added the expected plist output aswell?is there a simpler way to do this python?where am I going wrong?
CODE:-
import re,os,fileinput
text1_to_search = re.compile(r'<string>What change bugs are fixed in this submission?.*</string>')
replacement1_text = """change://problem/219620> milestone: WCM-739#202 has failed to build in install: expected a type
change://problem/215275> Fix logic for PSK-->Open update
change://problem/1265279> Hotspot keeps changing from the device I selected
"""
for line in fileinput.input(filename, inplace=True, backup='.bak'):
print(text1_to_search.sub(replacement1_text, line)),
plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//company//DTD PLIST 1.0//EN" "http://www.company.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>28</key>
<dict>
<key>description</key>
<string>Which update of macOS, Xcode, and the SDKs was this submission built on with 'abc buildit'?</string>
<key>id</key>
<string>28</string>
<key>multiline</key>
<string>0</string>
<key>releases</key>
<array>
<string>milestone</string>
</array>
<key>response</key>
<string></string>
</dict>
<key>7</key>
<dict>
<key>description</key>
<string>What change bugs are fixed in this submission? (Please include the change number or URL followed by the title)</string>
<key>id</key>
<string>7</string>
<key>multiline</key>
<string>1</string>
<key>releases</key>
<array>
<string>milestone</string>
</array>
<key>response</key>
<string></string>
</dict>
</dict>
</plist>
Expected output After update
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//company//DTD PLIST 1.0//EN" "http://www.company.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>28</key>
<dict>
<key>description</key>
<string>Which update of macOS, Xcode, and the SDKs was this submission built on with 'abc buildit'?</string>
<key>id</key>
<string>28</string>
<key>multiline</key>
<string>0</string>
<key>releases</key>
<array>
<string>milestone</string>
</array>
<key>response</key>
<string></string>
</dict>
<key>7</key>
<dict>
<key>description</key>
<string>What change bugs are fixed in this submission? (Please include the change number or URL followed by the title)</string>
<key>id</key>
<string>7</string>
<key>multiline</key>
<string>1</string>
<key>releases</key>
<array>
<string>milestone</string>
</array>
<key>change://problem/219620> milestone: WCM-739#202 has failed to build in install: expected a type
change://problem/215275> Fix logic for PSK-->Open update
change://problem/1265279> Hotspot keeps changing from the device I selected</key>
<string></string>
</dict>
</dict>
</plist>