Created
May 24, 2021 14:30
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That script is a "Must have" for any Modo Developer.
thanks Andreas