feat: add source parsing and linking #8
No files matched your search
@@ -57,6 +57,18 @@ class Individual:
|
|||||||
"""
|
"""
|
||||||
return self.element.get_pointer()
|
return self.element.get_pointer()
|
||||||
|
|
||||||
|
def get_fs_id(self) -> str:
|
||||||
|
"""
|
||||||
|
Return the FamilySearch Tree ID (`_FSFTID`) if present.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: FamilySearch Tree ID value, or an empty string when not available.
|
||||||
|
"""
|
||||||
|
for child in self.element.get_child_elements():
|
||||||
|
if child.get_tag() == "_FSFTID":
|
||||||
|
return child.get_value() or ""
|
||||||
|
return ""
|
||||||
|
|
||||||
def get_names(self) -> Tuple[str, str]:
|
def get_names(self) -> Tuple[str, str]:
|
||||||
"""
|
"""
|
||||||
Return the individual's first and last name with surrounding whitespace removed.
|
Return the individual's first and last name with surrounding whitespace removed.
|
||||||
|
|||||||
@@ -136,8 +136,11 @@ class MarkdownGenerator:
|
|||||||
|
|
||||||
birth = individual.get_birth_info()
|
birth = individual.get_birth_info()
|
||||||
death = individual.get_death_info()
|
death = individual.get_death_info()
|
||||||
|
fs_id = individual.get_fs_id()
|
||||||
|
|
||||||
f.write(f"ID: {individual.get_id()}\n")
|
f.write(f"ID: {individual.get_id()}\n")
|
||||||
|
if fs_id:
|
||||||
|
f.write(f"FamilySearch ID: {fs_id}\n")
|
||||||
f.write(f"Name: {individual.get_full_name()}\n")
|
f.write(f"Name: {individual.get_full_name()}\n")
|
||||||
|
|
||||||
# Lived years
|
# Lived years
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ def sample_gedcom_content():
|
|||||||
1 NAME John /Doe/
|
1 NAME John /Doe/
|
||||||
2 GIVN John
|
2 GIVN John
|
||||||
2 SURN Doe
|
2 SURN Doe
|
||||||
|
1 _FSFTID G123-ABC
|
||||||
1 SEX M
|
1 SEX M
|
||||||
1 BIRT
|
1 BIRT
|
||||||
2 DATE 1 JAN 1950
|
2 DATE 1 JAN 1950
|
||||||
|
|||||||
@@ -81,6 +81,15 @@ class TestIndividualBasicInfo:
|
|||||||
"""Test gender extraction."""
|
"""Test gender extraction."""
|
||||||
assert john_doe.get_gender() == 'M'
|
assert john_doe.get_gender() == 'M'
|
||||||
|
|
||||||
|
def test_get_fs_id(self, john_doe, sample_gedcom_file):
|
||||||
|
"""Test FamilySearch Tree ID extraction from _FSFTID tag."""
|
||||||
|
assert john_doe.get_fs_id() == 'G123-ABC'
|
||||||
|
parser = GedcomParser(sample_gedcom_file)
|
||||||
|
individuals = parser.get_individuals()
|
||||||
|
jane = [ind for ind in individuals if 'Jane' in str(ind.get_name())]
|
||||||
|
jane_doe = Individual(jane[0], parser.parser)
|
||||||
|
assert jane_doe.get_fs_id() == ''
|
||||||
|
|
||||||
def test_get_gender_default_unknown(self, sample_gedcom_file):
|
def test_get_gender_default_unknown(self, sample_gedcom_file):
|
||||||
"""Test that missing gender defaults to 'U'."""
|
"""Test that missing gender defaults to 'U'."""
|
||||||
gedcom_content = """0 HEAD
|
gedcom_content = """0 HEAD
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ class TestMetadataFormatting:
|
|||||||
|
|
||||||
# Check for YAML frontmatter metadata
|
# Check for YAML frontmatter metadata
|
||||||
assert 'ID: I1' in content
|
assert 'ID: I1' in content
|
||||||
|
assert 'FamilySearch ID: G123-ABC' in content
|
||||||
assert 'Name: John Doe' in content
|
assert 'Name: John Doe' in content
|
||||||
assert 'Sex: M' in content
|
assert 'Sex: M' in content
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user