normalize scraper behavior
This commit is contained in:
parent
91c37e35e5
commit
3fbbfa9423
6 changed files with 22 additions and 45 deletions
|
|
@ -129,6 +129,7 @@ Here's an example configuration with lazy.nvim: >lua
|
|||
{
|
||||
'barrett-ruth/cp.nvim',
|
||||
cmd = 'CP',
|
||||
build = 'uv sync',
|
||||
opts = {
|
||||
contests = {
|
||||
default = {
|
||||
|
|
@ -152,8 +153,6 @@ Here's an example configuration with lazy.nvim: >lua
|
|||
run_panel = {
|
||||
ansi = true,
|
||||
diff_mode = 'vim',
|
||||
next_test_key = '<c-n>',
|
||||
prev_test_key = '<c-p>',
|
||||
max_output_lines = 50,
|
||||
},
|
||||
diff = {
|
||||
|
|
@ -162,7 +161,7 @@ Here's an example configuration with lazy.nvim: >lua
|
|||
'--word-diff-regex=.', '--no-prefix' },
|
||||
},
|
||||
},
|
||||
picker = 'telescope', -- 'telescope', 'fzf-lua', or nil (disabled)
|
||||
picker = 'telescope',
|
||||
}
|
||||
}
|
||||
<
|
||||
|
|
@ -228,8 +227,6 @@ is required:
|
|||
{diff_mode} (string, default: "none") Diff backend: "none", "vim", or "git".
|
||||
"none" displays plain buffers without highlighting,
|
||||
"vim" uses built-in diff, "git" provides character-level precision.
|
||||
{next_test_key} (string, default: "<c-n>") Key to navigate to next test case.
|
||||
{prev_test_key} (string, default: "<c-p>") Key to navigate to previous test case.
|
||||
{toggle_diff_key} (string, default: "<c-t>") Key to cycle through diff modes.
|
||||
{max_output_lines} (number, default: 50) Maximum lines of test output.
|
||||
|
||||
|
|
@ -533,10 +530,8 @@ prevent them from being overridden: >lua
|
|||
|
||||
==============================================================================
|
||||
RUN PANEL KEYMAPS *cp-test-keys*
|
||||
<c-n> Navigate to next test case (configurable via
|
||||
run_panel.next_test_key)
|
||||
<c-p> Navigate to previous test case (configurable via
|
||||
run_panel.prev_test_key)
|
||||
<c-n> Navigate to next test case
|
||||
<c-p> Navigate to previous test case
|
||||
t Cycle through diff modes: none → git → vim
|
||||
q Exit run panel and restore layout
|
||||
<c-q> Exit interactive terminal and restore layout
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ function M.set_contest_data(platform, contest_id, problems)
|
|||
local out = {
|
||||
name = prev.name,
|
||||
display_name = prev.display_name,
|
||||
problems = vim.deepcopy(problems),
|
||||
problems = problems,
|
||||
index_map = {},
|
||||
}
|
||||
for i, p in ipairs(out.problems) do
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
---@class RunPanelConfig
|
||||
---@field ansi boolean Enable ANSI color parsing and highlighting
|
||||
---@field diff_mode "none"|"vim"|"git" Diff backend to use
|
||||
---@field next_test_key string Key to navigate to next test case
|
||||
---@field prev_test_key string Key to navigate to previous test case
|
||||
---@field max_output_lines number Maximum lines of test output to display
|
||||
|
||||
---@class DiffGitConfig
|
||||
|
|
@ -90,8 +88,6 @@ M.defaults = {
|
|||
run_panel = {
|
||||
ansi = true,
|
||||
diff_mode = 'none',
|
||||
next_test_key = '<c-n>',
|
||||
prev_test_key = '<c-p>',
|
||||
max_output_lines = 50,
|
||||
},
|
||||
diff = {
|
||||
|
|
@ -196,20 +192,6 @@ function M.setup(user_config)
|
|||
end,
|
||||
"diff_mode must be 'none', 'vim', or 'git'",
|
||||
},
|
||||
next_test_key = {
|
||||
config.run_panel.next_test_key,
|
||||
function(value)
|
||||
return type(value) == 'string' and value ~= ''
|
||||
end,
|
||||
'next_test_key must be a non-empty string',
|
||||
},
|
||||
prev_test_key = {
|
||||
config.run_panel.prev_test_key,
|
||||
function(value)
|
||||
return type(value) == 'string' and value ~= ''
|
||||
end,
|
||||
'prev_test_key must be a non-empty string',
|
||||
},
|
||||
max_output_lines = {
|
||||
config.run_panel.max_output_lines,
|
||||
function(value)
|
||||
|
|
|
|||
|
|
@ -18,12 +18,7 @@ function M.set_platform(platform)
|
|||
return false
|
||||
end
|
||||
|
||||
if state.get_platform() == platform then
|
||||
logger.log(('platform already set to %s'):format(platform))
|
||||
else
|
||||
state.set_platform(platform)
|
||||
logger.log(('platform set to %s'):format(platform))
|
||||
end
|
||||
state.set_platform(platform)
|
||||
|
||||
return true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -273,21 +273,14 @@ function M.toggle_run_panel(is_debug)
|
|||
config.run_panel.diff_mode = modes[(current_idx % #modes) + 1]
|
||||
refresh_run_panel()
|
||||
end, { buffer = buf, silent = true })
|
||||
vim.keymap.set('n', config.run_panel.next_test_key, function()
|
||||
vim.keymap.set('n', '<c-n>', function()
|
||||
navigate_test_case(1)
|
||||
end, { buffer = buf, silent = true })
|
||||
vim.keymap.set('n', config.run_panel.prev_test_key, function()
|
||||
vim.keymap.set('n', '<c-p>', function()
|
||||
navigate_test_case(-1)
|
||||
end, { buffer = buf, silent = true })
|
||||
end
|
||||
|
||||
vim.keymap.set('n', config.run_panel.next_test_key, function()
|
||||
navigate_test_case(1)
|
||||
end, { buffer = test_buffers.tab_buf, silent = true })
|
||||
vim.keymap.set('n', config.run_panel.prev_test_key, function()
|
||||
navigate_test_case(-1)
|
||||
end, { buffer = test_buffers.tab_buf, silent = true })
|
||||
|
||||
setup_keybindings_for_buffer(test_buffers.tab_buf)
|
||||
|
||||
local execute = require('cp.runner.execute')
|
||||
|
|
|
|||
|
|
@ -265,14 +265,26 @@ class AtcoderScraper(BaseScraper):
|
|||
|
||||
async def scrape_contest_metadata(self, contest_id: str) -> MetadataResult:
|
||||
async def impl(cid: str) -> MetadataResult:
|
||||
rows = await asyncio.to_thread(_scrape_tasks_sync, cid)
|
||||
try:
|
||||
rows = await asyncio.to_thread(_scrape_tasks_sync, cid)
|
||||
except requests.HTTPError as e:
|
||||
if e.response is not None and e.response.status_code == 404:
|
||||
return self._create_metadata_error(
|
||||
f"No problems found for contest {cid}", cid
|
||||
)
|
||||
raise
|
||||
|
||||
problems = _to_problem_summaries(rows)
|
||||
if not problems:
|
||||
return self._create_metadata_error(
|
||||
f"No problems found for contest {cid}", cid
|
||||
)
|
||||
|
||||
return MetadataResult(
|
||||
success=True, error="", contest_id=cid, problems=problems
|
||||
success=True,
|
||||
error="",
|
||||
contest_id=cid,
|
||||
problems=problems,
|
||||
)
|
||||
|
||||
return await self._safe_execute("metadata", impl, contest_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue