Skip to content

Commit

Permalink
Update 30-enable-kotlin.py
Browse files Browse the repository at this point in the history
Make it compatible with future domjusge versions
  • Loading branch information
robertdijk committed Aug 3, 2023
1 parent 76806da commit 45250ef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docker/domserver/scripts/patches.d/30-enable-kotlin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python3

import pathlib
import re

dj_source = next(pathlib.Path("/domjudge-src").glob("domjudge*"))
language_fixture_php = dj_source / "webapp/src/DataFixtures/DefaultData/LanguageFixture.php"
Expand All @@ -9,9 +10,14 @@
lines = f.readlines()

for i in range(len(lines)):
if lines[i] == " ['kt', 'kotlin', 'Kotlin', ['kt'], true, 'Main class', false, true, 1, 'kt'],\n":
lines[i] = " ['kt', 'kotlin', 'Kotlin', ['kt'], true, 'Main class', true, true, 1, 'kt'],\n"
break
elements = lines[i].split(',')

if len(elements) >= 10 and elements[6].strip().lower() == 'false':
if 'kt' in elements[0]:
elements[6] = 'true'

lines[i] = ','.join(elements)
break
else:
print(f"Couldn't find kotlin line in {language_fixture_php}")
exit(1)
Expand Down

0 comments on commit 45250ef

Please sign in to comment.