From cb812f5d51da792d840afa6687545487c30f3c9a Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 21 Nov 2021 18:01:10 +0100 Subject: Gathering output file paths for board WWW generator --- boards/generate.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'boards') diff --git a/boards/generate.py b/boards/generate.py index 95d5460..86c7ca5 100644 --- a/boards/generate.py +++ b/boards/generate.py @@ -18,7 +18,8 @@ def deal_convert(source_file, target_files, params=''): def ensure_pbn(source_id, config_name, event_name): target_path = Path('output') / config_name / 'files' / (source_id + '.pbn') if target_path.exists(): - return + return target_path + print('Target path %s does not exist, generating' % (target_path), file=sys.stderr) source_path = Path('pbns') / config_name / (source_id + '.pbn') target_path.parent.mkdir(parents=True, exist_ok=True) deal_convert(str(source_path), [str(target_path)], '--jfr') @@ -27,15 +28,20 @@ def ensure_pbn(source_id, config_name, event_name): pbn_content = re.sub(PBN_EVENT_TAG, '[Event "%s"]' % (event_name), pbn_content) with open(target_path, 'w') as target_file: target_file.write(pbn_content) + return target_path def ensure_pdf(source_id, config_name): target_path = Path('output') / config_name / 'files' / (source_id + '.pdf') if target_path.exists(): - return + return target_path + print('Target path %s does not exist, generating' % (target_path), file=sys.stderr) source_path = Path('output') / config_name / 'files' / (source_id + '.pbn') + target_path.parent.mkdir(parents=True, exist_ok=True) deal_convert(str(source_path), [str(target_path)]) + return target_path +output_files = [] config_dir = Path('config') for config_path in config_dir.glob('*.json'): @@ -54,10 +60,13 @@ for config_path in config_dir.glob('*.json'): set_enabled = False set_finished = True set_content = '%s' % (dealset['title']) + set_files = [] for pbn in dealset['files']: if pbn.get('enabled', 0): - ensure_pbn(pbn['path'], config_name, pbn['title']) - ensure_pdf(pbn['path'], config_name) + set_files.append( + ensure_pbn(pbn['path'], config_name, pbn['title'])) + set_files.append( + ensure_pdf(pbn['path'], config_name)) set_enabled = True set_content += '' set_content += '%s' % (pbn['name']) @@ -66,7 +75,10 @@ for config_path in config_dir.glob('*.json'): set_content += '' else: set_finished = False + output_files += set_files if set_finished: + output_files.append( + ensure_zip(dealset['zip']['id'], config_name, set_files)) set_content += '' set_content += '%s' % (dealset['zip'].get('title', 'cały mecz')) set_content += 'zip' % (dealset['zip']['id']) @@ -82,5 +94,8 @@ for config_path in config_dir.glob('*.json'): template = template.replace('', content) template = template.replace('', datetime.now().strftime('%Y-%m-%d %X')) - with open(output_dir / 'index.html', 'w') as output_file: + output_path = output_dir / 'index.html' + with open(output_path, 'w') as output_file: output_file.write(template) + print('Written output file %s' % (output_path), file=sys.stderr) + output_files.append(output_path) -- cgit v1.2.3