EvForm tracebacks with certain dissimilar line lengths of form
See original GitHub issueBrief summary of issue / Description of requested feature:
EvForm throws an exception, apparently if the form has a shorter line following a line with a cell.
In addition, the EvForm documentation reports that "CELLCHAR"
is the key name to use for the inline dict, but it is actually "FORMCHAR"
which provides the functionality.
Steps to reproduce the issue / Reasons for adding feature:
from evennia.utils.evform import EvForm
TEST_A = """
Test form: xx1xx
Won't crash?
"""
TEST_B = """
Test form: xx1xx
Crashhhhhh.
"""
TEST_A_FORM = {"FORMCHAR": "x", "TABLECHAR": "c", "FORM": TEST_A}
TEST_B_FORM = {"FORMCHAR": "x", "TABLECHAR": "c", "FORM": TEST_B}
form_a = EvForm(form=TEST_A_FORM, cells={1: 'hello'})
self.msg(form_a)
form_b = EvForm(form=TEST_B_FORM, cells={1: 'hello'})
self.msg(form_b)
Error output / Expected result of feature
File "evennia/utils/evform.py", line 215, in __init__
self.reload()
File "evennia/utils/evform.py", line 418, in reload
self.mapping = self._parse_rectangles(self.cellchar, self.tablechar, self.raw_form, **kwargs)
File "evennia/utils/evform.py", line 276, in _parse_rectangles
if all(form[iy + i][ix] == cellchar for ix in range(leftix, rightix)):
File "evennia/utils/evform.py", line 276, in
if all(form[iy + i][ix] == cellchar for ix in range(leftix, rightix)):
File "evennia/utils/ansi.py", line 888, in __getitem__
raise IndexError("ANSIString Index out of range")
IndexError: ANSIString Index out of range
Extra information, such as Evennia revision/repo/branch, operating system and ideas for how to solve / implement:
Evennia 0.7.0 (rev 2bc76538)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Coding Utils · evennia/evennia Wiki - GitHub
This function will crop a very long line, adding a suffix to show the line actually continues. This can be useful in listings...
Read more >CS697 Class Notes - UMass Boston CS
that these sequences have different lengths – this is not uncommon for protien sequences. A common approach to judging similarity is to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello all,
After a “quick” look with
pdb
, I arrived to the following:The issue happens in line 312 when
form
is accessed with the indices obtained from matching the firstxxNxx
row.https://github.com/evennia/evennia/blob/a53957096f33ce991a52921fe9a26e1984367ede/evennia/utils/evform.py#L308-L315
It seems like a
form
object is always expected to be a rectangle. See line 410. In @RyanStein’s test form, that’s not the case.https://github.com/evennia/evennia/blob/a53957096f33ce991a52921fe9a26e1984367ede/evennia/utils/evform.py#L410-L411
I’m thinking that the following could do the trick:
The
_rectangularize
function calculates the longest line and forces all lines to be of that max length, effectively converting the jaggedform
into arect
.WDYT @Griatch?
Closed with merge of PR