Nriver/trilium-py

invalid escape sequence (was Export: no argument 'savePath')

maphew opened this issue · 2 comments

This snippet worked a last week:

def export(noteId, alias):
    res = ea.export_note(
        noteId=noteId,
        format="html",
        savePath=f"out/{alias}.zip",
    )
    print(f"Export 'out/{alias}.zip'", res)
    return res

today I get:

D:\personal\metril\.pixi\envs\default\Lib\site-packages\trilium_py\client.py:874: SyntaxWarning: invalid escape sequence '\l'
  lambda x: x.replace("<", " \lt ").replace(">", " \gt "), latex_code_part
D:\personal\metril\.pixi\envs\default\Lib\site-packages\trilium_py\client.py:874: SyntaxWarning: invalid escape sequence '\g'
  lambda x: x.replace("<", " \lt ").replace(">", " \gt "), latex_code_part
Trilium appVersion: 0.63.5
Found note: FlE3sCcgtRkW maphew.com
Traceback (most recent call last):
  File "D:\personal\metril\export-note.py", line 48, in <module>
    export(id, alias)
  File "D:\personal\metril\export-note.py", line 18, in export
    res = ea.export_note(
          ^^^^^^^^^^^^^^^
TypeError: ETAPI.export_note() got an unexpected keyword argument 'savePath'

Doubling the backslashes in client.py:874 makes the syntax warning go away, but looking at git blame says the code has been single slash for at least 7 months so this is probably not the right fix:

lambda x: x.replace("<", " \\lt ").replace(">", " \\gt "), latex_code_part

ahhhh, the parameter name has changed from savePath to the pythonic save_path. Ok, so my export works. Leaving this open though because I'm wondering if the escape warning is still valid?

The code comes from this PR #28. I agree with your suggestion for the fix.