msg193358 - (view) |
Author: R. Jayakrishnan (JayKrish) * |
Date: 2013-07-19 13:00 |
|
|
|
|
|
|
|
|
|
Following the Idle: mock Text class and test thereof created #18365 I am trying to improve the _decode function because most of the Idletests needs the mock text and requires some more features to handle indexes. Started improving the mockText _decode method while writing unit test for AutoExpand.py at #18292. For now I want the mock text to decode following indexes: line.char, insert, end, +-#c/chars, lineend, linestart, wordstart, wordend For this I am trying to write regular expressions to extract the parts of index. The submitted decodeTest.py is a sample script to show how my regular expression starts manipulating the decoding of indexes. I have attached a checklist of several indexes. So you can easily run them and get an understanding of my approach. |
|
|
|
|
|
|
|
|
|
|
|
msg193395 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2013-07-20 02:31 |
|
|
|
|
|
|
|
|
|
Further changes should be aimed at actual idlelib uses. Wordstart and wordend are used once each in AutoExpand.py (and wordstart a couple of times for tag.start positions). So forget them. Does idlelib really have indexes like "2.3 + 1c" ('2.4'), "2.3-1c" ('2.2'), and "22.33-1chars" ('22.32')? The grammar we need to parse is something like index := base modifier* # nearly always 0, 1, few 2, one 3 times, so index := base modifier{0:3} index := base modmaybe modmaybe modmaybe base := numpair | mark numpair := int '.' ( int |
'end' ) mark := 'end' |
'insert' |
'iomark' |
'my_anchor' |
'sel.first' |
sel.last # parts tags but this should work modmaybe := modifier |
'' modifier := ' linestart' |
' lineend' |
incr incr := ' '* ('+' |
'-') ' '* int ('c' |
'line') # Could change the one 'char' to 'c' Rather than parse an entire index at once, parse, interpret as position, and remove base from input. While remainder, parse, apply to position, and remove from remainder. Whether the parsing is done with base and modifier REs with groups or code or some mixture does not much matter. |
msg193740 - (view) |
Author: R. Jayakrishnan (JayKrish) * |
Date: 2013-07-26 20:35 |
|
|
|
|
|
|
|
|
|
Yes,correcting myself. I should aim indexes which actual idlelib uses. Thank you Terry for the grammar. Fighting with the index parsing last week, and finally came up with a level to break the index into base and modifier and decode it along with using regular expressions. Now the mock_tk attached at this patch passes all the existing test cases, and failing the new test I have written on text_test The problem now I am dealing with is, there are four exceeding conditions I have to handle which make errors. 1.returning line < 0 2.returning line > last line 3.returning char < 0 4.returning char > its line length For example, in parsing base the return line may exceed last line but the modifier will say '-2lines' doing that, now the return line is not exceeding last line. |
|
|
|
|
|
|
|
|
|
|
|
msg219502 - (view) |
Author: Saimadhav Heblikar (Saimadhav.Heblikar) * |
Date: 2014-06-01 14:44 |
|
|
|
|
|
|
|
|
|
This patch tries to enable mock_Tk.Text._decode to handle the following patterns insert linestart insert lineend insert wordstart insert wordend insert +x chars insert -x chars These additions are required for testing AutoExpand and are written keeping the same in mind. Also, adds respective tests for test_decode in test_text.py. I would like to know if my approach is acceptable or whether it needs changes. is about adding unittests for AutoExpand. (A 2.7 patch will be submitted once the above changes become acceptable) |
|
|
|
|
|
|
|
|
|
|
|