clr.AddReference("TWC.I2Libs")
clr.AddReference("I2Common")
clr.AddReference("System")

from System.IO import DirectoryInfo
from System.IO import Path

from TWC.I2.Util import Config

def Run(doc):

	root = doc.CreateElement("SystemUpgradeCatalogs")
	files = DirectoryInfo(Path.Combine(Config.SystemRoot, "Upgrades/Catalogs")).GetFiles("*.xml")

	for x in range(0, len(files)):
		f = files[x]
		d = XmlDocument()
		d.Load(f.FullName)
		root.AppendChild(doc.ImportNode(d.DocumentElement, True))
	
	doc.DocumentElement.AppendChild(root)