fix(scraper/codeforces): scrape multiple tc
This commit is contained in:
parent
66b7db6da4
commit
91e066bbd6
4 changed files with 20 additions and 19 deletions
|
|
@ -2,6 +2,6 @@ vim.opt_local.number = false
|
||||||
vim.opt_local.relativenumber = false
|
vim.opt_local.relativenumber = false
|
||||||
vim.opt_local.statuscolumn = ""
|
vim.opt_local.statuscolumn = ""
|
||||||
vim.opt_local.signcolumn = "no"
|
vim.opt_local.signcolumn = "no"
|
||||||
vim.opt_local.foldcolumn = "0"
|
|
||||||
vim.opt_local.wrap = true
|
vim.opt_local.wrap = true
|
||||||
vim.opt_local.linebreak = true
|
vim.opt_local.linebreak = true
|
||||||
|
vim.opt_local.foldcolumn = "0"
|
||||||
|
|
|
||||||
|
|
@ -193,19 +193,20 @@ local function toggle_test_panel(is_debug)
|
||||||
vim.api.nvim_win_set_buf(main_win, tab_buf)
|
vim.api.nvim_win_set_buf(main_win, tab_buf)
|
||||||
vim.api.nvim_set_option_value("filetype", "cptest", { buf = tab_buf })
|
vim.api.nvim_set_option_value("filetype", "cptest", { buf = tab_buf })
|
||||||
|
|
||||||
vim.cmd("split")
|
vim.cmd.split()
|
||||||
local content_win = vim.api.nvim_get_current_win()
|
vim.api.nvim_win_set_buf(0, actual_buf)
|
||||||
vim.api.nvim_win_set_buf(content_win, actual_buf)
|
|
||||||
vim.api.nvim_set_option_value("filetype", "cptest", { buf = actual_buf })
|
vim.api.nvim_set_option_value("filetype", "cptest", { buf = actual_buf })
|
||||||
|
|
||||||
vim.cmd("vsplit")
|
vim.cmd.vsplit()
|
||||||
local expected_win = vim.api.nvim_get_current_win()
|
vim.api.nvim_win_set_buf(0, expected_buf)
|
||||||
vim.api.nvim_win_set_buf(expected_win, expected_buf)
|
|
||||||
vim.api.nvim_set_option_value("filetype", "cptest", { buf = expected_buf })
|
vim.api.nvim_set_option_value("filetype", "cptest", { buf = expected_buf })
|
||||||
|
|
||||||
|
local expected_win = vim.fn.bufwinid(expected_buf)
|
||||||
|
local actual_win = vim.fn.bufwinid(actual_buf)
|
||||||
|
|
||||||
local test_windows = {
|
local test_windows = {
|
||||||
tab_win = main_win,
|
tab_win = main_win,
|
||||||
actual_win = content_win,
|
actual_win = actual_win,
|
||||||
expected_win = expected_win,
|
expected_win = expected_win,
|
||||||
}
|
}
|
||||||
local test_buffers = {
|
local test_buffers = {
|
||||||
|
|
@ -319,10 +320,10 @@ local function toggle_test_panel(is_debug)
|
||||||
|
|
||||||
if enable_diff then
|
if enable_diff then
|
||||||
vim.api.nvim_win_call(test_windows.expected_win, function()
|
vim.api.nvim_win_call(test_windows.expected_win, function()
|
||||||
vim.cmd("diffthis")
|
vim.cmd.diffthis()
|
||||||
end)
|
end)
|
||||||
vim.api.nvim_win_call(test_windows.actual_win, function()
|
vim.api.nvim_win_call(test_windows.actual_win, function()
|
||||||
vim.cmd("diffthis")
|
vim.cmd.diffthis()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -355,10 +356,10 @@ local function toggle_test_panel(is_debug)
|
||||||
refresh_test_panel()
|
refresh_test_panel()
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set("n", "j", function()
|
vim.keymap.set("n", "<c-n>", function()
|
||||||
navigate_test_case(1)
|
navigate_test_case(1)
|
||||||
end, { buffer = test_buffers.tab_buf, silent = true })
|
end, { buffer = test_buffers.tab_buf, silent = true })
|
||||||
vim.keymap.set("n", "k", function()
|
vim.keymap.set("n", "<c-p>", function()
|
||||||
navigate_test_case(-1)
|
navigate_test_case(-1)
|
||||||
end, { buffer = test_buffers.tab_buf, silent = true })
|
end, { buffer = test_buffers.tab_buf, silent = true })
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,8 +200,7 @@ def main() -> None:
|
||||||
|
|
||||||
test_list: list[dict[str, str]] = []
|
test_list: list[dict[str, str]] = []
|
||||||
for input_data, output_data in tests:
|
for input_data, output_data in tests:
|
||||||
normalized_input = "1\n" + input_data
|
test_list.append({"input": input_data, "expected": output_data})
|
||||||
test_list.append({"input": normalized_input, "expected": output_data})
|
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
"success": True,
|
"success": True,
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,12 @@ def scrape(url: str) -> list[tuple[str, str]]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for div in test_line_divs:
|
for div in test_line_divs:
|
||||||
|
classes = div.get("class", [])
|
||||||
class_name = next(
|
class_name = next(
|
||||||
(
|
(
|
||||||
cls
|
cls
|
||||||
for cls in div.get("class", [])
|
for cls in classes
|
||||||
if "test-example-line-" in cls
|
if "test-example-line-" in cls and cls.split("-")[-1].isdigit()
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
@ -60,11 +61,12 @@ def scrape(url: str) -> list[tuple[str, str]]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for div in test_line_divs:
|
for div in test_line_divs:
|
||||||
|
classes = div.get("class", [])
|
||||||
class_name = next(
|
class_name = next(
|
||||||
(
|
(
|
||||||
cls
|
cls
|
||||||
for cls in div.get("class", [])
|
for cls in classes
|
||||||
if "test-example-line-" in cls
|
if "test-example-line-" in cls and cls.split("-")[-1].isdigit()
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
@ -88,7 +90,6 @@ def scrape(url: str) -> list[tuple[str, str]]:
|
||||||
prefixed_input = "1\n" + input_text
|
prefixed_input = "1\n" + input_text
|
||||||
tests.append((prefixed_input, output_text))
|
tests.append((prefixed_input, output_text))
|
||||||
return tests
|
return tests
|
||||||
|
|
||||||
all_inputs = []
|
all_inputs = []
|
||||||
all_outputs = []
|
all_outputs = []
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue