def _add_bibfile_manual(self, repo): """Add publication to library by manual entry of bibfile. Parameters ---------- repo : `obj`:Repository """ tmp_bib_file = os.path.expandvars("${HOME}/.local/tmp/test.bib") uis._ui.edit_file(tmp_bib_file, False) doc = choose_file("PDF:", "Choose a PDF file", filter="pdf") args = PubsArgs() args.bibfile = tmp_bib_file args.docfile = doc # Read bibfile if doc is not None: with open(tmp_bib_file) as bibtex_file: bibtex_str = bibtex_file.read() bib_database = bibtexparser.loads(bibtex_str) base_key = bib_database.entries[0]["ID"] citekey = repo.unique_citekey(base_key, uis._ui) args.citekey = citekey conf = repo.conf add_cmd(conf, args) if doc is not None: doc = update_pdf_metadata(repo, args.citekey) events.PostCommandEvent().send()
def _add_bibfile(self, repo): """Add publication to library from bibfile. Parameters ---------- repo : `obj`:Repository """ bibfile, doc = choose_two_files( text="Bibfile:", description="Import reference from Bibfile", ) args = PubsArgs() args.bibfile = bibfile args.docfile = doc # Read bibfile if doc is not None: with open(bibfile) as bibtex_file: bibtex_str = bibtex_file.read() bib_database = bibtexparser.loads(bibtex_str) base_key = bib_database.entries[0]["ID"] citekey = repo.unique_citekey(base_key, uis._ui) args.citekey = citekey conf = repo.conf add_cmd(conf, args) if doc is not None: doc = update_pdf_metadata(repo, args.citekey) events.PostCommandEvent().send()
def _add_isbn(self, repo): """Add publication to library from ISBN. Parameters ---------- repo : `obj`:Repository """ isbn, doc = get_user_input("ISBN:", description="Import reference by ISBN") args = PubsArgs() args.isbn = isbn args.docfile = doc args.citekey = gen_citekey(repo, args) conf = repo.conf add_cmd(conf, args) if doc is not None: doc = update_pdf_metadata(repo, args.citekey) events.PostCommandEvent().send()
def _add_arxiv(self, repo): """Add publication to library from ArXiv. Parameters ---------- repo : `obj`:Repository """ arxiv, doc = get_user_input("ArXiv:", description="Import reference by Arxiv") args = PubsArgs() args.arxiv = arxiv args.docfile = doc args.citekey = gen_citekey(repo, args) conf = repo.conf add_cmd(conf, args) if doc is not None: doc = update_pdf_metadata(repo, args.citekey) events.PostCommandEvent().send()