Build a recursive data structure of all given component paths. For example: "trac.admin.web_ui.PluginAdminPanel" -> {"trac": {"admin": {"web_ui": "PluginAdminPanel": {}}}} "tracdjangoplugin.*" -> {"tracdjangoplugin": {"*": {}}} This will be used to determine if some config
(import_paths)
| 15 | |
| 16 | |
| 17 | def _build_component_tree(import_paths): |
| 18 | """ |
| 19 | Build a recursive data structure of all given component paths. For example: |
| 20 | |
| 21 | "trac.admin.web_ui.PluginAdminPanel" -> {"trac": {"admin": {"web_ui": "PluginAdminPanel": {}}}} |
| 22 | "tracdjangoplugin.*" -> {"tracdjangoplugin": {"*": {}}} |
| 23 | |
| 24 | This will be used to determine if some configured components are installed. |
| 25 | """ |
| 26 | tree = {} |
| 27 | for path in import_paths: |
| 28 | branch = tree |
| 29 | for node in path.split("."): |
| 30 | branch.setdefault(node, {}) |
| 31 | branch = branch[node] |
| 32 | |
| 33 | return tree |
| 34 | |
| 35 | |
| 36 | printerr = partial(print, file=sys.stderr) |
no outgoing calls