summaryrefslogtreecommitdiff
path: root/dealconvert/formats/rzd.py
diff options
context:
space:
mode:
Diffstat (limited to 'dealconvert/formats/rzd.py')
-rw-r--r--dealconvert/formats/rzd.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/dealconvert/formats/rzd.py b/dealconvert/formats/rzd.py
index d6cbc5e..8ca1e97 100644
--- a/dealconvert/formats/rzd.py
+++ b/dealconvert/formats/rzd.py
@@ -1,10 +1,10 @@
-import sys
+import warnings
from . import DealFormat
from .. import dto
class RZDFormat(DealFormat):
- number_warning = 'WARNING: .rzd file format assumes consequent deal numbers from 1'
+ number_warning = '.rzd file format assumes consequent deal numbers from 1'
@property
def suffix(self):
@@ -20,7 +20,7 @@ class RZDFormat(DealFormat):
return deal.hands
def parse_content(self, content):
- print self.number_warning
+ warnings.warn(self.number_warning)
dealset = []
header = None
number = 1
@@ -28,7 +28,7 @@ class RZDFormat(DealFormat):
data = content.read(13)
if len(data) < 13:
if len(data) != 0:
- print 'WARNING: .rzd data truncated: %s' % (data)
+ warnings.warn('.rzd data truncated: %s' % (data))
break
if header is None:
header = data
@@ -51,8 +51,7 @@ class RZDFormat(DealFormat):
try:
idx = self.cards.index(card)
except ValueError:
- print 'ERROR: invalid card: %s' % (card)
- sys.exit()
+ raise RuntimeError('invalid card: %s' % (card))
values[idx*4+suit] = (i + offset)%4
for i in range(0, 13):
byte = 0
@@ -63,7 +62,7 @@ class RZDFormat(DealFormat):
return value
def output_content(self, out_file, dealset):
- print self.number_warning
+ warnings.warn(self.number_warning)
board_count = len(dealset)
out_file.write(chr(board_count%256))
out_file.write(chr(board_count/256))