This repo is without a file repo nor a search engine. This code deletes any existing "paper-model1.yaml it might be there.
! rm -f data/paper-model1.yaml
from paperapp.paper_repo import PaperRepo
from paperapp.paper_ipython import *
from paperapp.paper_bibtex import import_bibtex_str
These are the default types:
default_types = PaperRepo.get_default_types()
default_types
{'topic': {'related-to': ['topic'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'search': {'site': [],
'date': [],
'related-to': ['topic'],
'type': [],
'id': [],
'text': [],
'note': []},
'artifact': {'related-to': ['topic'],
'on-disk': ['file'],
'found-in': ['search', 'artifact', 'external'],
'found-date': [],
'bibtex': ['bibtex'],
'external': ['external'],
'status': [],
'read': ['scenario'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'bibtex': {'booktitle': [],
'title': [],
'author': [],
'year': [],
'pages': [],
'organization': [],
'journal': [],
'publisher': [],
'number': [],
'volume': [],
'howpublished': [],
'institution': [],
'address': [],
'meta': [],
'school': [],
'biburl': [],
'timestamp': [],
'link': [],
'editor': [],
'month': [],
'crossref': [],
'chapter': [],
'isbn': [],
'series': [],
'doi': [],
'issue': [],
'issn': [],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'place': {'type': [], 'id': [], 'text': [], 'note': [], 'date': []},
'file': {'md5hash': [],
'number': [],
'mimetype': [],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'scenario': {'location': ['place'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'external': {'url': [],
'cited-by': [],
'provider': [],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'reading-list': {'related-to': ['topic'],
'artifacts': ['artifact'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'relation': {'source': ['artifact'],
'target': ['artifact'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []}}
We are going to add a custom type 'lecture':
custom_types = default_types.copy()
custom_types['lecture'] = { 'year': [], 'institution':[], 'number': []}
custom_types['artifact']['lecture'] = [ 'lecture' ]
custom_types
{'topic': {'related-to': ['topic'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'search': {'site': [],
'date': [],
'related-to': ['topic'],
'type': [],
'id': [],
'text': [],
'note': []},
'artifact': {'related-to': ['topic'],
'on-disk': ['file'],
'found-in': ['search', 'artifact', 'external'],
'found-date': [],
'bibtex': ['bibtex'],
'external': ['external'],
'status': [],
'read': ['scenario'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': [],
'lecture': ['lecture']},
'bibtex': {'booktitle': [],
'title': [],
'author': [],
'year': [],
'pages': [],
'organization': [],
'journal': [],
'publisher': [],
'number': [],
'volume': [],
'howpublished': [],
'institution': [],
'address': [],
'meta': [],
'school': [],
'biburl': [],
'timestamp': [],
'link': [],
'editor': [],
'month': [],
'crossref': [],
'chapter': [],
'isbn': [],
'series': [],
'doi': [],
'issue': [],
'issn': [],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'place': {'type': [], 'id': [], 'text': [], 'note': [], 'date': []},
'file': {'md5hash': [],
'number': [],
'mimetype': [],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'scenario': {'location': ['place'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'external': {'url': [],
'cited-by': [],
'provider': [],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'reading-list': {'related-to': ['topic'],
'artifacts': ['artifact'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'relation': {'source': ['artifact'],
'target': ['artifact'],
'type': [],
'id': [],
'text': [],
'note': [],
'date': []},
'lecture': {'year': [], 'institution': [], 'number': []}}
p = PaperRepo("data/paper-model1.yaml", auto_save=True, custom_types=custom_types)
print(p.versionhash())
0
p.new_node('lecture-1', 'lecture', 'Lighting Talk', institution='LearnDS')
render_node(p, 'lecture-1')
p2 = PaperRepo("data/paper-model1.yaml")
p2.repo
[{'id': 'lecture-1',
'institution': 'LearnDS',
'text': 'Lighting Talk',
'type': 'lecture'}]
p2.versionhash()
4671
p2.types['lecture']
{'date': [],
'id': [],
'institution': [],
'note': [],
'number': [],
'text': [],
'type': [],
'year': []}
Check the lecture is available for the node.
new_node(p, _type='artifact')
render_node(p,'paper-1')
p.auto_save()