Skip to content
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

Bugfix/html temp file writing #54

Merged
merged 7 commits into from
Jun 6, 2024
Merged

Conversation

MischaPanch
Copy link
Collaborator

No description provided.

@MischaPanch MischaPanch requested a review from kklemon June 5, 2024 10:50
Copy link
Collaborator

@kklemon kklemon left a comment

Choose a reason for hiding this comment

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

Please keep the width and height parameters in the BaseSVGRenderer class.

# buffering=0 is very important if you want to yield inside
# Since we don't use the delete option here (we delete manually below)
# we yield outside of this context
# The code below is essentially equivalent to `with open()...write`
with NamedTemporaryFile(prefix="penai_", suffix=extension, mode=mode, delete=False) as file:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I had issues with this function again yesterday and to my surprise, I actually had to figure out that we can't just use buffering=0 here as it seems to be a requirement for writing to files in text mode for whatever reason.

The solution therefore seems to be to just flush the file after writing. We should also remove the then misleading comment.

You can also stick to the current state and I will provide a PR on top.

Copy link
Collaborator Author

@MischaPanch MischaPanch Jun 6, 2024

Choose a reason for hiding this comment

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

I removed it already I though. Also had issues

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it was already removed. Was your comment on an older version?

src/penai/svg.py Show resolved Hide resolved
src/penai/render.py Outdated Show resolved Hide resolved
src/penai/render.py Show resolved Hide resolved
@MischaPanch MischaPanch force-pushed the bugfix/html-temp-file-writing branch from 9fa795e to 93e1554 Compare June 6, 2024 09:15
@MischaPanch MischaPanch merged commit 0d741d0 into main Jun 6, 2024
2 checks passed
@MischaPanch MischaPanch deleted the bugfix/html-temp-file-writing branch June 9, 2024 16:53
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.

2 participants