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 = (
|
"formatting",
|
||||||
conf["plugins"]
|
"{newline}{quote_begin}> {quote} {quote_end}[{page}]{note_begin}{newline}Note: {note}{note_end}",
|
||||||
.get("extract", {})
|
|
||||||
.get(
|
|
||||||
"formatting",
|
|
||||||
"{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(
|
||||||
get_paper_filter(
|
filter(
|
||||||
args.query,
|
get_paper_filter(
|
||||||
case_sensitive=args.case_sensitive,
|
args.query,
|
||||||
strict=args.strict,
|
case_sensitive=args.case_sensitive,
|
||||||
),
|
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