Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use f-strings #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scr/activity_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def generate_activity(template, activity):

text = ''
for org in activity.orgs:
text += '<a href="%s" target="_blank">%s</a>, ' % (org.url, org.name)
text += f'<a href="{org.url}" target="_blank">{org.name}</a>, '
template = template.replace('{{orgs}}', text[:-2])

return template
Expand Down
7 changes: 3 additions & 4 deletions scr/activity_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
8 changes: 3 additions & 5 deletions scr/soc_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,10 @@ def generate_soc(template, topic):
icon_text = ''
for t in topic.fields:
icon_text += ('<div class="soc-field-image"><img src="/static/'
'soc-icon/%s.svg" alt="%s" title="%s"/></div>' %
(t, t, t))
svg_path = os.path.join(IMAGE_DIR, '%s.svg' % (t))
f'soc-icon/{t}.svg" alt="{t}" title="{t}"/></div>')
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
Expand Down
11 changes: 5 additions & 6 deletions scr/soc_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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))

Expand Down