Skip to content

Instantly share code, notes, and snippets.

@rondreas
Created May 24, 2021 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondreas/e317b664207c0718c6fb775702a9c024 to your computer and use it in GitHub Desktop.
Save rondreas/e317b664207c0718c6fb775702a9c024 to your computer and use it in GitHub Desktop.
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)
configs.add(path)
ids = {}
for config in configs:
try:
root = ET.parse(config).getroot()
sheets = root.findall('.//*[@type="Sheet"]')
for sheet in sheets:
key = sheet.get('key')
if key in ids:
ids[key].append(config)
else:
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:
print("\t{}".format(x))
@smoluck
Copy link

smoluck commented Sep 9, 2022

That script is a "Must have" for any Modo Developer.
thanks Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment