From 510e7f6a3bb3a8f2a7bd029a313350145eff8f5f Mon Sep 17 00:00:00 2001 From: sirrice Date: Thu, 3 Dec 2015 20:56:20 -0500 Subject: [PATCH] add paranoid flag --- biblib/bib.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/biblib/bib.py b/biblib/bib.py index 495ab87..e865079 100644 --- a/biblib/bib.py +++ b/biblib/bib.py @@ -28,7 +28,7 @@ class ParseError(Exception): class Parser: """A parser for .bib BibTeX database files.""" - def __init__(self, *, month_style='full'): + def __init__(self, *, month_style='full', paranoid=False): """Initialize an empty database. This also initializes standard month macros (which are usually @@ -43,6 +43,7 @@ def __init__(self, *, month_style='full'): self.__log, self.__errors = [], False self.__entries = collections.OrderedDict() + self.__paranoid = paranoid if month_style == 'full': self.__macros = {'jan': 'January', 'feb': 'February', @@ -119,7 +120,11 @@ def parse(self, str_or_fp_or_iter, name=None, *, log_fp=None): # Just continue to the next entry if there's an error with recoverer: self._scan_command_or_entry() - recoverer.reraise() + + if self.__paranoid: + recoverer.reraise() + else: + recoverer.dispose() return self def get_entries(self):