summaryrefslogtreecommitdiff
path: root/dealconvert
diff options
context:
space:
mode:
Diffstat (limited to 'dealconvert')
-rw-r--r--dealconvert/__init__.py2
-rw-r--r--dealconvert/formats/__init__.py3
-rw-r--r--dealconvert/formats/pbn.py19
-rw-r--r--dealconvert/formats/stdout.py2
4 files changed, 14 insertions, 12 deletions
diff --git a/dealconvert/__init__.py b/dealconvert/__init__.py
index e25db66..530990f 100644
--- a/dealconvert/__init__.py
+++ b/dealconvert/__init__.py
@@ -10,7 +10,7 @@ class DealConverter(object):
def output(self, output_files):
deal_set = sorted(self.parser.parse(self.input), key=lambda d:d.number)
for output in output_files:
- self.detect_format(output).output(output, deal_set)
+ self.detect_format(output).output(output, deal_set, True)
def detect_format(self, filename, interactive=True):
for deal_format in globals()['formats'].__all__:
diff --git a/dealconvert/formats/__init__.py b/dealconvert/formats/__init__.py
index cdd8703..2d3d983 100644
--- a/dealconvert/formats/__init__.py
+++ b/dealconvert/formats/__init__.py
@@ -11,7 +11,8 @@ class DealFormat(object):
with open(input_file, 'rb') as content:
return self.parse_content(content)
- def output(self, output_file, deal):
+ def output(self, output_file, deal, analyze=False):
+ self.analyze = analyze
if not len(deal):
raise RuntimeError('Dealset is empty')
with open(output_file, 'wb') as out_file:
diff --git a/dealconvert/formats/pbn.py b/dealconvert/formats/pbn.py
index bc52462..b6c30ed 100644
--- a/dealconvert/formats/pbn.py
+++ b/dealconvert/formats/pbn.py
@@ -137,14 +137,15 @@ class PBNFormat(DealFormat):
])))
for field in board.extra_fields:
lines.append(field)
- try:
- dd_board = PBNBoard(lines)
- dd_table = DDTable(dd_board).get_dd_table(self.interactive)
- dd_contract = ParScore(dd_board).get_par_contract(dd_table)
- dd_board.save_dd_table(dd_table)
- dd_board.save_par_contract(dd_contract)
- lines = [field.raw_field for field in dd_board.fields]
- except Exception as e:
- warnings.warn('unable to determine double-dummy data: %s' % e)
+ if self.analyze:
+ try:
+ dd_board = PBNBoard(lines)
+ dd_table = DDTable(dd_board).get_dd_table(self.interactive)
+ dd_contract = ParScore(dd_board).get_par_contract(dd_table)
+ dd_board.save_dd_table(dd_table)
+ dd_board.save_par_contract(dd_contract)
+ lines = [field.raw_field for field in dd_board.fields]
+ except Exception as e:
+ warnings.warn('unable to determine double-dummy data: %s' % e)
for line in lines + ['']:
out_file.write(line + '\r\n')
diff --git a/dealconvert/formats/stdout.py b/dealconvert/formats/stdout.py
index b9df341..9725c06 100644
--- a/dealconvert/formats/stdout.py
+++ b/dealconvert/formats/stdout.py
@@ -9,7 +9,7 @@ class STDOUTFormat(DealFormat):
def parse(self, input_file):
return []
- def output(self, output_file, deal):
+ def output(self, output_file, deal, analyze=False):
width = 9
for board in deal:
lines = []