summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-10-01 18:12:06 +0200
committeremkael <emkael@tlen.pl>2019-10-01 18:12:06 +0200
commitc1df2239c5d09a03768439714550dd01ebe917c4 (patch)
treef7552006ca64bfb36eba777250a40fad0f2d8423
parentbc2a83ad9ac5dd506866af1dd903cbd428701a5f (diff)
Parameter to write only JFR DD fields
-rw-r--r--bcdd/PBNBoard.py31
-rw-r--r--pybcdd.py12
2 files changed, 24 insertions, 19 deletions
diff --git a/bcdd/PBNBoard.py b/bcdd/PBNBoard.py
index 35d4466..0430dfa 100644
--- a/bcdd/PBNBoard.py
+++ b/bcdd/PBNBoard.py
@@ -199,24 +199,25 @@ class PBNBoard(object):
'T' if BCalcWrapper.DENOMINATIONS[j] == 'N' else '',
dd_table[i][j])))
- def save_par_contract(self, contract):
- # we're not writing DDS custom fields, just parse them
- self.delete_optimum_score()
- self.write_optimum_score(contract)
+ def save_par_contract(self, contract, jfr_only=False):
+ if not jfr_only:
+ self.delete_optimum_score()
+ self.write_optimum_score(contract)
self.delete_minimax()
self.write_minimax(contract)
- def save_dd_table(self, dd_table):
- if self._has_optimum_result_table is None:
- try:
- optimum_result_table = self.validate_optimum_result_table(
- self.get_optimum_result_table())
- self._has_optimum_result_table = True
- except FieldNotFoundException:
- self._has_optimum_result_table = False
- if not self._has_optimum_result_table:
- self.delete_optimum_result_table()
- self.write_optimum_result_table(dd_table)
+ def save_dd_table(self, dd_table, jfr_only=False):
+ if not jfr_only:
+ if self._has_optimum_result_table is None:
+ try:
+ optimum_result_table = self.validate_optimum_result_table(
+ self.get_optimum_result_table())
+ self._has_optimum_result_table = True
+ except FieldNotFoundException:
+ self._has_optimum_result_table = False
+ if not self._has_optimum_result_table:
+ self.delete_optimum_result_table()
+ self.write_optimum_result_table(dd_table)
if self._has_ability is None:
try:
ability = self.validate_ability(
diff --git a/pybcdd.py b/pybcdd.py
index 366a311..019f1c9 100644
--- a/pybcdd.py
+++ b/pybcdd.py
@@ -7,15 +7,19 @@ from bcdd.Exceptions import DllNotFoundException, FieldNotFoundException
from bcdd.PBNFile import PBNFile
def get_files(args):
+ jfr_only = False
+ if '--jfr' in args:
+ jfr_only = True
+ args.remove('--jfr')
filenames = [name for name in args
if os.path.exists(name)
and (os.path.realpath(name) != os.path.realpath(__file__))]
if len(filenames) == 0:
raise FileNotFoundError('No valid filepaths provided!')
- return filenames
+ return filenames, jfr_only
def main():
- files = get_files(sys.argv)
+ files, jfr_only = get_files(sys.argv)
errors = []
for filename in files:
try:
@@ -37,8 +41,8 @@ def main():
contract = par.get_par_contract(dd_table)
print(contract)
print('')
- board.save_dd_table(dd_table)
- board.save_par_contract(contract)
+ board.save_dd_table(dd_table, jfr_only)
+ board.save_par_contract(contract, jfr_only)
pbn_file.write_board(board)
else:
error = 'unable to determine DD table for board %s' \