summaryrefslogtreecommitdiff
path: root/boards/generate.py
diff options
context:
space:
mode:
Diffstat (limited to 'boards/generate.py')
-rw-r--r--boards/generate.py25
1 files changed, 20 insertions, 5 deletions
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 = '<tr><td class="bdcc1" colspan="3">%s</td></tr>' % (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 += '<tr>'
set_content += '<td class="bd1">%s</td>' % (pbn['name'])
@@ -66,7 +75,10 @@ for config_path in config_dir.glob('*.json'):
set_content += '</tr>'
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 += '<tr>'
set_content += '<td class="bd1" colspan="2">%s</td>' % (dealset['zip'].get('title', 'cały mecz'))
set_content += '<td class="bdc"><a class="zb" href="files/%s.zip">zip</a></td>' % (dealset['zip']['id'])
@@ -82,5 +94,8 @@ for config_path in config_dir.glob('*.json'):
template = template.replace('<!---[CONTENT]--->', content)
template = template.replace('<!---[GENDATE]--->', 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)