Fix an error when changes.json doesn't return datas (status code 204)
authorBenoît Fontaine <benoitfontaine.ba@gmail.com>
Sat, 10 Nov 2018 19:03:56 +0000 (20:03 +0100)
committerBenoît Fontaine <benoitfontaine.ba@gmail.com>
Sat, 10 Nov 2018 19:03:56 +0000 (20:03 +0100)
getmyancestors.py

index 5ff62a74ff5755319a52499cc4dafe5169ef7cae..244ac795d1ff09ecace699036a6a371c57748f68 100755 (executable)
@@ -558,9 +558,10 @@ class Indi:
     def get_contributors(self):
         temp = set()
         data = self.tree.fs.get_url('/platform/tree/persons/%s/changes.json' % self.fid)
-        for entries in data['entries']:
-            for contributors in entries['contributors']:
-                temp.add(contributors['name'])
+        if data:
+            for entries in data['entries']:
+                for contributors in entries['contributors']:
+                    temp.add(contributors['name'])
         if temp:
             text = '=== ' + self.tree.fs._('Contributors') + ' ===\n' + '\n'.join(sorted(temp))
             for n in self.tree.notes:
@@ -678,9 +679,10 @@ class Fam:
         if self.fid:
             temp = set()
             data = self.tree.fs.get_url('/platform/tree/couple-relationships/%s/changes.json' % self.fid)
-            for entries in data['entries']:
-                for contributors in entries['contributors']:
-                    temp.add(contributors['name'])
+            if data:
+                for entries in data['entries']:
+                    for contributors in entries['contributors']:
+                        temp.add(contributors['name'])
             if temp:
                 text = '=== ' + self.tree.fs._('Contributors') + ' ===\n' + '\n'.join(sorted(temp))
                 for n in self.tree.notes: