-
Notifications
You must be signed in to change notification settings - Fork 78
Refactor statement handling #311
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
Conversation
… even when there are multiple statements in a language
… of multiple problems
fb0889d to
5184cc8
Compare
|
|
||
| def convert(problem: str, options: argparse.Namespace) -> bool: | ||
| def convert(problem_root: Path, options: argparse.Namespace, statement_file: Path) -> bool: | ||
| """Convert a Markdown statement to HTML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should document that output will be written to current working directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it? I'm pretty sure it'll be written to destfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I meant from the perspective of this code, it's the current working directory. copy_image will dump images to the working directory (destdir). When I was reading this code by itself, I missed that "we are in output directory" is a precondition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Feels like that also goes into the follow-up that deals with the other issue you raised w.r.t. copy_image.
| if os.path.isfile(img_src): # already copied | ||
| return | ||
| shutil.copyfile(source_name, img_src) | ||
| shutil.copyfile(statement_dir / img_src, img_src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not your fault, but does this actually work as we expect it to? When I read the spec, I don't see subfolders being disallowed. https://www.kattis.com/problem-package-format/spec/2023-07-draft.html#problem-statements
I.e., what happens if img_src points to a subfolder in statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I'll leave that for a follow-up
We used to have at least 3 implementations of code that found statements for a problem, all of them inconsistent. This makes use of the new methods in
statement_utilto unify the implementation. That fix blew up a bit, as it touched a lot of old parts (including our latex templates).I opted not to maintain the "0.1" version of our latex templates any longer. Support for that is now removed. It seemed broken (rendering empty pdf:s) when I tested.
This PR also continues moving from
strtopathlib.Pathfor paths. A lot of our code deals with paths, and I think usingPaththroughout the code is a significant improvement.Improves our
mypyconfiguration to not allow missing imports. As we are heavy users of a library without type annotations (plasTeX), I also mademypyfollow untyped imports. It seems likeplasTeXactually has a decent number of type annotations, just that they haven't marked the package as such.Fixes an untracked bug where
verifyproblemstopped after the first problem when one listed multiple problems.Fixes #282
Closes #310