Nriver / trilium-py

Python client for ETAPI of Trilium Note. Trilium 的 Python版 ETAPI 客户端
GNU Affero General Public License v3.0
118 stars 27 forks source link

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

Closed maphew closed 4 months ago

maphew commented 4 months ago

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
maphew commented 4 months ago

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?

Nriver commented 4 months ago

The code comes from this PR https://github.com/Nriver/trilium-py/pull/28. I agree with your suggestion for the fix.