Skip to content

refactor: update contest problem info extraction #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 10, 2025
Merged

Conversation

QuBenhao
Copy link
Owner

add unicode decoding

new contest fit

@QuBenhao QuBenhao requested a review from Copilot June 10, 2025 06:49
@QuBenhao QuBenhao self-assigned this Jun 10, 2025
@QuBenhao QuBenhao linked an issue Jun 10, 2025 that may be closed by this pull request
Copilot

This comment was marked as outdated.

contest py input path
@QuBenhao QuBenhao requested a review from Copilot June 10, 2025 07:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refactors contest problem info extraction by switching from regex-based HTML/script parsing to JSON-driven parsing, adds a Unicode decoding utility, and updates template file access to use relative paths.

  • Adds decode_unicode_string to handle JS-encoded Unicode sequences.
  • Updates get_contest_problem_info to parse __NEXT_DATA__ JSON instead of regex on HTML and decodes content.
  • Changes code templates to load input.json/output.json via Path for relative file access.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
python/utils/str_util.py Introduces decode_unicode_string for transforming \uXXXX, \n, and \t escapes.
python/lc_libs/contest.py Replaces regex+BeautifulSoup logic with JSON parsing from __NEXT_DATA__, updates URL.
python/constants/code_templates.py Switches to Path(__file__).parent for opening JSON files relative to the script.
Comments suppressed due to low confidence (2)

python/utils/str_util.py:36

  • Missing docstring: consider adding a brief docstring to decode_unicode_string explaining its behavior, expected input format, and return value.
def decode_unicode_string(s: str) -> str:

python/constants/code_templates.py:228

  • Missing import: Path is used here but not imported. Add from pathlib import Path at the top of the file to prevent a NameError.
root_path = Path(__file__).parent

@QuBenhao QuBenhao merged commit 8b1deeb into master Jun 10, 2025
@QuBenhao QuBenhao deleted the 155-new-contest branch June 10, 2025 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new contest
1 participant