summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-05-23 01:46:56 +0200
committeremkael <emkael@tlen.pl>2019-05-23 01:46:56 +0200
commit41eefa5301eb58d93af156ccc166c243406cfc3a (patch)
treeefcf5289da948c8566dcf37920dfb4c9020499e4
parentc5608c4cdb67aca4d154541a09d5ebb88bf232ec (diff)
Error/warning message formatting
-rw-r--r--deal-converter.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/deal-converter.py b/deal-converter.py
index 65ab692..5a59b6a 100644
--- a/deal-converter.py
+++ b/deal-converter.py
@@ -1,4 +1,5 @@
-import argparse, sys
+from __future__ import print_function
+import argparse, sys, warnings
from dealconvert import DealConverter
@@ -14,5 +15,12 @@ parser.add_argument('output', metavar='OUTPUT_FILE', nargs='*',
arguments = parser.parse_args()
-converter = DealConverter(arguments.input)
-converter.output(arguments.output)
+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)