Skip to content

Commit

Permalink
fix #320: skip building pdfs for zip --kattis
Browse files Browse the repository at this point in the history
  • Loading branch information
RagnarGrootKoerkamp committed Oct 31, 2023
1 parent 455f0aa commit aa7e6ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
19 changes: 12 additions & 7 deletions bin/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def revert():

# Write any .lang.pdf files to .pdf.
def remove_language_suffix(fname, statement_language):
if not statement_language:
return fname
out = Path(fname)
if out.suffixes == ['.' + statement_language, '.pdf']:
out = out.with_suffix('').with_suffix('.pdf')
Expand All @@ -48,13 +50,16 @@ def build_samples_zip(problems, statement_language):
zf = zipfile.ZipFile(
'samples.zip', mode="w", compression=zipfile.ZIP_DEFLATED, allowZip64=False
)
for fname in glob(Path('.'), f'contest*.{statement_language}.pdf'):
if Path(fname).is_file():
zf.write(
fname,
remove_language_suffix(fname, statement_language),
compress_type=zipfile.ZIP_DEFLATED,
)

# Do not include contest PDF for kattis.
if not config.args.kattis:
for fname in glob(Path('.'), f'contest*.{statement_language}.pdf'):
if Path(fname).is_file():
zf.write(
fname,
remove_language_suffix(fname, statement_language),
compress_type=zipfile.ZIP_DEFLATED,
)

for problem in problems:
outputdir = Path(problem.label)
Expand Down
11 changes: 7 additions & 4 deletions bin/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,14 +951,17 @@ def run_parsed_arguments(args):
success &= generate.generate(problem)
config.args = old_args

success &= latex.build_problem_pdfs(problem)
if not config.args.kattis:
success &= latex.build_problem_pdfs(problem)
# Add problem PDF for only one language to the zip file
statement_language = force_single_language(problems)
else:
statement_language = None

if not config.args.force:
success &= problem.validate_format('input_format', constraints={})
success &= problem.validate_format('output_format', constraints={})

# Add problem PDF for only one language to the zip file
statement_language = force_single_language(problems)

# Write to problemname.zip, where we strip all non-alphanumeric from the
# problem directory name.
success &= export.build_problem_zip(problem, output, statement_language)
Expand Down

0 comments on commit aa7e6ee

Please sign in to comment.