From 62ee2f3e192a868087f8fc9fd949005aa27add72 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 17 Jan 2024 23:23:58 +0100 Subject: Option to generate reserve sets --- pysquaredeal.py | 3 ++- squaredeal/__init__.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pysquaredeal.py b/pysquaredeal.py index ccfc23a..7630772 100644 --- a/pysquaredeal.py +++ b/pysquaredeal.py @@ -33,6 +33,7 @@ argparser_publish = subparsers.add_parser('publish', help='mark SQD as published argparser_generate = subparsers.add_parser('generate', help='generate PBN') argparser_generate.add_argument('phase', nargs='?', type=int, metavar='PHASE', help='phase number, if empty, all phases will be generated') argparser_generate.add_argument('session', nargs='?', type=int, metavar='SESSION', help='session number, if empty, all sessions will be generated') +argparser_generate.add_argument('--reserve', action='store_true', help='generate reserve board set') arguments = argparser.parse_args() @@ -79,4 +80,4 @@ elif arguments.command == 'generate': sd.fromfile(arguments.sqd_file, sqkpath=arguments.sqk_file) if not sd.published: raise SquareDealError('Cannot generate PBN files: event info is not marked as published') - sd.generate(arguments.phase, arguments.session) + sd.generate(arguments.phase, arguments.session, reserve=arguments.reserve) diff --git a/squaredeal/__init__.py b/squaredeal/__init__.py index 2d4a020..8faeb71 100644 --- a/squaredeal/__init__.py +++ b/squaredeal/__init__.py @@ -26,8 +26,8 @@ class SquareDealPhase(object): def tostring(self): return ':'.join([str(self.sessions), str(self.boards), self.prefix, self.info or '']) - def _output_file_name(self, session): - return self.prefix.replace('#', str(session)) + def _output_file_name(self, session, reserve=False): + return self.prefix.replace('#', str(session)) + ('reserve' if reserve else '') def generate(self, session, delayed_info, reserve=False): if not SquareDeal.BIGDEALX_PATH: @@ -45,7 +45,7 @@ class SquareDealPhase(object): '-e', session_right, '-e', delayed_info, '-e', reserve_info, - '-p', self._output_file_name(session+1), + '-p', self._output_file_name(session+1, reserve), '-n', str(self.boards)] subprocess.run(args, cwd=os.path.realpath(SquareDeal.BIGDEALX_PATH)) @@ -169,7 +169,7 @@ class SquareDeal(object): phase.s_keys.append(self._generate_session_key()) self.phases.append(phase) - def generate(self, phase, session): + def generate(self, phase, session, reserve=False): phases_to_generate = range(0, len(self.phases)) if phase is None else [phase-1] for phase in phases_to_generate: - self.phases[phase].generate(session, self.delayed_info) + self.phases[phase].generate(session, self.delayed_value, reserve) -- cgit v1.2.3