From e749210de241426b07c1166ef022184bbee3b598 Mon Sep 17 00:00:00 2001 From: Kees Bakker Date: Thu, 3 Jul 2008 21:05:06 +0000 Subject: [PATCH] Use list comprehension instead of filter(lambda as suggested by Gerald. * src/plugins/ImportProGen.py svn: r10841 --- src/plugins/ImportProGen.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/plugins/ImportProGen.py b/src/plugins/ImportProGen.py index 7e9ae5f77..224b660d0 100644 --- a/src/plugins/ImportProGen.py +++ b/src/plugins/ImportProGen.py @@ -757,8 +757,7 @@ class ProgenParser: per_klad = recflds[per_klad_ix] per_info = recflds[per_info_ix] - - note_txt = filter(lambda x: x, [per_info, per_klad]) + note_txt = [x for x in [per_info, per_klad] if x] if note_txt: note = gen.lib.Note() note.set('\n'.join(note_txt)) @@ -804,7 +803,7 @@ class ProgenParser: source_text = recflds[birth_source_text_ix] info = recflds[birth_info_ix] if date or place or info or srcref: - desc = filter(lambda x: x, [info, time, source_text]) + desc = [x for x in [info, time, source_text] if x] desc = desc and '; '.join(desc) or None event, birth_ref = self.__create_event_and_ref(gen.lib.EventType.BIRTH, desc, date, place, srcref) person.set_birth_ref(birth_ref) @@ -827,7 +826,7 @@ class ProgenParser: source_text = recflds[bapt_source_text_ix] info = recflds[bapt_info_ix] if date or place or info or srcref or reli or witness: - desc = filter(lambda x: x, [reli, info, source_text]) + desc = [x for x in [reli, info, source_text] if x] desc = desc and '; '.join(desc) or None event, bapt_ref = self.__create_event_and_ref(gen.lib.EventType.BAPTISM, desc, date, place, srcref) person.add_event_ref(bapt_ref) @@ -863,7 +862,7 @@ class ProgenParser: source_text = recflds[death_source_text_ix] info = recflds[death_info_ix] if date or place or info or srcref: - desc = filter(lambda x: x, [info, time, source_text]) + desc = [x for x in [info, time, source_text] if x] desc = desc and '; '.join(desc) or None event, death_ref = self.__create_event_and_ref(gen.lib.EventType.DEATH, desc, date, place, srcref) person.set_death_ref(death_ref) @@ -884,7 +883,7 @@ class ProgenParser: source_text = recflds[bur_source_text_ix] info = recflds[bur_info_ix] if date or place or info or srcref: - desc = filter(lambda x: x, [info, source_text]) + desc = [x for x in [info, source_text] if x] desc = desc and '; '.join(desc) or None event, burial_ref = self.__create_event_and_ref(gen.lib.EventType.BURIAL, desc, date, place, srcref) person.add_event_ref(burial_ref) @@ -906,7 +905,7 @@ class ProgenParser: info = recflds[crem_info_ix] if date or place or info or srcref: # TODO. Check that not both burial and cremation took place. - desc = filter(lambda x: x, [info, source_text]) + desc = [x for x in [info, source_text] if x] desc = desc and '; '.join(desc) or None event, cremation_ref = self.__create_event_and_ref(gen.lib.EventType.CREMATION, desc, date, place, srcref) person.add_event_ref(cremation_ref) @@ -1019,7 +1018,7 @@ class ProgenParser: rel_klad = recflds[rel_klad_ix] rel_info = recflds[rel_info_ix] - note_txt = filter(lambda x: x, [rel_info, rel_klad]) + note_txt = [x for x in [rel_info, rel_klad] if x] if note_txt: note = gen.lib.Note() note.set('\n'.join(note_txt)) @@ -1040,7 +1039,7 @@ class ProgenParser: source_text = recflds[mar_source_text_ix] info = recflds[mar_info_ix] if date or place or info or srcref: - desc = filter(lambda x: x, [info, source_text]) + desc = [x for x in [info, source_text] if x] desc = desc and '; '.join(desc) or None event, mar_ref = self.__create_event_and_ref(gen.lib.EventType.MARRIAGE, desc, date, place, srcref) fam.add_event_ref(mar_ref) @@ -1072,7 +1071,7 @@ class ProgenParser: source_text = recflds[marc_source_text_ix] info = recflds[marc_info_ix] if date or place or info or srcref: - desc = filter(lambda x: x, [reli, info, source_text]) + desc = [x for x in [reli, info, source_text] if x] desc.insert(0, 'Kerkelijk huwelijk') desc = desc and '; '.join(desc) or None event, marc_ref = self.__create_event_and_ref(gen.lib.EventType.MARRIAGE, desc, date, place, srcref) @@ -1104,7 +1103,7 @@ class ProgenParser: source_text = recflds[marl_source_text_ix] info = recflds[marl_info_ix] if date or place or info or srcref: - desc = filter(lambda x: x, [info, source_text]) + desc = [x for x in [info, source_text] if x] desc.insert(0, 'Ondertrouw') desc = desc and '; '.join(desc) or None event, marl_ref = self.__create_event_and_ref(gen.lib.EventType.MARR_LIC, desc, date, place, srcref) @@ -1132,7 +1131,7 @@ class ProgenParser: source_text = recflds[civu_source_text_ix] info = recflds[civu_info_ix] if date or place or info or srcref: - desc = filter(lambda x: x, [info, source_text]) + desc = [x for x in [info, source_text] if x] desc.insert(0, 'Samenwonen') desc = desc and '; '.join(desc) or None event, civu_ref = self.__create_event_and_ref(gen.lib.EventType.UNKNOWN, desc, date, place, srcref) @@ -1156,7 +1155,7 @@ class ProgenParser: source_text = recflds[div_source_text_ix] info = recflds[div_info_ix] if date or place or info or srcref: - desc = filter(lambda x: x, [info, source_text]) + desc = [x for x in [info, source_text] if x] desc = desc and '; '.join(desc) or None event, div_ref = self.__create_event_and_ref(gen.lib.EventType.DIVORCE, desc, date, place, srcref) fam.add_event_ref(div_ref)