Merge branch 'develop' into plug/texnote
* develop: Adapt function in helpers.py to changes in ui.
This commit is contained in:
commit
c44881d3b3
@ -55,7 +55,7 @@ def command(args):
|
||||
if tags is not None:
|
||||
p.tags = set(tags.split(','))
|
||||
# Check if another doc file is specified in bibtex
|
||||
docfile2 = extract_doc_path_from_bibdata(p, ui)
|
||||
docfile2 = extract_doc_path_from_bibdata(p)
|
||||
if docfile is None:
|
||||
docfile = docfile2
|
||||
elif docfile2 is not None:
|
||||
|
@ -32,7 +32,7 @@ def command(args):
|
||||
if copy is None:
|
||||
copy = config().import_copy
|
||||
rp = repo.Repository(config())
|
||||
key = parse_reference(ui, rp, reference)
|
||||
key = parse_reference(rp, reference)
|
||||
paper = rp.get_paper(key)
|
||||
try:
|
||||
add_docfile_to_paper(rp, paper, docfile=document, copy=copy)
|
||||
|
@ -22,7 +22,7 @@ def command(args):
|
||||
reference = args.reference
|
||||
|
||||
rp = repo.Repository(config())
|
||||
key = parse_reference(ui, rp, reference)
|
||||
key = parse_reference(rp, reference)
|
||||
paper = rp.get_paper(key)
|
||||
filepath = rp._metafile(key) if meta else rp._bibfile(key)
|
||||
|
||||
|
@ -28,7 +28,7 @@ def command(args):
|
||||
|
||||
rp = repo.Repository(config())
|
||||
papers = [rp.get_paper(c)
|
||||
for c in parse_references(ui, rp, references)]
|
||||
for c in parse_references(rp, references)]
|
||||
if len(papers) == 0:
|
||||
papers = rp.all_papers()
|
||||
bib = BibliographyData()
|
||||
|
@ -3,6 +3,7 @@ from .. import color
|
||||
from .. import pretty
|
||||
from ..repo import InvalidReference
|
||||
from ..paper import NoDocumentFile
|
||||
from ..uis import get_ui()
|
||||
|
||||
|
||||
def add_references_argument(parser, single=False):
|
||||
@ -28,29 +29,31 @@ def add_paper_with_docfile(repo, paper, docfile=None, copy=False):
|
||||
add_docfile_to_paper(repo, paper, docfile, copy=copy)
|
||||
|
||||
|
||||
def extract_doc_path_from_bibdata(paper, ui):
|
||||
def extract_doc_path_from_bibdata(paper):
|
||||
try:
|
||||
file_path = paper.get_document_file_from_bibdata(remove=True)
|
||||
if files.check_file(file_path):
|
||||
return file_path
|
||||
else:
|
||||
ui = get_ui()
|
||||
ui.warning("File does not exist for %s (%s)."
|
||||
% (paper.citekey, file_path))
|
||||
except NoDocumentFile:
|
||||
return None
|
||||
|
||||
|
||||
def parse_reference(ui, rp, ref):
|
||||
def parse_reference(rp, ref):
|
||||
try:
|
||||
return rp.ref2citekey(ref)
|
||||
except InvalidReference:
|
||||
ui = get_ui()
|
||||
ui.error("no paper with reference: %s."
|
||||
% color.dye(ref, color.citekey))
|
||||
ui.exit(-1)
|
||||
|
||||
|
||||
def parse_references(ui, rp, refs):
|
||||
citekeys = [parse_reference(ui, rp, ref) for ref in refs]
|
||||
def parse_references(rp, refs):
|
||||
citekeys = [parse_reference(rp, ref) for ref in refs]
|
||||
return citekeys
|
||||
|
||||
def paper_oneliner(p, n = 0, citekey_only = False):
|
||||
|
@ -31,7 +31,7 @@ def command(args):
|
||||
# Extract papers from bib
|
||||
papers = Paper.many_from_path(bibpath, fatal=False)
|
||||
for p in papers:
|
||||
doc_file = extract_doc_path_from_bibdata(p, ui)
|
||||
doc_file = extract_doc_path_from_bibdata(p)
|
||||
if doc_file is None:
|
||||
ui.warning("No file for %s." % p.citekey)
|
||||
add_paper_with_docfile(rp, p, docfile=doc_file, copy=copy)
|
||||
|
@ -24,7 +24,7 @@ def command(args):
|
||||
reference = args.reference
|
||||
|
||||
rp = repo.Repository(config())
|
||||
key = parse_reference(ui, rp, reference)
|
||||
key = parse_reference(rp, reference)
|
||||
paper = rp.get_paper(key)
|
||||
if with_command is None:
|
||||
with_command = config().open_cmd
|
||||
|
@ -20,7 +20,7 @@ def command(args):
|
||||
references = args.references
|
||||
|
||||
rp = repo.Repository(config())
|
||||
citekeys = parse_references(ui, rp, references)
|
||||
citekeys = parse_references(rp, references)
|
||||
if force is None:
|
||||
are_you_sure = ("Are you sure you want to delete paper(s) [%s]"
|
||||
" (this will also delete associated documents)?"
|
||||
|
Loading…
x
Reference in New Issue
Block a user