On Sun, Apr 11, 2021 at 4:16 PM jkn <[email protected]> wrote:
> Hi (Edward, probably)
Yes. I wrote this mess :-)
> I am interested in writing an importer to allow me to use the parse-body
> command...
>
...
> I'm starting with a stripped-down file...leo/plugins/importers/tds.py
>
Yes, that sounds reasonable.
> I'm a little unclear as to whether just that file will be enough;
>
Yes, it should be enough, provided that '@language tds' is supported.
I intend to select this parser by means of '@language tds', but with just
> 'noddy' contents of the tds importer I am seeing an error like:
>
> {{{
>
> Traceback (most recent call last):
>
> File "/home/jkn/leo-editor/leo/core/leoKeys.py", line 2466, in
> callAltXFunction
> func(event)
>
> File "/home/jkn/leo-editor/leo/core/leoImport.py", line 2738, in
> parse_body_command
> c.importCommands.parse_body(c.p)
>
> File "/home/jkn/leo-editor/leo/core/leoImport.py", line 1137, in parse_body
> ext = '.' + g.app.language_extension_dict.get(language)
> TypeError: can only concatenate str (not "NoneType") to str
> }}}
>
> I have tried creating a matching file colorizor leo/modes/tds.py, without
> success
>
Creating modes/tds.py only affects colorizing. It should have no effect on
importers.
Any thoughts? In any case, that error message might be improved IMO
>
Hehe. I agree the message leaves a bit to be desired.
However, the traceback is actually pretty informative. As usual, the last
two lines are the most informative. Clearly, g.app.language_extension_dict.get(
language) is returning None.
The "language" var comes from the line:
language = g.scanForAtLanguage(c, p), so yes, you must support your new
language by creating entries in three language dictionaries. See the node
"app.__init__ (helpers contain language dicts)" in leoApp.py.
*Summary*
You have to make @language tds work by creating entries for tds in three
dictionaries in leoApp.py.
You have to create an importer for .tds files.
parse_body shouldn't crash if g.app.language_extension_dict.get( language)
is None.
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/CAMF8tS0JJdCvPbEFL9v5E9%2B7W9443m_Avg7o5_tkqdiY9LL%3DMQ%40mail.gmail.com.