Skip to content

Commit

Permalink
option to modify individual bibscore values from the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Oct 14, 2019
1 parent 2d9ca3c commit e220e4a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/macrogen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
from argparse import ArgumentParser
from logging import Logger
from pathlib import Path

from macrogen.config import config
Expand All @@ -15,11 +16,23 @@ def main(argv=sys.argv):
parser.add_argument('-i', '--input', metavar='ZIP', help='Loads graph from zip file and runs the reporting', type=Path)
parser.add_argument('-o', '--output', metavar='ZIP', help='Saves graph to given zip file', type=Path)
parser.add_argument('--skip-reports', action='store_true', help='Do not write reports (use with -o)')
parser.add_argument('--override-bibscore', nargs='+', metavar='uri=value', help='Override bibscore for specific URIs')
group = parser.add_argument_group("Configuration options")
config.prepare_options(group)
options = parser.parse_args(argv[1:])
config.config_override = vars(options)

if options.override_bibscore:
logger: Logger = config.getLogger(__name__)
for override in options.override_bibscore:
uri, value_str = override.split('=')
try:
value = int(value_str)
config.bibscores[uri] = value

except ValueError:
logger.error('Could not parse score %s for source %s', value_str, uri)

graphs = graph.MacrogenesisInfo(options.input)

if options.output:
Expand Down

0 comments on commit e220e4a

Please sign in to comment.