Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating klc "TypeError: ord() expected a character, but string of length 2 found" #176

Closed
trilowy opened this issue Jun 1, 2024 · 2 comments · Fixed by #177
Closed

Comments

@trilowy
Copy link
Contributor

trilowy commented Jun 1, 2024

Hello,

I’m trying Kalamine to build a Bépo driver but I got an issue running:

kalamine build Bépo.yml --out Bépo.klc

(same error with wkalamine)

Output logs:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts\kalamine.exe\__main__.py", line 7, in <module>
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\kalamine\cli.py", line 155, in build
    file.write(klc.klc(layout))
               ^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\kalamine\generators\klc.py", line 384, in klc
    out = substitute_lines(out, "LAYOUT",         klc_keymap(layout))
                                                  ^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\kalamine\generators\klc.py", line 128, in klc_keymap
    symbol = hex_ord(symbol)
             ^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\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

Here is a minimalist example that reproduce the bug: Bépo.yml.txt. If you take out one more key of that example you got another bug reported here #175.

I tried the toml format and yml format, same error.

I’m on Windows, Kalamine 0.36 and Python 3.12.3.

@Geobert
Copy link
Contributor

Geobert commented Jun 1, 2024

the attachment is not parseable :-/

# kalamine keyboard layout descriptor
name: "Bépo"                      # full layout name, displayed in the keyboard settings
name8: "bepo"                     # short Windows filename: no spaces, no special chars
locale: "fr"                      # locale/language id
variant: "bepo"                   # layout variant id
author: "Trilowy"                 # author name
description: "French Bépo layout"
url: "https://bepo.fr"
version: "0.0.1"
geometry: "ISO"

full: |
  ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┲━━━━━━━━━━┓
  │     │     │     │     │     │     │     │     │     │ 9   │ 0   │     │     ┃          ┃
  │     │     │     │     │     │     │     │     │ -   │     │     │     │     ┃ ⌫        ┃
  ┢━━━━━┷━━┱──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┺━━┳━━━━━━━┫
  ┃        ┃     │     │     │     │     │     │     │     │     │     │     │     ┃       ┃
  ┃ ↹      ┃     │ '*' │     │     │     │     │     │     │     │     │     │     ┃       ┃
  ┣━━━━━━━━┻┱────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┺┓  ⏎   ┃
  ┃         ┃     │     │     │     │     │     │     │     │     │     │     │     ┃      ┃
  ┃ ⇬       ┃     │     │     │     │     │     │     │     │     │     │     │     ┃      ┃
  ┣━━━━━━┳━━┹──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┲━━┷━━━━━┻━━━━━━┫
  ┃      ┃     │     │     │     │     │     │     │     │     │     │     ┃               ┃
  ┃ ⇧    ┃     │     │     │     │     │     │     │     │     │     │     ┃ ⇧             ┃
  ┣━━━━━━┻┳━━━━┷━━┳━━┷━━━━┱┴─────┴─────┴─────┴─────┴─────┴─┲━━━┷━━━┳━┷━━━━━╋━━━━━━━┳━━━━━━━┫
  ┃       ┃       ┃       ┃                                ┃       ┃       ┃       ┃       ┃
  ┃ Ctrl  ┃ super ┃ Alt   ┃ ␣                              ┃ AltGr ┃ super ┃ menu  ┃ Ctrl  ┃
  ┗━━━━━━━┻━━━━━━━┻━━━━━━━┹────────────────────────────────┺━━━━━━━┻━━━━━━━┻━━━━━━━┻━━━━━━━┛

@trilowy
Copy link
Contributor Author

trilowy commented Jun 1, 2024

My issue is resolved, I got the dead acute accent wrong because of the doc in the generated file. I fixed it here: #177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants