(script_path, sandbox)
| 86 | |
| 87 | |
| 88 | def CopyAircraftDef(script_path, sandbox): |
| 89 | # Get the aircraft name |
| 90 | tree = et.parse(script_path) |
| 91 | use_element = tree.getroot().find('use') |
| 92 | aircraft_name = use_element.attrib['aircraft'] |
| 93 | |
| 94 | # Then, create a directory aircraft/aircraft_name in the build directory |
| 95 | aircraft_path = os.path.join('aircraft', aircraft_name) |
| 96 | path_to_jsbsim_aircrafts = sandbox.path_to_jsbsim_file(aircraft_path) |
| 97 | aircraft_path = sandbox(aircraft_path) |
| 98 | if not os.path.exists(aircraft_path): |
| 99 | os.makedirs(aircraft_path) |
| 100 | |
| 101 | # Make a copy of the initialization file in |
| 102 | # build/.../aircraft/aircraft_name |
| 103 | IC_file = append_xml(use_element.attrib['initialize']) |
| 104 | shutil.copy(os.path.join(path_to_jsbsim_aircrafts, IC_file), aircraft_path) |
| 105 | |
| 106 | tree = et.parse(os.path.join(path_to_jsbsim_aircrafts, |
| 107 | aircraft_name+'.xml')) |
| 108 | |
| 109 | # The aircraft definition file may also load some data from external files. |
| 110 | # If so, we need to copy these files in our directory |
| 111 | # build/.../aircraft/aircraft_name Only the external files that are in the |
| 112 | # original directory aircraft/aircraft_name will be copied. The files |
| 113 | # located in 'engine' and 'systems' do not need to be copied. |
| 114 | for element in list(tree.getroot()): |
| 115 | if 'file' in element.keys(): |
| 116 | name = append_xml(element.attrib['file']) |
| 117 | name_with_path = os.path.join(path_to_jsbsim_aircrafts, name) |
| 118 | subdirs = os.path.split(name)[0] |
| 119 | if os.path.exists(name_with_path): |
| 120 | shutil.copy(name_with_path, os.path.join(aircraft_path, |
| 121 | subdirs)) |
| 122 | else: |
| 123 | name_with_system_path = os.path.join(path_to_jsbsim_aircrafts, |
| 124 | 'Systems', name) |
| 125 | print(name_with_system_path) |
| 126 | if os.path.exists(name_with_system_path): |
| 127 | system_path = sandbox(aircraft_path, 'Systems') |
| 128 | if not os.path.exists(system_path): |
| 129 | os.makedirs(system_path) |
| 130 | shutil.copy(name_with_system_path, |
| 131 | os.path.join(system_path, subdirs)) |
| 132 | |
| 133 | return tree, aircraft_name, path_to_jsbsim_aircrafts |
| 134 |
nothing calls this directly
no test coverage detected