Repository navigation
TrayLayout: accept the escaped layout from the SVG command line - #977
Merged
florianfesti merged 1 commit intoOct 17, 2026
Merged
florianfesti merged 1 commit into
florianfesti merged 1 commit into
Conversation
The "Command line" stored in the SVG writes the layout's newlines as a literal \n so the command fits on one line. TrayLayout split the layout only on real newlines, so running that command again read the whole grid as one line and failed with "Need more than one wall in y direction". Decode the literal \n when the layout contains no real newline. Fixes #973
Owner
|
I am not quite sure what work flow you are using to need this. But it is the right thing to do - especially given that we do produce the CLI ourselves. |
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.
Fixes #973.
parseArgsstores a "Command line" in the SVG metadata. ItscliQuote()writes the layout's newlines as a literal\n, so the command fits on one line.TrayLayout.prepare()splits--layoutonly on real newlines, so running that command again reads the whole grid as one line and fails withValueError: Need more than one wall in y direction.prepare()now turns a literal\nback into a newline when the layout has no real newline, which is exactly the shapecliQuote()produces. A hand-written layout or a layout from the web form contains real newlines and is left untouched, and the layout characters never include a backslash.GridfinityTrayLayoutinherits the fix. I leftcliQuote()alone: it has no portable way to put a newline into a one-line shell command, since$'…'is bash-only andshlexcan't parse it.This is separate from #974, which changes the
--layoutdefault for #972. That PR also touchestests/test_traylayout.py, so whichever lands second may need a small merge.Test:
test_command_line_from_svg_can_be_run_againrenders the layout and takes the storedmetadata["cli"]. It asserts that the stored--layoutargument contains a literal\nand no real newline, splits the command withshlex, and renders it again. Thex,y,hwalls,vwallsandfloorsmust match the original.ValueError: Need more than one wall in y direction, the error from the issueruff checkandmypyare clean on the changed files.