mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- Assign SetInfo will now keep track of the existing state of the File and compare it to the potential new file so only changes are written
This commit is contained in:
@@ -122,17 +122,21 @@ if __name__ == '__main__':
|
|||||||
cardName = firstLine[5:]
|
cardName = firstLine[5:]
|
||||||
altName = None
|
altName = None
|
||||||
|
|
||||||
|
previousLines = []
|
||||||
|
previousLines.append(firstLine)
|
||||||
|
|
||||||
validLines = []
|
validLines = []
|
||||||
validLines.append(firstLine)
|
validLines.append(firstLine)
|
||||||
|
|
||||||
for line in cardfile.readlines():
|
for line in cardfile.readlines():
|
||||||
if line[:8] != "SetInfo:" and line[:8] != "SVar:Rar":
|
previousLines.append(line.strip())
|
||||||
|
# Just in case SVar:Rar is used as a legitimate SVar
|
||||||
|
if not line.startswith("SetInfo:") and not line.startswith("SVar:Rarity:"):
|
||||||
validLines.append(line.strip())
|
validLines.append(line.strip())
|
||||||
if line[:5] == "Name:":
|
|
||||||
altName = line[5:].strip()
|
|
||||||
cardfile.close()
|
|
||||||
|
|
||||||
print (cardName, altName, fileName)
|
if line.startswith("Name:"):
|
||||||
|
altName = line[5:].strip()
|
||||||
|
cardfile.close()
|
||||||
|
|
||||||
if not cardName in mtgDataCards and not altName is None:
|
if not cardName in mtgDataCards and not altName is None:
|
||||||
cardName = altName
|
cardName = altName
|
||||||
@@ -141,6 +145,11 @@ if __name__ == '__main__':
|
|||||||
if not setCodeToForge[e] is None:
|
if not setCodeToForge[e] is None:
|
||||||
validLines.append( "SetInfo:{} {}".format(setCodeToForge[e], mtgDataCards[cardName][e]) )
|
validLines.append( "SetInfo:{} {}".format(setCodeToForge[e], mtgDataCards[cardName][e]) )
|
||||||
|
|
||||||
|
if previousLines == validLines:
|
||||||
|
continue
|
||||||
|
|
||||||
|
print (cardName, altName, fileName)
|
||||||
|
|
||||||
toWrite = "\n".join(validLines)
|
toWrite = "\n".join(validLines)
|
||||||
|
|
||||||
cardfile = open(os.path.join(root, fileName), 'w')
|
cardfile = open(os.path.join(root, fileName), 'w')
|
||||||
|
|||||||
Reference in New Issue
Block a user