Re: A new possible approach to importing python source files

2021-12-06 Thread Edward K. Ream
On Mon, Dec 6, 2021 at 2:31 AM vitalije wrote: > I am trying to catch up with new testing and your work on importers so > far. What is the proper way to run tests in Leo, now? > Use the test-all or test-import commands. I have also defined (in my local leoPy.leo file) the following @command

Re: A new possible approach to importing python source files

2021-12-06 Thread vitalije
I am trying to catch up with new testing and your work on importers so far. What is the proper way to run tests in Leo, now? On Monday, December 6, 2021 at 12:15:47 AM UTC+1 Edward K. Ream wrote: > On Sunday, December 5, 2021 at 5:09:30 PM UTC-6 Edward K. Ream wrote: > > You are in complete

Re: A new possible approach to importing python source files

2021-12-05 Thread Edward K. Ream
On Sunday, December 5, 2021 at 5:09:30 PM UTC-6 Edward K. Ream wrote: You are in complete charge. Just remember that all (still applicable) unit > tests should pass. > One more thing. The post-pass is a kind of peephole optimizer. Almost certainly the new importer should provide similar

Re: A new possible approach to importing python source files

2021-12-05 Thread Edward K. Ream
On Sunday, December 5, 2021 at 5:02:21 PM UTC-6 vitalije wrote: > Ok. I'll try to make PR. > Thanks! Let me know if you have any questions. You are in complete charge. Just remember that all (still applicable) unit tests should pass. Edward -- You received this message because you are

Re: A new possible approach to importing python source files

2021-12-05 Thread Edward K. Ream
On Sunday, December 5, 2021 at 4:22:42 PM UTC-6 vitalije wrote: > I don't see what substantial work do you mean is required. It might be best to use Importer.check and most of the other Importer machinery. At *minimum*, the top-level node of leo/importers/python.py should remain the same.

Re: A new possible approach to importing python source files

2021-12-05 Thread vitalije
Ok. I'll try to make PR. On Sunday, December 5, 2021 at 11:27:02 PM UTC+1 Edward K. Ream wrote: > On Sunday, December 5, 2021 at 2:09:05 PM UTC-6 Edward K. Ream wrote:' > > > I have begun my study. > > Oh joy, replacing difflib (as the test file) with the "strange > indentation" unit test just

Re: A new possible approach to importing python source files

2021-12-05 Thread Edward K. Ream
On Sunday, December 5, 2021 at 2:09:05 PM UTC-6 Edward K. Ream wrote:' > I have begun my study. Oh joy, replacing difflib (as the test file) with the "strange indentation" unit test just works! My modified version of import_one_level reports "same 1". Note: there was a bug in my version of

Re: A new possible approach to importing python source files

2021-12-05 Thread vitalije
Yes, None when used as index gives the same effect as if it was omitted. aList[i:None] is the same as aList[i:]. The same is correct if None is the first index. > Substantial work would be required to fold your script into the overall infrastructure created by the base Importer class. I would

Re: A new possible approach to importing python source files

2021-12-05 Thread Edward K. Ream
On Sunday, December 5, 2021 at 9:56:03 AM UTC-6 Edward K. Ream wrote: > I have begun my study. I'll ask questions as needed. I like to ask questions of the code :-) The split_root function defines "body" as follows: def body(a, b, tag): return ''.join(lines[a-1:b and (b-1)]) The

Re: A new possible approach to importing python source files

2021-12-05 Thread Edward K. Ream
On Fri, Dec 3, 2021 at 9:09 AM vitalije wrote: > I would like to explain a little more how my code works. Thanks. I have begun my study. I'll ask questions as needed. Substantial work would be required to fold your script into the overall infrastructure created by the base Importer class. I

Re: A new possible approach to importing python source files

2021-12-03 Thread vitalije
I've attached the wrong version of script. Here is the correct one. On Friday, December 3, 2021 at 4:09:17 PM UTC+1 vitalije wrote: > >> Clearly, you think differently than I do, and that's a very good thing >> :-) I'd like to get a feel for exactly how the code works, by "seeing it in >>

Re: A new possible approach to importing python source files

2021-12-03 Thread vitalije
> > > Clearly, you think differently than I do, and that's a very good thing :-) > I'd like to get a feel for exactly how the code works, by "seeing it in > action", so to speak. I'll then attempt a theory of operation for my own > benefit. > > I think that is a good idea. I would like to

Re: A new possible approach to importing python source files

2021-12-03 Thread Edward K. Ream
On Friday, December 3, 2021 at 7:43:25 AM UTC-6 Edward K. Ream wrote: > ...on second thought I see that I can probably "sign off" on your code in a day or so. The more I think about this topic, the better I like it. I was just about to beat my head against the last failing unit test:

Re: A new possible approach to importing python source files

2021-12-03 Thread Edward K. Ream
On Friday, December 3, 2021 at 7:14:12 AM UTC-6 Edward K. Ream wrote: I'll be happy to consider a pull request containing your work. My > conditions of satisfaction: > > 1. I must be convinced that the new code is *substantially* better than > the present code. > Still true, but on second

Re: A new possible approach to importing python source files

2021-12-03 Thread Edward K. Ream
On Fri, Dec 3, 2021 at 3:42 AM vitalije wrote: > Attached to this message is an improved version of this script, which doesn't "wish away the difficulties", but does full import. Excellent work. Imo, the complexity of this script is roughly comparable to the complexity of the present code

Re: A new possible approach to importing python source files

2021-12-03 Thread vitalije
On Thursday, December 2, 2021 at 10:31:56 AM UTC+1 Edward K. Ream wrote: > > > Idea: use tokenize python module... > > This idea might work, but the attached script "wishes away" the > difficulties involved in generating code. > > Attached to this message is an improved version of this script,

Re: A new possible approach to importing python source files

2021-12-02 Thread Edward K. Ream
On Wed, Dec 1, 2021 at 4:26 PM vitalije wrote: > Idea: use tokenize python module... This idea might work, but the attached script "wishes away" the difficulties involved in generating code. 1. Tokenizing the incoming lines (scan_line) is not the problem. The present code has no trouble

Re: A new possible approach to importing python source files

2021-12-01 Thread tbp1...@gmail.com
This is more or less what I was thinking of when I brought up Python's tokenizer on the earlier thread. The tokenizer seems to function much like a SAX parser in the XML world. It basically emits a stream of events as it works through a Python file. Most of them wouldn't be of interest for