diff options
author | emkael <emkael@tlen.pl> | 2024-01-17 23:23:58 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2024-01-17 23:23:58 +0100 |
commit | 62ee2f3e192a868087f8fc9fd949005aa27add72 (patch) | |
tree | afa913ca130e9177b7ba6eda3716f6a4db77c0a1 | |
parent | 1c4d342e281ab8641486d42d4a916cc2c47c8671 (diff) |
Option to generate reserve sets
-rw-r--r-- | pysquaredeal.py | 3 | ||||
-rw-r--r-- | 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) |