add template text to add editor input
This commit is contained in:
parent
2078876168
commit
c4f296346a
@ -4,6 +4,8 @@ from .. import bibstruct
|
|||||||
from .. import content
|
from .. import content
|
||||||
from .. import repo
|
from .. import repo
|
||||||
from .. import paper
|
from .. import paper
|
||||||
|
from .. import templates
|
||||||
|
|
||||||
|
|
||||||
def parser(subparsers):
|
def parser(subparsers):
|
||||||
parser = subparsers.add_parser('add', help='add a paper to the repository')
|
parser = subparsers.add_parser('add', help='add a paper to the repository')
|
||||||
@ -40,13 +42,21 @@ def command(args):
|
|||||||
if bibfile is None:
|
if bibfile is None:
|
||||||
cont = True
|
cont = True
|
||||||
bibstr = ''
|
bibstr = ''
|
||||||
while cont:
|
|
||||||
try:
|
try:
|
||||||
bibstr = content.editor_input(config().edit_cmd, bibstr, suffix='.yaml')
|
bibstr = content.editor_input(config().edit_cmd,
|
||||||
bibdata = rp.databroker.verify(bibstr)
|
templates.add_bib,
|
||||||
bibstruct.verify_bibdata(bibdata)
|
suffix='.bib')
|
||||||
# REFACTOR Generate citykey
|
if bibstr == templates.add_bib:
|
||||||
cont = False
|
cont = ui.input_yn(
|
||||||
|
question='Bibfile not edited. Edit again ?',
|
||||||
|
default='y')
|
||||||
|
if not cont:
|
||||||
|
ui.exit(0)
|
||||||
|
else:
|
||||||
|
bibdata = rp.databroker.verify(bibstr)
|
||||||
|
bibstruct.verify_bibdata(bibdata)
|
||||||
|
# REFACTOR Generate citykey
|
||||||
|
cont = False
|
||||||
except ValueError:
|
except ValueError:
|
||||||
cont = ui.input_yn(
|
cont = ui.input_yn(
|
||||||
question='Invalid bibfile. Edit again ?',
|
question='Invalid bibfile. Edit again ?',
|
||||||
|
1
pubs/templates/__init__.py
Normal file
1
pubs/templates/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from str_templates import *
|
18
pubs/templates/add_bib.txt
Normal file
18
pubs/templates/add_bib.txt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Input the bibliographic data for your article
|
||||||
|
# Supported formats are bibtex (template below), bibyaml and bibtexml
|
||||||
|
|
||||||
|
@article{
|
||||||
|
YourCitekey,
|
||||||
|
author = "LastName1, FirstName1 and LastName2, FirstName2",
|
||||||
|
title = "",
|
||||||
|
journal = "",
|
||||||
|
number = "7",
|
||||||
|
pages = "23-31",
|
||||||
|
volume = "13",
|
||||||
|
year = "2013",
|
||||||
|
|
||||||
|
doi = "",
|
||||||
|
issn = "",
|
||||||
|
keywords = "",
|
||||||
|
abstract = ""
|
||||||
|
}
|
20
pubs/templates/str_templates.py
Normal file
20
pubs/templates/str_templates.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
add_bib = """
|
||||||
|
# Input the bibliographic data for your article
|
||||||
|
# Supported formats are bibtex (template below), bibyaml and bibtexml
|
||||||
|
|
||||||
|
@article{
|
||||||
|
YourCitekey,
|
||||||
|
author = "LastName1, FirstName1 and LastName2, FirstName2",
|
||||||
|
title = "",
|
||||||
|
journal = "",
|
||||||
|
number = "7",
|
||||||
|
pages = "23-31",
|
||||||
|
volume = "13",
|
||||||
|
year = "2013",
|
||||||
|
|
||||||
|
doi = "",
|
||||||
|
issn = "",
|
||||||
|
keywords = "",
|
||||||
|
abstract = ""
|
||||||
|
}
|
||||||
|
"""
|
Loading…
x
Reference in New Issue
Block a user