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.statuscolumn = ""
|
||||
vim.opt_local.signcolumn = "no"
|
||||
vim.opt_local.foldcolumn = "0"
|
||||
vim.opt_local.wrap = 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_set_option_value("filetype", "cptest", { buf = tab_buf })
|
||||
|
||||
vim.cmd("split")
|
||||
local content_win = vim.api.nvim_get_current_win()
|
||||
vim.api.nvim_win_set_buf(content_win, actual_buf)
|
||||
vim.cmd.split()
|
||||
vim.api.nvim_win_set_buf(0, actual_buf)
|
||||
vim.api.nvim_set_option_value("filetype", "cptest", { buf = actual_buf })
|
||||
|
||||
vim.cmd("vsplit")
|
||||
local expected_win = vim.api.nvim_get_current_win()
|
||||
vim.api.nvim_win_set_buf(expected_win, expected_buf)
|
||||
vim.cmd.vsplit()
|
||||
vim.api.nvim_win_set_buf(0, 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 = {
|
||||
tab_win = main_win,
|
||||
actual_win = content_win,
|
||||
actual_win = actual_win,
|
||||
expected_win = expected_win,
|
||||
}
|
||||
local test_buffers = {
|
||||
|
|
@ -319,10 +320,10 @@ local function toggle_test_panel(is_debug)
|
|||
|
||||
if enable_diff then
|
||||
vim.api.nvim_win_call(test_windows.expected_win, function()
|
||||
vim.cmd("diffthis")
|
||||
vim.cmd.diffthis()
|
||||
end)
|
||||
vim.api.nvim_win_call(test_windows.actual_win, function()
|
||||
vim.cmd("diffthis")
|
||||
vim.cmd.diffthis()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
@ -355,10 +356,10 @@ local function toggle_test_panel(is_debug)
|
|||
refresh_test_panel()
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "j", function()
|
||||
vim.keymap.set("n", "<c-n>", function()
|
||||
navigate_test_case(1)
|
||||
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)
|
||||
end, { buffer = test_buffers.tab_buf, silent = true })
|
||||
|
||||
|
|
|
|||
|
|
@ -200,8 +200,7 @@ def main() -> None:
|
|||
|
||||
test_list: list[dict[str, str]] = []
|
||||
for input_data, output_data in tests:
|
||||
normalized_input = "1\n" + input_data
|
||||
test_list.append({"input": normalized_input, "expected": output_data})
|
||||
test_list.append({"input": input_data, "expected": output_data})
|
||||
|
||||
result = {
|
||||
"success": True,
|
||||
|
|
|
|||
|
|
@ -32,11 +32,12 @@ def scrape(url: str) -> list[tuple[str, str]]:
|
|||
continue
|
||||
|
||||
for div in test_line_divs:
|
||||
classes = div.get("class", [])
|
||||
class_name = next(
|
||||
(
|
||||
cls
|
||||
for cls in div.get("class", [])
|
||||
if "test-example-line-" in cls
|
||||
for cls in classes
|
||||
if "test-example-line-" in cls and cls.split("-")[-1].isdigit()
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
|
@ -60,11 +61,12 @@ def scrape(url: str) -> list[tuple[str, str]]:
|
|||
continue
|
||||
|
||||
for div in test_line_divs:
|
||||
classes = div.get("class", [])
|
||||
class_name = next(
|
||||
(
|
||||
cls
|
||||
for cls in div.get("class", [])
|
||||
if "test-example-line-" in cls
|
||||
for cls in classes
|
||||
if "test-example-line-" in cls and cls.split("-")[-1].isdigit()
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
|
@ -88,7 +90,6 @@ def scrape(url: str) -> list[tuple[str, str]]:
|
|||
prefixed_input = "1\n" + input_text
|
||||
tests.append((prefixed_input, output_text))
|
||||
return tests
|
||||
|
||||
all_inputs = []
|
||||
all_outputs = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue