MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / _generate_cpp_plugin_list

Function _generate_cpp_plugin_list

scripts/configure_plugins.py:186–214  ·  view source on GitHub ↗

Generate the PluginList.cpp source file. Args: plugin_list_full_path (str): Full path to PluginList.cpp where it shall be created. plugin_list (list): List of all plugin names.

(plugin_list_full_path, plugin_list)

Source from the content-addressed store, hash-verified

184 file_desc.write("];\n")
185
186def _generate_cpp_plugin_list(plugin_list_full_path, plugin_list):
187 """Generate the PluginList.cpp source file.
188
189 Args:
190 plugin_list_full_path (str): Full path to PluginList.cpp where it shall be created.
191 plugin_list (list): List of all plugin names.
192 """
193 includes = ""
194 list_entries = ""
195
196 for idx, plugin_name in enumerate(plugin_list):
197 if 0 < idx:
198 includes += "\n"
199 list_entries += ",\n"
200
201 includes += f"#include <{plugin_name}.h>"
202 list_entries += f" {{ \"{plugin_name}\", {plugin_name}::create }}"
203
204 data = {
205 "INCLUDES": includes,
206 "LIST_ENTRIES": list_entries
207 }
208
209 with open(_PLUGIN_LIST_TEMPLATE_FULL_PATH, "r", encoding="utf-8") as file_desc:
210 src = Template(file_desc.read())
211 result = src.substitute(data)
212
213 with open(plugin_list_full_path, "w", encoding="utf-8") as file_desc:
214 file_desc.write(result)
215
216def configure_plugins(plugin_list, layout):
217 """Handle all plugin related artifacts.

Callers 1

configure_pluginsFunction · 0.85

Calls 2

readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected