diff --git a/README.md b/README.md index d0a08b6..6f7d11a 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ is_private | none | Boolean | Returns True if the record is is_deceased | none | Boolean | Returns True if the individual is marked deceased criteria_match | colon separated string "surname=[name]:name=[name]:birth][year]:birth_range=[year-to-year]:death=[year]:death_range[year-to-year]"| Boolean | Returns True if the criteria matches surname_match | String | Boolean | Returns True if substring matches -given_match | String | Boolean | Returns True if subscring matches +given_match | String | Boolean | Returns True if substring matches death_range_match | Int from, Int to | Boolean | Returns True if Death Year is in the supplied range death_year_match | Int | Boolean | Returns True if Death Year equals parameter birth_range_match | Int from, Int to | Boolean | Returns True if Birth Year is in the supplied range @@ -144,11 +144,15 @@ Further updates by [Nicklas Reincke](https://github.com/nickreynke) and [Damon B ## Changelog +**v0.2.3dev** +- Assemble Marriages properly ([#9](https://github.com/nickreynke/python-gedcom/issues/9)) +- Return the top NAME record instead of the last one ([#9](https://github.com/nickreynke/python-gedcom/issues/9)) + **v0.2.2dev** -- Support BOM control characters +- Support BOM control characters ([#5](https://github.com/nickreynke/python-gedcom/issues/5)) - Support the last line not having a CR and/or LF -- Support incorrect line splitting generated by Ancestry. Insert CONT/CONC tag as necessary +- Support incorrect line splitting generated by Ancestry. Insert CONT/CONC tag as necessary ([#6](https://github.com/nickreynke/python-gedcom/issues/6)) **v0.2.1dev** diff --git a/gedcom/__init__.py b/gedcom/__init__.py index a775f6e..838cd3d 100644 --- a/gedcom/__init__.py +++ b/gedcom/__init__.py @@ -346,14 +346,14 @@ def get_marriages(self, individual): for family in families: for family_data in family.get_child_elements(): if family_data.get_tag() == GEDCOM_TAG_MARRIAGE: + date = '' + place = '' for marriage_data in family_data.get_child_elements(): - date = '' - place = '' if marriage_data.get_tag() == GEDCOM_TAG_DATE: date = marriage_data.get_value() if marriage_data.get_tag() == GEDCOM_TAG_PLACE: place = marriage_data.get_value() - marriages.append((date, place)) + marriages.append((date, place)) return marriages def get_marriage_years(self, individual): @@ -917,9 +917,14 @@ def get_name(self): last = "" if not self.is_individual(): return first, last + + # Return the first GEDCOM_TAG_NAME that is found. Alternatively + # as soon as we have both the GETCOM_TAG_GIVEN_NAME and _SURNAME return those + found_given_name = False + found_surname_name = False for child in self.get_child_elements(): if child.get_tag() == GEDCOM_TAG_NAME: - # some older GEDCOM files don't use child tags but instead + # some GEDCOM files don't use child tags but instead # place the name in the value of the NAME tag if child.get_value() != "": name = child.get_value().split('/') @@ -927,12 +932,19 @@ def get_name(self): first = name[0].strip() if len(name) > 1: last = name[1].strip() + return first, last else: for childOfChild in child.get_child_elements(): if childOfChild.get_tag() == GEDCOM_TAG_GIVEN_NAME: first = childOfChild.get_value() + found_given_name = True if childOfChild.get_tag() == GEDCOM_TAG_SURNAME: last = childOfChild.get_value() + found_surname_name = True + if found_given_name and found_surname_name: + return first, last + + # If we reach here we are probably returning empty strings return first, last def get_gender(self): diff --git a/setup.py b/setup.py index 5266523..525f9da 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='python-gedcom', - version='0.2.2dev', + version='0.2.3dev', packages=['gedcom', ], license='GPLv2', package_dir={'': '.'},