From 1918aead44f45ddad254b724388fede46b6169d3 Mon Sep 17 00:00:00 2001 From: TheFGFSEagle Date: Tue, 26 Jul 2022 15:17:14 +0200 Subject: [PATCH] Remove stray spaces --- scenery/create-day-night-xml.py | 72 ++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/scenery/create-day-night-xml.py b/scenery/create-day-night-xml.py index aed019b..010ad35 100755 --- a/scenery/create-day-night-xml.py +++ b/scenery/create-day-night-xml.py @@ -8,24 +8,24 @@ def get_texture_paths(folder="."): path = os.path.relpath(os.path.join(folder, name), start=folder) if name.endswith(".ac"): with open(path, "r") as f: - if not path in texture_paths: - texture_paths[path] = {} - object = "" - for line in f: - if line.strip().startswith("name"): - object = line.split('"')[1] - if object == "world": - object = "" - continue - - if line.strip().startswith("texture") and object: - texture_path = line.split('"')[1] - if not texture_path in texture_paths[path]: - texture_paths[path][texture_path] = [] - texture_paths[path][texture_path].append(object) - - if not texture_paths[path]: - print(path, "contains no texture, skipping") + if not path in texture_paths: + texture_paths[path] = {} + object = "" + for line in f: + if line.strip().startswith("name"): + object = line.split('"')[1] + if object == "world": + object = "" + continue + + if line.strip().startswith("texture") and object: + texture_path = line.split('"')[1] + if not texture_path in texture_paths[path]: + texture_paths[path][texture_path] = [] + texture_paths[path][texture_path].append(object) + + if not texture_paths[path]: + print(path, "contains no texture, skipping") if not texture_paths: print(os.path.abspath(folder), "does not contain any AC files - exiting") @@ -37,8 +37,8 @@ def write_xml_files(texture_paths, lit_suffix, overwrite): for ac_path in texture_paths: xml_path = ac_path.replace(".ac", ".xml") if os.path.isfile(xml_path) and not overwrite: - print("XML file", xml_path, "already exists - skipping") - continue + print("XML file", xml_path, "already exists - skipping") + continue with open(xml_path, "w") as xml_f: xml_f.write(""" @@ -67,14 +67,14 @@ def write_xml_files(texture_paths, lit_suffix, overwrite): for object in texture_paths[ac_path][texture_path]: xml_f.write(" %s" % object) - xml_f.write(""" + xml_f.write(""" 1 - 1 + 1 1 %s - """ % texture_lit_path) - xml_f.write(""" + """ % texture_lit_path) + xml_f.write(""" material @@ -83,21 +83,21 @@ def write_xml_files(texture_paths, lit_suffix, overwrite): /sim/time/sun-angle-rad 1.49 - """) - + """) + for object in texture_paths[ac_path][texture_path]: xml_f.write(" %s" % object) - xml_f.write(""" - 0 - 0 - 0 - - %s""" % texture_path) - - xml_f.write("") - - xml_f.write("\n") + xml_f.write(""" + 0 + 0 + 0 + + %s""" % texture_path) + + xml_f.write("") + + xml_f.write("\n") def main(): argp = argparse.ArgumentParser()