OneDeadKey / kalamine

Keyboard Layout Maker
MIT License
113 stars 29 forks source link

Error not clear: ord() expected a character, but string of length 2 found #193

Open Zefling opened 3 weeks ago

Zefling commented 3 weeks ago

With this file: https://git.ikilote.net/-/snippets/56

I have the following error in the console:

$ pipx run kalamine build layout.toml 
... dist/zefling.ahk
Traceback (most recent call last):
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/bin/kalamine", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/kalamine/cli.py", line 117, in build
    build_all(layout, Path("dist"))
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/kalamine/cli.py", line 53, in build_all
    file.write(klc.klc(layout))
               ^^^^^^^^^^^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/kalamine/generators/klc.py", line 387, in klc
    out = substitute_lines(out, "LAYOUT",         klc_keymap(layout))
                                                  ^^^^^^^^^^^^^^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/kalamine/generators/klc.py", line 131, in klc_keymap
    symbol = hex_ord(symbol)
             ^^^^^^^^^^^^^^^
  File "/home/zefling/.cache/pipx/b4448a5db7aab53/lib/python3.12/site-packages/kalamine/utils.py", line 10, in hex_ord
    return hex(ord(char))[2:].zfill(4)
               ^^^^^^^^^
TypeError: ord() expected a character, but string of length 2 found

The error is not very clear on the problem. It launches it in watch mode. Some modes like JSON or SVG work, but others don't.