Last active
February 4, 2021 23:54
-
-
Save WNP78/18bd69c73fa0cfb65c2d71bff323c5aa to your computer and use it in GitHub Desktop.
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 sys,os | |
def tryFindSpDir(): | |
if sys.platform.startswith("win"): | |
p = os.path.abspath(os.path.join(os.getenv("APPDATA"),"..\\LocalLow\Jundroo\SimplePlanes\AircraftDesigns")) + "\\" | |
if os.path.isdir(p): return p | |
elif sys.platform.startswith("darwin"): # MacOS - not tested | |
p = os.path.abspath("~/Library/Application Support/Jundroo/SimplePlanes/AircraftDesigns") + "/" | |
if os.path.isdir(p): return p | |
return input("SP aircraft directory> ") # failed to auto detect | |
from xml.etree.ElementTree import ElementTree as et | |
path = os.path.join(tryFindSpDir(), input("Name> ") + ".xml") | |
tree = et(file=path) | |
root = tree.getroot() | |
prop = input("Property> ") | |
val = input("Value> ") | |
for part in root.findall("Assembly/Parts/Part"): | |
part.set(prop, val) | |
tree.write(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment