diff --git a/README.md b/README.md index fca4721..dd140f4 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@

PyPI - GitHub release - Build Status + GitHub release + Build Status GEDCOM format version 5.5 Python versions 3.5 to 3.8

@@ -21,19 +21,19 @@ ## Documentation -Documentation can be found here: https://nickreynke.github.io/python-gedcom/gedcom/index.html +Documentation can be found here: https://joeyaurel.github.io/python-gedcom/gedcom/index.html ## Changelog For the latest changes please have a look at the [`CHANGELOG.md`](CHANGELOG.md) file. -The current development process can be tracked in the [develop branch](https://github.com/nickreynke/python-gedcom/tree/develop). +The current development process can be tracked in the [develop branch](https://github.com/joeyaurel/python-gedcom/tree/develop). ## Common problems * When you name your script `gedcom.py`, and import the `gedcom` module from this package, running your script won't work because Python will try to resolve imports like `gedcom.element.individual` from within your `gedcom.py` but - not from within the module from this package. Rename your file in this case. ([#26](https://github.com/nickreynke/python-gedcom/issues/26)) + not from within the module from this package. Rename your file in this case. ([#26](https://github.com/joeyaurel/python-gedcom/issues/26)) ## Local development @@ -75,14 +75,12 @@ Daniel Zappala at Brigham Young University (Copyright (C) 2005) which was licensed under the GPL v2 and then continued by [Mad Price Ball](https://github.com/madprime) in 2012. -The project was taken over by [Nicklas Reincke](https://github.com/nickreynke) in 2018. -Together with [Damon Brodie](https://github.com/nomadyow) a lot of changes were made and the parser was optimized. - ## License Licensed under the [GNU General Public License v2](http://www.gnu.org/licenses/gpl-2.0.html) **Python GEDCOM Parser** +
Copyright (C) 2024 Joey Aurel (hi at joeyaurel.dev)
Copyright (C) 2018 Damon Brodie (damon.brodie at gmail.com)
Copyright (C) 2018-2019 Nicklas Reincke (contact at reynke.com)
Copyright (C) 2016 Andreas Oberritter diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index 8f78040..0000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -gedcom.nickreynke.dev \ No newline at end of file diff --git a/gedcom/element/individual.py b/gedcom/element/individual.py index da61d08..709a63d 100644 --- a/gedcom/element/individual.py +++ b/gedcom/element/individual.py @@ -71,7 +71,7 @@ def is_private(self): for child in self.get_child_elements(): if child.get_tag() == gedcom.tags.GEDCOM_TAG_PRIVATE: private = child.get_value() - if private == 'Y': + if private == "Y": return True return False @@ -93,7 +93,7 @@ def get_name(self): # 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('/') + name = child.get_value().split("/") if len(name) > 0: given_name = name[0].strip() @@ -119,7 +119,11 @@ def get_name(self): return given_name, surname def get_all_names(self): - return [a.get_value() for a in self.get_child_elements() if a.get_tag() == gedcom.tags.GEDCOM_TAG_NAME] + return [ + a.get_value() + for a in self.get_child_elements() + if a.get_tag() == gedcom.tags.GEDCOM_TAG_NAME + ] def surname_match(self, surname_to_match): """Matches a string with the surname of an individual @@ -158,6 +162,17 @@ def get_gender(self): return gender + def get_sosadaboville(self): + """Returns the sosa daboville of a person in string format + :rtype: str + """ + # L'ajout du _SOSADABOVILLE est propre au logiciel Ancestris + sosadaboville = "" + for child in self.get_child_elements(): + if child.get_tag() == "_SOSADABOVILLE": + sosadaboville = child.get_value() + return sosadaboville + def get_birth_data(self): """Returns the birth data of a person formatted as a tuple: (`str` date, `str` place, `list` sources) :rtype: tuple @@ -289,8 +304,8 @@ def get_census_data(self): for child in self.get_child_elements(): if child.get_tag() == gedcom.tags.GEDCOM_TAG_CENSUS: - date = '' - place = '' + date = "" + place = "" sources = [] for childOfChild in child.get_child_elements(): @@ -334,6 +349,31 @@ def get_occupation(self): return occupation + def get_occupations(self): + """Returns a list of occupation of a person individual formatted as tuples: (`str` date, `str“ place, `str` occu) + :rtype: list of tuple + """ + occupations = [] + + for child in self.get_child_elements(): + if child.get_tag() == gedcom.tags.GEDCOM_TAG_OCCUPATION: + + date = "" + place = "" + occupation = child.get_value() + + for childOfChild in child.get_child_elements(): + + if childOfChild.get_tag() == gedcom.tags.GEDCOM_TAG_DATE: + date = childOfChild.get_value() + + if childOfChild.get_tag() == gedcom.tags.GEDCOM_TAG_PLACE: + place = childOfChild.get_value() + + occupations.append((date, place, occupation)) + + return occupations + def birth_year_match(self, year): """Returns `True` if the given year matches the birth year of this person :type year: int @@ -396,15 +436,15 @@ def criteria_match(self, criteria): # Check if criteria is a valid criteria and can be split by `:` and `=` characters try: - for criterion in criteria.split(':'): - criterion.split('=') + for criterion in criteria.split(":"): + criterion.split("=") except ValueError: return False match = True - for criterion in criteria.split(':'): - key, value = criterion.split('=') + for criterion in criteria.split(":"): + key, value = criterion.split("=") if key == "surname" and not self.surname_match(value): match = False @@ -422,7 +462,7 @@ def criteria_match(self, criteria): elif key == "birth_range": try: - from_year, to_year = value.split('-') + from_year, to_year = value.split("-") from_year = int(from_year) to_year = int(to_year) if not self.birth_range_match(from_year, to_year): @@ -442,7 +482,7 @@ def criteria_match(self, criteria): elif key == "death_range": try: - from_year, to_year = value.split('-') + from_year, to_year = value.split("-") from_year = int(from_year) to_year = int(to_year) if not self.death_range_match(from_year, to_year): diff --git a/gedcom/parser.py b/gedcom/parser.py index 74f40c7..904510a 100644 --- a/gedcom/parser.py +++ b/gedcom/parser.py @@ -276,6 +276,28 @@ def __build_list(self, element, element_list): self.__build_list(child, element_list) # Methods for analyzing individuals and relationships between individuals + def get_marriage(self, family:FamilyElement): + """Returns a marriage of a family formatted as a tuple (`str` date, `str` place) + :type family: FamilyElement + :rtype: tuple + """ + if not isinstance(family, FamilyElement): + raise NotAnActualFamilyError( + "Operation only valid for element with %s tag." % gedcom.tags.GEDCOM_TAG_FAMILY + ) + # Get and analyze family. + for family_data in family.get_child_elements(): + if family_data.get_tag() == gedcom.tags.GEDCOM_TAG_MARRIAGE: + date = '' + place = '' + for marriage_data in family_data.get_child_elements(): + if marriage_data.get_tag() == gedcom.tags.GEDCOM_TAG_DATE: + date = marriage_data.get_value() + if marriage_data.get_tag() == gedcom.tags.GEDCOM_TAG_PLACE: + place = marriage_data.get_value() + return ((date,place)) + return None + def get_marriages(self, individual): """Returns a list of marriages of an individual formatted as a tuple (`str` date, `str` place)