{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Find person" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Person" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. autofunction:: metacatalog.api.find_person" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Role" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. autofunction:: metacatalog.api.find_role" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Associations" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. note::\n", "\n", " Persons are not directly bound to an :class:`Entry `. They are related by an association that have to be further described by the type of contribution to the :class:`Entry `. Therefore, if an :class:`Entry ` is deleted, the :class:`Person ` will persist.\n", " Finally, you can't search for contributions directly, you either have to find a Person and load the associated entries, or you need to find an entry and load the contributors." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Alfred, E. Neumann as author for Entry \n", "Alfred, E. Neumann as author for Entry \n", "Alfred, E. Neumann as author for Entry \n" ] } ], "source": [ "from metacatalog import api\n", "session = api.connect_database()\n", "\n", "# get the person\n", "alfred =api.find_person(session, id=2)[0]\n", "\n", "for assoc in alfred.entries:\n", " print(assoc)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "First author: Alfred, E. Neumann \n", "all authors: Alfred, E. Neumann \n", "Alfred, E. Neumann as author for Entry \n" ] } ], "source": [ "# now starting from the entry side\n", "entry = api.find_entry(session, id=20)[0]\n", "\n", "print('First author:', str(entry.author))\n", "print('all authors: ', ', '.join([str(a) for a in entry.authors]))\n", "for assoc in entry.contributors:\n", " print(assoc)" ] } ], "metadata": { "celltoolbar": "Raw Cell Format", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }