From 791bf033c6ea9a91951ca910e8e952a10a4e3072 Mon Sep 17 00:00:00 2001 From: romjerome Date: Fri, 11 Jun 2021 18:41:44 +0200 Subject: [PATCH] fix my mistake on spouses and descendants --- GeneanetForGramps.py | 85 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/GeneanetForGramps.py b/GeneanetForGramps.py index 2849af2..5b72118 100755 --- a/GeneanetForGramps.py +++ b/GeneanetForGramps.py @@ -103,7 +103,7 @@ ascendants = False descendants = False spouses = False -LEVEL = 4 +LEVEL = 2 ROOTURL = 'https://gw.geneanet.org/' GUIMODE = False progress = None @@ -846,6 +846,7 @@ def from_geneanet(self): self.g_marriageplace = self.father.marriageplace[idx] self.g_marriageplacecode = self.father.marriageplacecode[idx] for c in self.father.childref[idx]: + LOG.info(c) self.g_childref.append(c) if self.g_marriagedate and self.g_marriageplace and self.g_marriageplacecode: @@ -1305,26 +1306,24 @@ def random_headers(): marriage = [] for spouse in spouses: for a in spouse.xpath('a'): - sosa = a.find('img') - if sosa is None: - try: - sname.append(str(a.xpath('text()')[0]).title()) - if verbosity >= 2: - print(_("Spouse name:"), sname[s]) - except: - sname.append("") - try: - sref.append(str(a.xpath('attribute::href')[0])) - if verbosity >= 2: - print(_("Spouse ref:"), ROOTURL+sref[s]) - except: - sref.append("") - - if s in sref: - self.spouseref.append(ROOTURL+sref[s]) - else: - LOG.debug('index issue on spouseref "%s"' % sref) - + sref = a.xpath('attribute::href')[0] + LOG.debug(sref) + #sosa = a.find('img') + #if sosa is None: + #try: + #sname.append(str(a.xpath('text()')[0]).title()) + #if verbosity >= 2: + #print(_("Spouse name:"), sname[s]) + #except: + #sname.append("") + #try: + #sref.append(str(a.xpath('attribute::href')[0])) + #if verbosity >= 2: + #print(_("Spouse ref:"), ROOTURL+sref[s]) + #except: + #sref.append("") + + self.spouseref.append(ROOTURL+sref) try: marriage.append(str(spouse.xpath('em/text()')[0])) except: @@ -1359,31 +1358,33 @@ def random_headers(): for c in spouse.xpath('ul/li'): LOG.info(etree.tostring(c, method='xml', pretty_print=True)) for a in c.xpath('a'): - sosa = a.find('img') - if sosa is None: - try: - cname = c.xpath('a/text()')[0].title() - if verbosity >= 2: - print(_("Child %d name: %s")%(cnum, cname)) - except: - cname = str(uuid.uuid3(uuid.NAMESPACE_URL, str(cnum))) - LOG.debug(cname) - try: - cref = ROOTURL+str(a.xpath('attribute::href')[0]) - if verbosity >= 2: - print(_("Child %d ref: %s") %(cnum, cref)) - except: - cref = None - else: - LOG.info(etree.tostring(c, method='html', pretty_print=False)) - LOG.debug('Failed to set children %s' % cnum) + cref = a.xpath('attribute::href')[0] + LOG.debug(cref) + #sosa = a.find('img') + #if sosa is None: + #try: + #cname = c.xpath('a/text()')[0].title() + #if verbosity >= 2: + #print(_("Child %d name: %s")%(cnum, cname)) + #except: + #cname = str(uuid.uuid3(uuid.NAMESPACE_URL, str(cnum))) + #LOG.debug(cname) + #try: + #cref = ROOTURL+str(a.xpath('attribute::href')[0]) + #if verbosity >= 2: + #print(_("Child %d ref: %s") %(cnum, cref)) + #except: + #cref = None + #else: + #LOG.info(etree.tostring(c, method='html', pretty_print=False)) + #LOG.debug('Failed to set children %s' % cnum) - clist.append(cref) + clist.append(cref) cnum = cnum + 1 self.childref.append(clist) s = s + 1 # End spouse loop - LOG.info('clist %s' % clist) + LOG.info('clist %s' % clist) self.fref = "" self.mref = "" @@ -1395,7 +1396,7 @@ def random_headers(): LOG.info(p.text) for a in p.xpath('a'): pref = a.xpath('attribute::href')[0] - LOG.debug(pref[0]) + LOG.debug(pref) #if p.xpath('a'): #for a in p.xpath('a')[0]: #sosa = a.find('img')