]> Nutra Git (v1) - gamesguru/getmyancestors.git/commitdiff
Ordinances: add status Ready and Infant
authorBenoît Fontaine <benoitfontaine.ba@gmail.com>
Mon, 15 Jan 2018 09:03:01 +0000 (10:03 +0100)
committerBenoît Fontaine <benoitfontaine.ba@gmail.com>
Mon, 15 Jan 2018 09:03:01 +0000 (10:03 +0100)
README.md
getmyancestors.py
mergemyancestors.py
translation.py [moved from fsearch_translation.py with 98% similarity]

index c5af6b4a793a8fc12ef0190145b1f3fbd4a2488d..78ba6c1de142e6409a983ad7a01f843eb34b8c6a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ This script requires python 3.4 (or higher) to run due to some novel features in
 
 To download the script, click on the green button "Clone or download" on the top of this page and then click on "Download ZIP".
 
-Current version was updated on January 11th 2018.
+Current version was updated on January 15th 2018.
 
 Examples
 ========
index ec70470ea44d53e530b5872933290f85843d3320..d23b9c8e5d275d65a0dbcb6236bdc83d25a65f9d 100755 (executable)
@@ -31,7 +31,7 @@ import asyncio
 import re
 
 # local import
-from fsearch_translation import translations
+from translation import translations
 
 try:
     import requests
@@ -74,6 +74,14 @@ FACT_EVEN = {
     'http://familysearch.org/v1/TribeName': 'Tribe Name'
 }
 
+ORDINANCES_STATUS = {
+    'http://familysearch.org/v1/Ready': 'QUALIFIED',
+    'http://familysearch.org/v1/Completed': 'COMPLETED',
+    'http://familysearch.org/v1/Cancelled': 'CANCELED',
+    'http://familysearch.org/v1/InProgress': 'SUBMITTED',
+    'http://familysearch.org/v1/NotNeeded': 'INFANT'
+}
+
 
 def cont(level, string):
     return re.sub(r'[\r\n]+', '\n' + str(level) + ' CONT ', string)
@@ -211,7 +219,10 @@ class Session:
                 time.sleep(self.timeout)
                 continue
             self.write_log('Status code: %s\n' % str(r.status_code))
-            if r.status_code in {204, 404, 405, 410}:
+            if r.status_code == 204:
+                return None
+            if r.status_code in {404, 405, 410, 500}:
+                self.write_log('WARNING: ' + url)
                 return None
             if r.status_code == 401:
                 self.login()
@@ -436,20 +447,15 @@ class Ordinance:
                 self.date = data['date']['formal']
             if 'templeCode' in data:
                 self.temple_code = data['templeCode']
-            if data['status'] == u'http://familysearch.org/v1/Completed':
-                self.status = 'COMPLETED'
-            if data['status'] == u'http://familysearch.org/v1/Cancelled':
-                self.status = 'CANCELED'
-            if data['status'] == u'http://familysearch.org/v1/InProgress':
-                self.status = 'SUBMITTED'
+            self.status = data['status']
 
     def print(self, file=sys.stdout):
         if self.date:
             file.write('2 DATE ' + self.date + '\n')
         if self.temple_code:
             file.write('2 TEMP ' + self.temple_code + '\n')
-        if self.status:
-            file.write('2 STAT ' + self.status + '\n')
+        if self.status in ORDINANCES_STATUS:
+            file.write('2 STAT ' + ORDINANCES_STATUS[self.status] + '\n')
         if self.famc:
             file.write('2 FAMC @F' + str(self.famc.num) + '@\n')
 
@@ -819,7 +825,8 @@ class Tree:
         async def add(loop, rels):
             futures = set()
             for father, mother, relfid in rels:
-                futures.add(loop.run_in_executor(None, self.fam[(father, mother)].add_marriage, relfid))
+                if (father, mother) in self.fam:
+                    futures.add(loop.run_in_executor(None, self.fam[(father, mother)].add_marriage, relfid))
             for future in futures:
                 await future
 
index 44888b12c38f29766f5e47ffc0fb400c71dbd6a5..2582d6f46eefc926959bc0ce95b3a9653ff2045c 100755 (executable)
@@ -29,14 +29,17 @@ import sys
 import argparse
 
 # local import
-from getmyancestors import FACT_TAGS, Indi, Fam, Tree, Name, Note, Fact, Source, Ordinance, Memorie
+from getmyancestors import *
 
 sys.path.append(os.path.dirname(sys.argv[0]))
 
-FACT_TYPES = dict()
 
-for key, value in FACT_TAGS.items():
-    FACT_TYPES[value] = key
+def reversed_dict(d):
+    return {val: key for key, val in d.items()}
+
+
+FACT_TYPES = reversed_dict(FACT_TAGS)
+ORDINANCES = reversed_dict(ORDINANCES_STATUS)
 
 
 class Gedcom:
@@ -293,7 +296,7 @@ class Gedcom:
             elif self.tag == 'TEMP':
                 ordinance.temple_code = self.data
             elif self.tag == 'STAT':
-                ordinance.status = self.data
+                ordinance.status = ORDINANCES[self.data]
             elif self.tag == 'FAMC':
                 num = int(self.data[2:len(self.data) - 1])
                 if num not in self.fam:
similarity index 98%
rename from fsearch_translation.py
rename to translation.py
index 76586051550fb0fcfaa7d7037f2b588d608cfede..b615756261bab4a97eac89b6a91f9692fc5be8a5 100644 (file)
@@ -108,7 +108,7 @@ translations = {
         'fr': 'e génération de descendants...',
     },
     'Download spouses and marriage information...': {
-        'fr': 'Téléchargement des conjoints de des information de mariage...',
+        'fr': 'Téléchargement des conjoints et des informations de mariage...',
     },
     'Download notes': {
         'fr': 'Téléchargement des notes',