Keybind path (#601)

This commit is contained in:
end-4
2024-06-16 21:46:18 +07:00
committed by GitHub
3 changed files with 26 additions and 7 deletions
+6 -1
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
import re
import os
from os.path import expandvars as os_expandvars
from typing import Dict, List
@@ -35,7 +36,9 @@ class Section(dict):
def read_content(path: str) -> str:
with open(os_expandvars(path), "r") as file:
if (not os.access(os.path.expanduser(os.path.expandvars(path)), os.R_OK)):
return ("error")
with open(os.path.expanduser(os.path.expandvars(path)), "r") as file:
return file.read()
@@ -207,6 +210,8 @@ def get_binds_recursive(current_content, scope):
def parse_keys(path: str) -> Dict[str, List[KeyBinding]]:
global content_lines
content_lines = read_content(path).splitlines()
if content_lines[0] == "error":
return "error"
return get_binds_recursive(Section([], [], ""), 0)