summaryrefslogtreecommitdiff
path: root/dealconvert
diff options
context:
space:
mode:
Diffstat (limited to 'dealconvert')
-rw-r--r--dealconvert/__init__.py9
-rw-r--r--dealconvert/formats/__init__.py3
-rw-r--r--dealconvert/formats/cds.py2
-rw-r--r--dealconvert/formats/dup.py2
-rw-r--r--dealconvert/formats/pbn.py4
5 files changed, 11 insertions, 9 deletions
diff --git a/dealconvert/__init__.py b/dealconvert/__init__.py
index 530990f..229e4ce 100644
--- a/dealconvert/__init__.py
+++ b/dealconvert/__init__.py
@@ -1,23 +1,24 @@
from .formats import *
class DealConverter(object):
- def __init__(self, input_file=None):
+ def __init__(self, input_file=None, jfr_only=False):
self.input = input_file
self.formats = {}
+ print jfr_only
if input_file is not None:
- self.parser = self.detect_format(self.input)
+ self.parser = self.detect_format(self.input, jfr_only=jfr_only)
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, True)
- def detect_format(self, filename, interactive=True):
+ def detect_format(self, filename, interactive=True, jfr_only=False):
for deal_format in globals()['formats'].__all__:
if deal_format not in self.formats:
self.formats[deal_format] = getattr(
globals()[deal_format],
- deal_format.upper() + 'Format')(interactive)
+ deal_format.upper() + 'Format')(interactive, jfr_only)
if self.formats[deal_format].match_file(filename):
return self.formats[deal_format]
raise RuntimeError('Unrecognized file extension: %s' % filename)
diff --git a/dealconvert/formats/__init__.py b/dealconvert/formats/__init__.py
index 2d3d983..9ac48e3 100644
--- a/dealconvert/formats/__init__.py
+++ b/dealconvert/formats/__init__.py
@@ -4,8 +4,9 @@ import glob
class DealFormat(object):
cards = 'AKQJT98765432'
- def __init__(self, interactive=True):
+ def __init__(self, interactive=True, jfr_only=False):
self.interactive = interactive
+ self.jfr_only = jfr_only
def parse(self, input_file):
with open(input_file, 'rb') as content:
diff --git a/dealconvert/formats/cds.py b/dealconvert/formats/cds.py
index c7eeb5a..6137c4d 100644
--- a/dealconvert/formats/cds.py
+++ b/dealconvert/formats/cds.py
@@ -9,7 +9,7 @@ class CDSFormat(DealFormat):
def suffix(self):
return '.cds'
- def __init__(self, interactive=True):
+ def __init__(self, *args, **kwargs):
self.rzd_format = RZDFormat()
def parse_content(self, content):
diff --git a/dealconvert/formats/dup.py b/dealconvert/formats/dup.py
index 19dca0f..3e34f2c 100644
--- a/dealconvert/formats/dup.py
+++ b/dealconvert/formats/dup.py
@@ -10,7 +10,7 @@ class DUPFormat(DealFormat):
def suffix(self):
return '.dup'
- def __init__(self, interactive=True):
+ def __init__(self, *args, **kwargs):
self.bri = BRIFormat()
self.dge = DGEFormat()
diff --git a/dealconvert/formats/pbn.py b/dealconvert/formats/pbn.py
index 750d57d..04db8a2 100644
--- a/dealconvert/formats/pbn.py
+++ b/dealconvert/formats/pbn.py
@@ -144,8 +144,8 @@ class PBNFormat(DealFormat):
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)
+ dd_board.save_dd_table(dd_table, jfr_only=self.jfr_only)
+ dd_board.save_par_contract(dd_contract, jfr_only=self.jfr_only)
lines = [field.raw_field for field in dd_board.fields]
except Exception as e:
warnings.warn('unable to determine double-dummy data: %s' % e)