summaryrefslogtreecommitdiff
path: root/deal-converter.py
blob: 5a59b6ad6f880aaf9152c29a36ce902efde43805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from __future__ import print_function
import argparse, sys, warnings

from dealconvert import DealConverter

parser = argparse.ArgumentParser(
    description='Universal converter for bridge deal formats',
    formatter_class=argparse.RawTextHelpFormatter,
    epilog='Supported formats: BER BHG BRI CDS CSV DGE DLM DUP PBN RZD.\n' + \
    'Formats are auto-detected based on file extension.')
parser.add_argument('input', metavar='INPUT_FILE',
                    help='Input file path')
parser.add_argument('output', metavar='OUTPUT_FILE', nargs='*',
                    help='Output file path(s)')

arguments = parser.parse_args()

def _warning(msg, *args, **kwargs):
    print('WARNING: %s' % (msg), file=sys.stderr)
warnings.showwarning = _warning

try:
    converter = DealConverter(arguments.input)
    converter.output(arguments.output)
except RuntimeError as e:
    print('ERROR: %s' % (str(e)), file=sys.stderr)