Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, collector, outputs="stdout,pickle", fn=DUECREDIT_FILE):
self._due = collector
self.fn = fn
# for now decide on output "format" right here
self._outputs = [
self._get_output_handler(
type_.lower().strip(), collector, fn=fn)
for type_ in os.environ.get('DUECREDIT_OUTPUTS', outputs).split(',')
if type_
]
def setup_parser(parser):
parser.add_argument(
"-f", "--filename", default=DUECREDIT_FILE,
help="Filename containing collected citations. Default: %(default)s")
parser.add_argument(
"--style", choices=("apa", "harvard1"), default="harvard1",
help="Style to be used for listing citations")
parser.add_argument(
"--format", choices=("text", "bibtex"), default="text",
help="Way to present the summary")
def _get_active_due():
from .config import CACHE_DIR, DUECREDIT_FILE
from duecredit.collector import CollectorSummary, DueCreditCollector
from .io import load_due
# TODO: this needs to move to atexit handling, that we load previous
# one and them merge with new ones. Informative bits could be -- how
# many new citations we got
if os.path.exists(DUECREDIT_FILE):
try:
due_ = load_due(DUECREDIT_FILE)
except Exception as e:
lgr.warning("Failed to load previously collected %s. "
"DueCredit will not be active for this session."
% DUECREDIT_FILE)
return _get_inactive_due()
else:
due_ = DueCreditCollector()
return due_
def _get_active_due():
from .config import CACHE_DIR, DUECREDIT_FILE
from duecredit.collector import CollectorSummary, DueCreditCollector
from .io import load_due
# TODO: this needs to move to atexit handling, that we load previous
# one and them merge with new ones. Informative bits could be -- how
# many new citations we got
if os.path.exists(DUECREDIT_FILE):
try:
due_ = load_due(DUECREDIT_FILE)
except Exception as e:
lgr.warning("Failed to load previously collected %s. "
"DueCredit will not be active for this session."
% DUECREDIT_FILE)
return _get_inactive_due()
else:
due_ = DueCreditCollector()
return due_
def __init__(self, collector, fn=DUECREDIT_FILE):
self.collector = collector
self.fn = fn
def load(cls, filename=DUECREDIT_FILE):
with open(filename, 'rb') as f:
return pickle.load(f)