SeungheonOh / QMK_KeymapToAsciiTable

Convert QMK keymap file into Comment Ascii Table
MIT License
27 stars 3 forks source link

Vague errors when running script #4

Open zakrywilson opened 3 years ago

zakrywilson commented 3 years ago

Running the script on my config produces error messages and no resulting files.

Attempt 1

> ./QMK_KeymapToAsciiTable.py                                                              
./QMK_KeymapToAsciiTable.py: 2: ./QMK_KeymapToAsciiTable.py: QMKCodeDic: not found      
./QMK_KeymapToAsciiTable.py: 4: ./QMK_KeymapToAsciiTable.py: KC_NO:Null,: not found           
./QMK_KeymapToAsciiTable.py: 5: ./QMK_KeymapToAsciiTable.py: XXXXXXX:Null,: not found      
./QMK_KeymapToAsciiTable.py: 6: ./QMK_KeymapToAsciiTable.py: _______:,: not found              
./QMK_KeymapToAsciiTable.py: 7: ./QMK_KeymapToAsciiTable.py: KC_TRNS:,: not found       
./QMK_KeymapToAsciiTable.py: 8: ./QMK_KeymapToAsciiTable.py: KC_A:A,: not found

Then I realized that the script wasn't set up to be executed in that manner.

Attempt 2

> python QMK_KeymapToAsciiTable.py
  File "QMK_KeymapToAsciiTable.py", line 196
SyntaxError: Non-ASCII character '\xc2' in file QMK_KeymapToAsciiTable.py on line 196, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Which I fixed by adding encoding information to the file:

# -*- coding: utf-8 -*-

Attempt 3

> python3 QMK_KeymapToAsciiTable.py
You should execute this script the same directory where you keymap.c file is.

Which I see is what is printed out in the except block.

Here is my config: https://gist.github.com/zakrywilson/59fcbb7a214abce3d37a54f3c574ab26

Happy to help improve this, by the way, and thanks for creating it!

mvaneijgen commented 3 years ago

Have you ever got it to work?

I've tried it both with python (2.7.16) and python3 (3.9.2) and getting the same errors as you.

By adding # -*- coding: utf-8 -*- to the top of the file and running python QMK_KeymapToAsciiTable.py

  File "QMK_KeymapToAsciiTable.py", line 562
    print("Layer '{0}' have been added".format(keymapStarts),file=file)
                                                                 ^
SyntaxError: invalid syntax

It does generate a comment.txt file, but it has two empty lines in it. I've tried two of my own keymap.c files and some random board in the qmk_firmware, but all give the same error

paulchiu commented 3 years ago

I got it working with the following patch on MacOS.

diff --git a/QMK_KeymapToAsciiTable.py b/QMK_KeymapToAsciiTable.py
old mode 100644
new mode 100755
index 982ac22..fcd0faa
--- a/QMK_KeymapToAsciiTable.py
+++ b/QMK_KeymapToAsciiTable.py
@@ -1,3 +1,5 @@
+#!/usr/bin/python3
+# coding=utf8

 QMKCodeDic = {
     #BASICKEYCODES

I'm not planning on PR'ing this because the project doesn't appear active.

Rostiger commented 2 years ago

I've added

+#!/usr/bin/python3
+# coding=utf8

to the first two lines. The script runs now but it can't open keymap.c, even though the file is in the same directory.

You should execute this script the same directory where you keymap.c file is.

Any ideas what could cause this?