From 2462166ce2128911bb4f166a5f39caba5ab2b75a Mon Sep 17 00:00:00 2001 From: Jan Horacek Date: Sun, 1 Nov 2020 17:01:57 +0100 Subject: [PATCH 1/2] SOC: report missing image. --- scr/soc_generator.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scr/soc_generator.py b/scr/soc_generator.py index 0a7002f..883f760 100755 --- a/scr/soc_generator.py +++ b/scr/soc_generator.py @@ -94,10 +94,9 @@ def generate_soc(template, topic): icon_text += ('
%s
' % (t, t, t)) - svg_path = os.path.join(IMAGE_DIR, '%s.svg' % (t)) + svg_path = os.path.join(IMAGE_DIR, f'{t}.svg') if not os.path.isfile(svg_path): - logging.warning('Missing file %s for SOC %s' % - (svg_path, topic.id)) + logging.warning(f'Missing file {svg_path} for SOC {topic.id}') template = template.replace('{{field-icons}}', icon_text) return template From 4a4ea7275d444d277e89d1a444d25350cbba0d6e Mon Sep 17 00:00:00 2001 From: Jan Horacek Date: Sun, 1 Nov 2020 17:05:40 +0100 Subject: [PATCH 2/2] Use f-strings. --- scr/activity_generator.py | 2 +- scr/activity_parser.py | 7 +++---- scr/soc_generator.py | 3 +-- scr/soc_parser.py | 11 +++++------ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/scr/activity_generator.py b/scr/activity_generator.py index 98b4369..02a6ac0 100755 --- a/scr/activity_generator.py +++ b/scr/activity_generator.py @@ -105,7 +105,7 @@ def generate_activity(template, activity): text = '' for org in activity.orgs: - text += '%s, ' % (org.url, org.name) + text += f'{org.name}, ' template = template.replace('{{orgs}}', text[:-2]) return template diff --git a/scr/activity_parser.py b/scr/activity_parser.py index 9815282..b126604 100755 --- a/scr/activity_parser.py +++ b/scr/activity_parser.py @@ -107,12 +107,11 @@ def parse_csv(f): if not header_loaded or line[0] == '-': continue if len(line) < 16: - logging.warning('Not enough columns of activity #%i' % (i+1)) + logging.warning(f'Not enough columns of activity #{i+1}') continue if line[0] == '': - logging.warning('Empty ID of activity #%i (%s)' % ( - i+1, line[column_map['full-name']] - )) + logging.warning(f'Empty ID of activity #{i+1} ' + f'({line[column_map["full-name"]]})') continue out.append(Activity(line, column_map)) diff --git a/scr/soc_generator.py b/scr/soc_generator.py index 883f760..bcef2cb 100755 --- a/scr/soc_generator.py +++ b/scr/soc_generator.py @@ -92,8 +92,7 @@ def generate_soc(template, topic): icon_text = '' for t in topic.fields: icon_text += ('
%s
' % - (t, t, t)) + f'soc-icon/{t}.svg" alt="{t}" title="{t}"/>') svg_path = os.path.join(IMAGE_DIR, f'{t}.svg') if not os.path.isfile(svg_path): logging.warning(f'Missing file {svg_path} for SOC {topic.id}') diff --git a/scr/soc_parser.py b/scr/soc_parser.py index 89383d7..8d43018 100755 --- a/scr/soc_parser.py +++ b/scr/soc_parser.py @@ -109,12 +109,11 @@ def parse_topic_csv(f): if not header_loaded or line[0] == '-': continue if len(line) < 7: - logging.warning('Not enough columns of SOC #%i' % (i+1)) + logging.warning(f'Not enough columns of SOC #{i+1}') continue if line[0] == '': - logging.warning('Empty ID of SOC #%i (%s)' % ( - i+1, line[column_map['name']] - )) + logging.warning(f'Empty ID of SOC #{i+1} ' + f'({line[column_map["name"]]})') continue out.append(SOC(line, column_map)) @@ -138,10 +137,10 @@ def parse_garant_csv(f): if not header_loaded or line[0] == '-': continue if len(line) < 2: - logging.warning('Not enough columns of SOC garant #%i' % (i+1)) + logging.warning(f'Not enough columns of SOC garant #{i+1}') continue if line[0] == '': - logging.warning('Empty name of SOC garant #%i' % (i+1)) + logging.warning(f'Empty name of SOC garant #{i+1}') continue out.append(Garant(line, column_map))