From: Benoît Fontaine Date: Mon, 15 Jan 2018 09:03:01 +0000 (+0100) Subject: Ordinances: add status Ready and Infant X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=67a5e681cf21f6e24e301db508b6bd60a2f45bd3;p=gamesguru%2Fgetmyancestors.git Ordinances: add status Ready and Infant --- diff --git a/README.md b/README.md index c5af6b4..78ba6c1 100644 --- 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 ======== diff --git a/getmyancestors.py b/getmyancestors.py index ec70470..d23b9c8 100755 --- a/getmyancestors.py +++ b/getmyancestors.py @@ -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 diff --git a/mergemyancestors.py b/mergemyancestors.py index 44888b1..2582d6f 100755 --- a/mergemyancestors.py +++ b/mergemyancestors.py @@ -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: diff --git a/fsearch_translation.py b/translation.py similarity index 98% rename from fsearch_translation.py rename to translation.py index 7658605..b615756 100644 --- a/fsearch_translation.py +++ b/translation.py @@ -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',