class Fact:
def __init__(self, data=None):
- self.value = ''
- self.date = self.place = self.note = None
+ self.value = self.type = self.date = self.place = self.note = None
if data:
- self.value = data['value']
+ if 'value' in data:
+ self.value = data['value']
+ if 'type' in data:
+ self.type = data['type']
if 'date' in data:
self.date = data['date']['original']
if 'place' in data:
self.date = data['date']['formal']
if 'templeCode' in data:
self.temple_code = data['templeCode']
- if data['status'] == 'http://familysearch.org/v1/Completed':
+ if data['status'] == u'http://familysearch.org/v1/Completed':
self.status = 'COMPLETED'
- if data['status'] == 'http://familysearch.org/v1/Cancelled':
+ if data['status'] == u'http://familysearch.org/v1/Cancelled':
self.status = 'CANCELED'
- if data['status'] == 'http://familysearch.org/v1/InProgress':
+ if data['status'] == u'http://familysearch.org/v1/InProgress':
self.status = 'SUBMITTED'
def print(self, file=sys.stdout):
data = fs.get_url(url)['persons'][0]['ordinances']
if data:
for o in data:
- if o['type'] == 'http://lds.org/Baptism':
+ if o['type'] == u'http://lds.org/Baptism':
self.baptism = Ordinance(o)
- if o['type'] == 'http://lds.org/Confirmation':
+ if o['type'] == u'http://lds.org/Confirmation':
self.confirmation = Ordinance(o)
- if o['type'] == 'http://lds.org/Endowment':
+ if o['type'] == u'http://lds.org/Endowment':
self.endowment = Ordinance(o)
- if o['type'] == 'http://lds.org/SealingChildToParents':
+ if o['type'] == u'http://lds.org/SealingChildToParents':
self.sealing_child = Ordinance(o)
# retrieve parents
self.num = Fam.counter
self.husb_fid = husb if husb else None
self.wife_fid = wife if wife else None
- self.husb_num = self.wife_num = self.fid = self.marrdate = self.marrplac = None
+ self.husb_num = self.wife_num = self.fid = None
+ self.marriage_facts = set()
self.sealing_spouse = None
self.chil_fid = set()
self.chil_num = set()
url = 'https://familysearch.org/platform/tree/couple-relationships/' + self.fid + '.json'
data = fs.get_url(url)
if data and 'facts' in data['relationships'][0]:
- x = data['relationships'][0]['facts'][0]
- self.marrdate = x['date']['original'] if 'date' in x and 'original' in x['date'] else None
- self.marrplac = x['place']['original'] if 'place' in x and 'original' in x['place'] else None
- else:
- self.marrdate = self.marrplac = None
- notes = fs.get_url(data['relationships'][0]['links']['notes']['href'])
- if notes:
- for n in notes['relationships'][0]['notes']:
- self.notes.add(Note('===' + n['subject'] + '===\n' + n['text'] + '\n'))
+ for x in data['relationships'][0]['facts']:
+ self.marriage_facts.add(Fact(x))
if data and 'sources' in data['relationships'][0]:
for y in data['relationships'][0]['sources']:
json = fs.get_url(y['links']['description']['href'])['sourceDescriptions'][0]
self.sources.add((Source.add_source(json), y['attribution']['changeMessage']))
else:
self.sources.add((Source(json),))
+ notes = fs.get_url(data['relationships'][0]['links']['notes']['href'])
+ if notes:
+ for n in notes['relationships'][0]['notes']:
+ self.notes.add(Note('===' + n['subject'] + '===\n' + n['text'] + '\n'))
# retrieve and add LDS ordinances
def add_ordinance(self):
file.write('1 WIFE @I' + str(self.wife_num) + '@\n')
for num in self.chil_num:
file.write('1 CHIL @I' + str(num) + '@\n')
- if self.marrdate or self.marrplac:
- file.write('1 MARR\n')
- if self.marrdate:
- file.write('2 DATE ' + self.marrdate + '\n')
- if self.marrplac:
- file.write('2 PLAC ' + self.marrplac + '\n')
+ for o in self.marriage_facts:
+ if o.type == u'http://gedcomx.org/Marriage':
+ file.write('1 MARR\n')
+ if o.type == u'http://gedcomx.org/Divorce':
+ file.write('1 DIV\n')
+ if o.type == u'http://gedcomx.org/Annulment':
+ file.write('1 ANUL\n')
+ if o.type == u'http://gedcomx.org/CommonLawMarriage':
+ file.write('1 _COML\n')
+ if o.date:
+ file.write('2 DATE ' + o.date + '\n')
+ if o.place:
+ file.write('2 PLAC ' + o.place + '\n')
if self.sealing_spouse:
file.write('1 SLGS\n')
self.sealing_spouse.print(file)
self.fam[self.num].wife_num = int(self.data[2:len(self.data) - 1])
elif self.tag == 'CHIL':
self.fam[self.num].chil_num.add(int(self.data[2:len(self.data) - 1]))
- elif self.tag == 'MARR':
- self.__get_marr()
+ elif self.tag in ('MARR', 'DIV', 'ANUL', '_COML'):
+ self.fam[self.num].marriage_facts.add(self.__get_marr())
elif self.tag == 'SLGS':
self.fam[self.num].sealing_spouse = self.__get_ordinance()
elif self.tag == '_FSFTID':
self.flag = True
def __get_marr(self):
+ fact = Fact()
+ if self.tag == 'MARR':
+ fact.type = 'http://gedcomx.org/Marriage'
+ elif self.tag == 'DIV':
+ fact.type = 'http://gedcomx.org/Divorce'
+ elif self.tag == 'ANUL':
+ fact.type = 'http://gedcomx.org/Annulment'
+ elif self.tag == '_COML':
+ fact.type = 'http://gedcomx.org/CommonLawMarriage'
while self.__get_line() and self.level > 1:
if self.tag == 'DATE':
- self.fam[self.num].marrdate = self.data
+ fact.date = self.data
elif self.tag == 'PLAC':
- self.fam[self.num].marrplac = self.data
+ fact.place = self.data
+ elif self.tag == 'NOTE':
+ num = int(self.data[2:len(self.data) - 1])
+ self.note[num] = Note(num=num)
+ fact.note = (self.note[num])
self.flag = True
+ return fact
def __get_fact(self):
fact = Fact()
tree.fam[(husb, wife)] = Fam(husb, wife, fam_counter)
tree.fam[(husb, wife)].chil_fid |= ged.fam[num].chil_fid
tree.fam[(husb, wife)].fid = ged.fam[num].fid
- tree.fam[(husb, wife)].marrdate = ged.fam[num].marrdate
- tree.fam[(husb, wife)].marrplac = ged.fam[num].marrplac
+ tree.fam[(husb, wife)].marriage_facts = ged.fam[num].marriage_facts
tree.fam[(husb, wife)].notes = ged.fam[num].notes
tree.fam[(husb, wife)].sources = ged.fam[num].sources
tree.fam[(husb, wife)].sealing_spouse = ged.fam[num].sealing_spouse