记录家谱的包裹。
genealog的Python项目详细描述
谱系学
一个包,用于记录人类和机器可读的.json文件中的系谱。json文件格式已被选中,而不是gedcom文件格式,以便更好地访问和互操作记录的数据。包将在当前工作目录中创建.json记录。
日期是ISO格式,最少需要一年。约'日期不接受。
需要Python3.7+。
安装
pip install genealogy
用法
创建一个人
>>> p = genealogy.person()
>>> p.create(fn=["Joe"], ln=["BLOGGS"], dob="1900-1-1", pob="Town, County")
>>> p.print()
{
"id": "a1b2c3",
"last_names": ["BLOGGS"],
"first_names": ["Joe"],
"date_of_birth": "1900-1-1",
"place_of_birth": "Town, County",
"date_of_death": null,
"place_of_death": null,
"direct_relatives": {
"ascendants": [],
"descendants": [],
"partners": []
},
"life_events": [
{
"start": "1900-1-1",
"finish": null,
"title": "Lifetime',
"description": null,
"notes": null,
"sources": []
}
]
}
>>> p.data['date_of_death'] = "1970-1-1"
>>> p.save()
a1b2c3.json saved.
载人
>>> p = genealogy.person(load='a1b2c3')
>>> p.print()
{
"id": "a1b2c3",
"last_names": ["BLOGGS"],
"first_names": ["Joe"],
"date_of_birth": "1900-1-1",
"place_of_birth": "Town, County",
"date_of_death": "1970-1-1",
"place_of_death": null,
"direct_relatives": {
"ascendants": [],
"descendants": [],
"partners": []
},
"life_events": [
{
"start": "1900-1-1",
"finish": null,
"title": "Lifetime',
"description": null,
"notes": null,
"sources": []
}
]
}
添加生活事件
>>> p = genealogy.person(load="a1b2c3")
>>> p.add_event(
start="1900-1-1",
title="Birth",
description="Town, County",
notes="",
sources=[
"Birth Certificate of Joe BLOGGS dob 01/01/1900"
])
>>> p.save()
a1b2c3.json saved.
>>> p.print()
{
"id": "a1b2c3",
"last_names": ["BLOGGS"],
"first_names": ["Joe"],
"date_of_birth": "1900-1-1",
"place_of_birth": "Town, County",
"date_of_death": "1970-1-1",
"place_of_death": null,
"direct_relatives": {
"ascendants": [],
"descendants": [],
"partners": []
},
"life_events": [
{
"start": "1900-1-1",
"finish": null,
"title": "Lifetime',
"description": null,
"notes": null,
"sources": []
},
{
"start": "1900-1-1",
"finish": null,
title="Birth",
description="Town, County",
notes="",
"sources": [
"Birth Certificate of Joe BLOGGS dob 01/01/1900"
]
}
]
}
编辑数据
>>> p = genealogy.person(load="a1b2c3")
>>> p.data['life_events][0]
{'start': None, 'finish': None, 'title': 'Lifetime', description': None, 'notes': None, 'sources': []}
>>> p.data['life_events][0]['sources'].append("Birth Certificate of Joe BLOGGS dob 01/01/1900")
>>> p.save()
a1b2c3.json saved.
>>> p.print()
{
"id": "a1b2c3",
"last_names": ["BLOGGS"],
"first_names": ["Joe"],
"date_of_birth": "1900-1-1",
"place_of_birth": "Town, County",
"date_of_death": "1970-1-1",
"place_of_death": null,
"direct_relatives": {
"ascendants": [],
"descendants": [],
"partners": []
},
"life_events": [
{
"start": "1900-1-1",
"finish": null,
"title": "Lifetime",
"description": null,
"notes": null,
"sources": [
"Birth Certificate of Joe BLOGGS dob 01/01/1900"
]
},
{
"start": "1900-1-1",
"finish": null,
title="Birth",
description="Town, County",
notes="",
"sources": [
"Birth Certificate of Joe BLOGGS dob 01/01/1900"
]
}
]
}
链接父项和子项
>>> genealogy.link_child(
parents=["g4h5i6", "m7n8o9"],
child="a1b2c3")
>>> p = genealogy.person(load="a1b2c3")
>>> p.print()
{
"id": "a1b2c3",
"last_names": ["BLOGGS"],
"first_names": ["Joe"],
"date_of_birth": "1900-1-1",
"place_of_birth": "Town, County",
"date_of_death": "1970-1-1",
"place_of_death": null,
"direct_relatives": {
"ascendants": ["g4h5i6", "m7n8o9"],
"descendants": [],
"partners": []
},
"life_events": [
{
"start": "1900-1-1",
"finish": null,
"title": "Lifetime",
"description": null,
"notes": null,
"sources": [
"Birth Certificate of Joe BLOGGS dob 01/01/1900"
]
},
{
"start": "1900-1-1",
"finish": null,
title="Birth",
description="Town, County",
notes="",
"sources": [
"Birth Certificate of Joe BLOGGS dob 01/01/1900"
]
}
]
}