From 62060f9c9c1c489bc3f6a83a0ff502e8fdb7ee9e Mon Sep 17 00:00:00 2001 From: dan-gut1 Date: Sat, 25 Feb 2023 16:08:36 +0200 Subject: [PATCH] fix result returned empty by adding result to function call --- automation_api_scripts/migrate_connections.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/automation_api_scripts/migrate_connections.py b/automation_api_scripts/migrate_connections.py index c82f9e5..519fbaa 100644 --- a/automation_api_scripts/migrate_connections.py +++ b/automation_api_scripts/migrate_connections.py @@ -15,14 +15,15 @@ class ConnectionData: target_resource: str -def _recursive_get_connections(children_resources: List[ResourceInfo]): +def _recursive_get_connections(children_resources: List[ResourceInfo], result: List=None): """ recursively get connections. No child resources is the base case :param list[ResourceInfo] children_resources: :param connections_list: :return: """ - result = [] + result = result if result else [] + for resource in children_resources: connections = resource.Connections children = resource.ChildResources @@ -31,7 +32,7 @@ def _recursive_get_connections(children_resources: List[ResourceInfo]): for connection in connections: result.append(ConnectionData(resource.Name, connection.FullPath)) else: - _recursive_get_connections(children) + _recursive_get_connections(children, result) return result