From ecb795ec368eed3c9e1c6e87e5d086cf1e3c6cc6 Mon Sep 17 00:00:00 2001 From: aoi-buh Date: Wed, 20 Nov 2024 18:36:12 -0700 Subject: [PATCH 1/2] Fixing previous patches for add and setfingermap. --- cmds/add.py | 3 --- cmds/setfingermap.py | 2 -- util/parser.py | 4 +++- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmds/add.py b/cmds/add.py index 6a57f8642e1..8421510d35a 100644 --- a/cmds/add.py +++ b/cmds/add.py @@ -20,9 +20,6 @@ def exec(message: Message): size = len(row) - len(row.lstrip()) spaces.append(size) - # Subtracting the min prepending space off of each line so the board shape is defined from the relative shape of the input and you can have prepending spaces. - spaces = [row - min(spaces) for row in spaces] - # Determine board type with leading whitespace if spaces[0] < spaces[1] < spaces[2]: board = 'stagger' diff --git a/cmds/setfingermap.py b/cmds/setfingermap.py index f60f6d6df7d..dbe21cc4426 100644 --- a/cmds/setfingermap.py +++ b/cmds/setfingermap.py @@ -75,8 +75,6 @@ def board_value(rows): size = len(row) - len(row.lstrip()) spaces.append(size) - spaces = [row - min(spaces) for row in spaces] - # Determine board type with leading whitespace if spaces[0] < spaces[1] < spaces[2]: return 'stagger' diff --git a/util/parser.py b/util/parser.py index c351e7bbcfa..9ce1cfd80d0 100644 --- a/util/parser.py +++ b/util/parser.py @@ -19,7 +19,9 @@ def get_layout(message: Message) -> Tuple[str, str]: args = tokens[0].split() name = '-'.join(args[2:] if args[0] in TRIGGERS else args[1:]).lower() - matrix = tokens[1].strip().lower() + lines = tokens[1].splitlines()[1:] + min_space = min(len(row) - len(row.lstrip()) for row in lines) + matrix = '\n'.join([line[min_space:] for line in lines]) return name, matrix From e63efeb9c2b237eeb73d7ea13eca92b540380cd6 Mon Sep 17 00:00:00 2001 From: aoi-buh Date: Wed, 20 Nov 2024 23:12:47 -0700 Subject: [PATCH 2/2] Made it better. --- util/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/parser.py b/util/parser.py index 9ce1cfd80d0..8f5657ef048 100644 --- a/util/parser.py +++ b/util/parser.py @@ -19,8 +19,8 @@ def get_layout(message: Message) -> Tuple[str, str]: args = tokens[0].split() name = '-'.join(args[2:] if args[0] in TRIGGERS else args[1:]).lower() - lines = tokens[1].splitlines()[1:] - min_space = min(len(row) - len(row.lstrip()) for row in lines) + lines = [line for line in tokens[1].splitlines() if line.strip() != ''] + min_space = min(len(line) - len(line.lstrip()) for line in lines) matrix = '\n'.join([line[min_space:] for line in lines]) return name, matrix