Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Had issue where some artists had copied configs from another machine and ui elements would just be gone or they'd suffer constant crashes. Figured it could be conflicts in their configs so threw this one together and seems to have solved our issues.
import xml.etree.ElementTree as ET
import os
platform = lx.service.Platform()
configs = set() # all unique paths to config files
for i in range(platform.ImportPathCount()):
directory = platform.ImportPathByIndex(i)
for filename in os.listdir(directory):
if filename.lower().endswith('.cfg'):
path = os.path.join(directory, filename)
ids = {}
for config in configs:
root = ET.parse(config).getroot()
sheets = root.findall('.//*[@type="Sheet"]')
for sheet in sheets:
key = sheet.get('key')
if key in ids:
ids[key] = [config]
except ET.ParseError:
pass # not all configs are valid xml
# key will be the sheet "id" and values will be list of all configs where it was defined
for k,v in ids.items():
if len(v) > 1:
print("Conflict found:")
for x in v:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment