Refactor initial configuration ingestion
This commit is contained in:
parent
ca56bf3cdb
commit
af885e0083
1 changed files with 30 additions and 24 deletions
|
@ -38,20 +38,15 @@ class ExtractPlugin(PapersPlugin):
|
||||||
self.pubsdir = os.path.expanduser(conf["main"]["pubsdir"])
|
self.pubsdir = os.path.expanduser(conf["main"]["pubsdir"])
|
||||||
self.broker = self.repository.databroker
|
self.broker = self.repository.databroker
|
||||||
|
|
||||||
self.on_import = conf["plugins"].get("extract", {}).get("on_import", False)
|
settings = conf["plugins"].get("extract", {})
|
||||||
self.minimum_similarity = float(
|
self.on_import = settings.get("on_import", False)
|
||||||
conf["plugins"].get("extract", {}).get("minimum_similarity", 0.75)
|
self.minimum_similarity = float(settings.get("minimum_similarity", 0.75))
|
||||||
)
|
self.formatting = settings.get(
|
||||||
self.formatting = (
|
|
||||||
conf["plugins"]
|
|
||||||
.get("extract", {})
|
|
||||||
.get(
|
|
||||||
"formatting",
|
"formatting",
|
||||||
"{newline}{quote_begin}> {quote} {quote_end}[{page}]{note_begin}{newline}Note: {note}{note_end}",
|
"{newline}{quote_begin}> {quote} {quote_end}[{page}]{note_begin}{newline}Note: {note}{note_end}",
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
def update_parser(self, subparsers, conf):
|
def update_parser(self, subparsers, _):
|
||||||
"""Allow the usage of the pubs extract subcommand"""
|
"""Allow the usage of the pubs extract subcommand"""
|
||||||
# TODO option for ignoring missing documents or erroring.
|
# TODO option for ignoring missing documents or erroring.
|
||||||
extract_parser = subparsers.add_parser(self.name, help=self.description)
|
extract_parser = subparsers.add_parser(self.name, help=self.description)
|
||||||
|
@ -141,22 +136,33 @@ class ExtractPlugin(PapersPlugin):
|
||||||
keys = resolve_citekey_list(
|
keys = resolve_citekey_list(
|
||||||
self.repository, conf, args.query, ui=self.ui, exit_on_fail=True
|
self.repository, conf, args.query, ui=self.ui, exit_on_fail=True
|
||||||
)
|
)
|
||||||
|
if not keys:
|
||||||
|
return []
|
||||||
for key in keys:
|
for key in keys:
|
||||||
papers.append(self.repository.pull_paper(key))
|
papers.append(self.repository.pull_paper(key))
|
||||||
else:
|
else:
|
||||||
papers = list(filter(
|
papers = list(
|
||||||
|
filter(
|
||||||
get_paper_filter(
|
get_paper_filter(
|
||||||
args.query,
|
args.query,
|
||||||
case_sensitive=args.case_sensitive,
|
case_sensitive=args.case_sensitive,
|
||||||
strict=args.strict,
|
strict=args.strict,
|
||||||
),
|
),
|
||||||
self.repository.all_papers(),
|
self.repository.all_papers(),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
if len(papers) > CONFIRMATION_PAPER_THRESHOLD:
|
if len(papers) > CONFIRMATION_PAPER_THRESHOLD:
|
||||||
self.ui.message('\n'.join(
|
self.ui.message(
|
||||||
pretty.paper_oneliner(p, citekey_only=False, max_authors=conf['main']['max_authors'])
|
"\n".join(
|
||||||
for p in papers))
|
pretty.paper_oneliner(
|
||||||
self.ui.input_yn(question=f"Extract annotations for these papers?", default='y')
|
p, citekey_only=False, max_authors=conf["main"]["max_authors"]
|
||||||
|
)
|
||||||
|
for p in papers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.ui.input_yn(
|
||||||
|
question=f"Extract annotations for these papers?", default="y"
|
||||||
|
)
|
||||||
return papers
|
return papers
|
||||||
|
|
||||||
def _get_file(self, paper):
|
def _get_file(self, paper):
|
||||||
|
|
Loading…
Reference in a new issue