scripts: set_assignees: handle the documentation + unmaintained case

The script right now assumes that all the areas have a maintainer and
that the second area in particular has one in case of Documentation,
that results in a ValueError when it's not the case. Handle that by
checking the lists before using them.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
diff --git a/scripts/set_assignees.py b/scripts/set_assignees.py
index bc23451..9649645 100755
--- a/scripts/set_assignees.py
+++ b/scripts/set_assignees.py
@@ -93,9 +93,12 @@
     log(f"Submitted by: {pr.user.login}")
     log(f"candidate maintainers: {sm}")
 
+    maintainer = "None"
+    maintainers = list(sm.keys())
+
     prop = 0
-    if sm:
-        maintainer = list(sm.keys())[0]
+    if maintainers:
+        maintainer = maintainers[0]
 
         if len(ac) > 1 and list(ac.values())[0] == list(ac.values())[1]:
             log("++ Platform/Drivers takes precedence over subsystem...")
@@ -103,8 +106,10 @@
                 if 'Documentation' in aa:
                     log("++ With multiple areas of same weight including docs, take something else other than Documentation as the maintainer")
                     for a in all_areas:
-                        if a.name == aa and a.maintainers[0] == maintainer:
-                            maintainer = list(sm.keys())[1]
+                        if (a.name == aa and
+                            a.maintainers and a.maintainers[0] == maintainer and
+                            len(maintainers) > 1):
+                            maintainer = maintainers[1]
                 elif 'Platform' in aa:
                     log(f"Set maintainer of area {aa}")
                     for a in all_areas:
@@ -129,8 +134,7 @@
         prop = (maint[maintainer] / num_files) * 100
         if prop < 20:
             maintainer = "None"
-    else:
-        maintainer = "None"
+
     log(f"Picked maintainer: {maintainer} ({prop:.2f}% ownership)")
     log("+++++++++++++++++++++++++")