fix(script): Suppress bibtex warning on import
When first importing bibtex entries, if there are e.g. double entries, the library gives an 'unsuppressable' warning which will always appear in the manuscript otherwise. This simply ensures no warning is displayed by turning off logging for the duration of their use.
This commit is contained in:
parent
eaaba00755
commit
74a9d201b5
1 changed files with 15 additions and 2 deletions
|
@ -27,6 +27,17 @@ import seaborn as sns
|
|||
from tabulate import tabulate
|
||||
import bibtexparser
|
||||
|
||||
from contextlib import contextmanager
|
||||
import logging
|
||||
@contextmanager
|
||||
def all_logging_disabled(highest_level=logging.CRITICAL):
|
||||
previous_level = logging.root.manager.disable
|
||||
logging.disable(highest_level)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
logging.disable(previous_level)
|
||||
|
||||
sns.set_style("whitegrid")
|
||||
|
||||
DATA_DIR=Path("./02-data")
|
||||
|
@ -39,12 +50,14 @@ bib_string=""
|
|||
for partial_bib in RAW_DATA.glob("**/*.bib"):
|
||||
with open(partial_bib) as f:
|
||||
bib_string+="\n".join(f.readlines())
|
||||
with all_logging_disabled():
|
||||
bib_sample_raw_db = bibtexparser.parse_string(bib_string)
|
||||
|
||||
bib_string=""
|
||||
for partial_bib in WORKING_DATA.glob("**/*.bib"):
|
||||
with open(partial_bib) as f:
|
||||
bib_string+="\n".join(f.readlines())
|
||||
with all_logging_disabled():
|
||||
bib_sample = bibtexparser.parse_string(bib_string)
|
||||
|
||||
# load relevant studies
|
||||
|
|
Loading…
Reference in a new issue