Repository navigation
Conversation
--paper handed any name straight to the PDF library, so eg. `--paper a5` was accepted, even though only Letter, Legal, A4 and Photo are supported (PAPER_FORMATS, and the sizes offered by the GUI). A5 is too small to hold a Paper Wallet (7.75 inches wide, vs. 5.8 inches for a portrait A5 page), which ended in a ZeroDivisionError (pjkundert#10); and `--paper photo` failed with "Unknown page format: photo", as the Photo size is not a paper name the PDF library knows. Convert --paper (case-insensitively) through PAPER_FORMATS, and refuse other sizes up front with a one-line message: error: argument --paper: Unsupported paper size 'a5'; use one of: Letter, Legal, A4, Photo Add main_test.py. See pjkundert#10.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #10 (see also the comment there about A5).
--paperhands any name straight to the PDF library, so--paper a5is accepted even though only Letter, Legal, A4 and Photo are supported (PAPER_FORMATS, which are also the sizes the GUI offers). A5 is too small to hold a Paper Wallet (7.75 inches wide, vs. 5.8 inches for a portrait A5 page), andpython3 -m slip39 -w password --paper a5ends inZeroDivisionError: division by zero(the same crash as #10, now for A5). Conversely,--paper photofails withFPDFPageFormatException: Unknown page format: photo, because Photo is a(width, height)size, not a paper name the PDF library knows.This converts
--paper(case-insensitively) throughPAPER_FORMATS, and refuses any other size up front, with a one-line message instead of a traceback:slip39/main.py(paper_format()as thetype=of--paper, plus the help text), and the--paperline of the usage inREADME.org.slip39/main_test.py: the name conversion (includingPhoto), the refusal ofa5/a3/tabloid, and thata4andPhotoproduce a PDF.pytest(without the invoice/communications tests, which need optional packages): 44 passed, 4 skipped.Note that this makes other paper sizes that the PDF library happens to accept (A3, Tabloid, ...) an error. If you'd rather keep
--paperopen-ended, #29 (a guard against the ZeroDivisionError for any component wider than the page) is independent of this, and I'm happy to drop this one.