Skip to content

Commit

Permalink
Verify problem names in yaml and tex agree, warn ow.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorehusfeldt committed Jan 15, 2024
1 parent 732de0a commit 6fdd06f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bin/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path

import config
import latex
import parallel
import program
import run
Expand Down Expand Up @@ -70,6 +71,18 @@ def _determine_statement_languages(self):
error(
f"{self.name}: Found name for language {lang} in problem.yaml, but not problem.{lang}.tex."
)
for lang in texlangs & yamllangs:
unnormalised_yamlname = self.settings.name[lang]
yamlname = ' '.join(unnormalised_yamlname.split())
with open(self.path / 'problem_statement' / f'problem.{lang}.tex') as texfile:
match tex_problem_name := latex.get_argument_for_command(texfile, 'problemname'):
case None:
warn(rf"No \problemname found in problem.{lang}.tex")
case s if s not in ["\\problemyamlname", yamlname]:
warn(f'Problem titles in problem.{lang}.tex ({tex_problem_name})' +
f' and problem.yaml ({yamlname}) differ;' +
r' consider using \problemname{\problemyamlname}.'
)
return sorted(texlangs & yamllangs)

def _read_settings(self):
Expand Down

0 comments on commit 6fdd06f

Please sign in to comment.