记录家谱的包裹。

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"
            ]
        }
    ]
}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JavaFX:无法在GridPane内水平居中放置行单元格   java GAE flex Jersey Web服务返回404   java使用SLF4J,是否可以对错误/警告采取行动?   如何使用Java解析每个不同键和值的JSON对象?   java如何在azure服务总线中始终侦听队列并截获每条消息   java需要退出循环并修复打印顺序错误(基本计算器)   java在Kafka的哪个分区中有多少数据?   在Java中访问无顶级类的非顶级类的编译器构造   java如何从maven项目生成jar   java如何使用amazon资源名称(ARN)作为标识符来查找amazon资源?   java为什么我的程序忽略else语句   java如何控制JTable中的字体样式、颜色和大小?   java对命令使用多个类,命令不起作用?   树集中的java字母排序不起作用   java将变量作为正则表达式传递   java TestNG XML中的一组值   java什么时候应该重写Equals函数?   Java中通过SSL使用web服务的web服务   java LibGDX以不同的速度移动对象   java中“and”的正则表达式