repo: Update get_projects_from_devices() to support yaml anchors

Change-Id: Ia371f530ae0fbeab4cc831e003eaebed67a864e5
diff --git a/repo/repo_settings.py b/repo/repo_settings.py
index bbb2e9e..1bd7194 100755
--- a/repo/repo_settings.py
+++ b/repo/repo_settings.py
@@ -165,15 +165,19 @@
 
 def get_projects_from_devices(device, branch):
     projects = []
-
     with open(leaf_devices) as f:
         root = yaml.safe_load(f)
 
     for item in root:
-        if device in item["device"]:
-            for repository in item["repositories"]:
-                projects.append({"name": repository["name"], "revision": branch})
-
+        if "device" in item and "repositories" in item and device in item["device"]:
+            for repo_list in item["repositories"]:
+                if isinstance(repo_list, list):
+                    for repository in repo_list:
+                        projects.append(
+                            {"name": repository["name"], "revision": branch}
+                        )
+                else:
+                    projects.append({"name": repo_list["name"], "revision": branch})
     return projects