Sorry, I've missed your two posts. I've been working on new branch `importers` today.
While looking at the importer pipeline, I've noticed several conversion text to lines and backwards. First split is in checking tabs and spaces, if there are mixed tabs and spaces, again text is turned into lines, and back to text. Finally in gen_lines the same input text is once again divided in lines. So, I've changed all methods to accept lines as input argument instead of text. There were several places to change, in almost all importers that override gen_lines, but changes were minimal. All unit tests passed except two related to leoAst that fail. After that I've marked all test methods in test_leoImport.TestPython for skipping and I've started to add my own tests. The old tests were checking only on headlines. Using new utility method for checking outline: def check_outline(self, p, nodes): it = iter(nodes) zlev = p.level() for p1 in p.self_and_subtree(): lev, h, b = next(it) assert p1.level()-zlev == lev, f'lev:{p1.level()-zlev} != {lev}' if lev > 0: assert p1.h == h, f'"{p1.h}" != "{h}"' assert p1.b == b, f'\n{repr(p1.b)} !=\n{repr(b)}' try: next(it) return False, 'extra nodes' except StopIteration: return True, 'ok' Now, both structure and content are checked. After I've added 6 new tests with some corner cases that I've found to be interesting, I've deleted all other old tests in TestPython class. You can check the tests and suggest any new test case. If you just provide Leo outline for interesting cases, I can easily turn them into test methods. >From outline it is easy to get source text, and expected node structure. All new tests have same form: def test_something(self): txt = '''sourcecode''' exp_nodes = [(lev, h, b),...] p = self.run_test(txt) ok, msg = self.check_outline(p, exp_nodes) assert ok, msg Look at the branch `importers` and we can discus what I've accomplished so far. I don't think there will be any serious problems in the future. Function split_root, should have some more comments and perhaps better var names, before PR is ready, but all remaining tweaks should be easy. Let me know what do you think about the results of new python importer. Vitalije On Monday, December 6, 2021 at 10:01:02 PM UTC+1 Edward K. Ream wrote: > On Monday, December 6, 2021 at 10:35:03 AM UTC-6 Edward K. Ream wrote: > > > I shall soon convert all tests so that they use check_headlines rather > than the more verbose equivalent. > > Done in devel at rev c65459. In the tests I have marked headlines that > should not be generated, or have poor headlines. Vitalije, feel free to > adjust the arguments so the call passes. > > Edward > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/f54984cc-86c5-47c3-a4a1-b377beca05acn%40googlegroups.com.