replace printerr with push_error and push_warning
This commit is contained in:
parent
82c9a229da
commit
a0428d90d6
@ -53,7 +53,7 @@ func swap_layout(layout_name: String) -> void:
|
|||||||
_set_layout(layouts[layout_name])
|
_set_layout(layouts[layout_name])
|
||||||
layout_swapped.emit(current_layout)
|
layout_swapped.emit(current_layout)
|
||||||
else:
|
else:
|
||||||
printerr("layout '%s' not found" % layout_name)
|
push_error("layout '%s' not found" % layout_name)
|
||||||
|
|
||||||
|
|
||||||
func _set_defaults() -> void:
|
func _set_defaults() -> void:
|
||||||
@ -76,7 +76,7 @@ func _load_config() -> Error:
|
|||||||
return FAILED
|
return FAILED
|
||||||
|
|
||||||
if err != OK:
|
if err != OK:
|
||||||
printerr("failed to load layout config file: '%s'" % err)
|
push_error("failed to load layout config file: '%s'" % err)
|
||||||
print()
|
print()
|
||||||
return FAILED
|
return FAILED
|
||||||
|
|
||||||
@ -84,12 +84,12 @@ func _load_config() -> Error:
|
|||||||
if _config.has_section_key(SECTION_INFO, PARAM_NAME):
|
if _config.has_section_key(SECTION_INFO, PARAM_NAME):
|
||||||
layout_name = _config.get_value(SECTION_INFO, PARAM_NAME, "") as String
|
layout_name = _config.get_value(SECTION_INFO, PARAM_NAME, "") as String
|
||||||
else:
|
else:
|
||||||
printerr("layout config is missing '%s/%s'" % [SECTION_INFO, PARAM_NAME])
|
push_error("layout config is missing '%s/%s'" % [SECTION_INFO, PARAM_NAME])
|
||||||
|
|
||||||
if layout_name != "" and layouts.has(layout_name):
|
if layout_name != "" and layouts.has(layout_name):
|
||||||
_set_layout(layouts[layout_name])
|
_set_layout(layouts[layout_name])
|
||||||
else:
|
else:
|
||||||
printerr("layout '%s' not found" % layout_name)
|
push_error("layout '%s' not found" % layout_name)
|
||||||
_set_defaults()
|
_set_defaults()
|
||||||
|
|
||||||
for row: Array[KeyProps] in layout_rows:
|
for row: Array[KeyProps] in layout_rows:
|
||||||
@ -126,7 +126,7 @@ func _save_config() -> Error:
|
|||||||
var err := _config.save(CONFIG_PATH)
|
var err := _config.save(CONFIG_PATH)
|
||||||
|
|
||||||
if err != OK:
|
if err != OK:
|
||||||
printerr("failed to save config file: '%s'" % err)
|
push_error("failed to save config file: '%s'" % err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
return OK
|
return OK
|
||||||
@ -136,22 +136,22 @@ func _load_custom_layouts(path: String) -> void:
|
|||||||
if not DirAccess.dir_exists_absolute(path):
|
if not DirAccess.dir_exists_absolute(path):
|
||||||
var dir_err := DirAccess.make_dir_absolute(path)
|
var dir_err := DirAccess.make_dir_absolute(path)
|
||||||
if dir_err != OK:
|
if dir_err != OK:
|
||||||
printerr("error creating directory '%s': %s" % [path, dir_err])
|
push_error("error creating directory '%s': %s" % [path, dir_err])
|
||||||
print()
|
print()
|
||||||
return
|
return
|
||||||
var file_err := DirAccess.copy_absolute(
|
var file_err := DirAccess.copy_absolute(
|
||||||
CUSTOM_LAYOUTS_README, path.path_join(CUSTOM_LAYOUTS_README.get_file())
|
CUSTOM_LAYOUTS_README, path.path_join(CUSTOM_LAYOUTS_README.get_file())
|
||||||
)
|
)
|
||||||
if file_err != OK:
|
if file_err != OK:
|
||||||
printerr("error copying file '%s': %s" % [CUSTOM_LAYOUTS_README, file_err])
|
push_error("error copying file '%s': %s" % [CUSTOM_LAYOUTS_README, file_err])
|
||||||
|
|
||||||
var dir := DirAccess.open(path)
|
var dir := DirAccess.open(path)
|
||||||
if not dir:
|
if not dir:
|
||||||
var err := DirAccess.get_open_error()
|
var err := DirAccess.get_open_error()
|
||||||
if err == ERR_FILE_NOT_FOUND:
|
if err == ERR_FILE_NOT_FOUND:
|
||||||
printerr("directory not found '%s'" % path)
|
push_error("directory not found '%s'" % path)
|
||||||
else:
|
else:
|
||||||
printerr("error opening directory '%s': %s" % [path, err])
|
push_error("error opening directory '%s': %s" % [path, err])
|
||||||
print()
|
print()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ func _load_custom_layouts(path: String) -> void:
|
|||||||
if layout.failed:
|
if layout.failed:
|
||||||
continue
|
continue
|
||||||
if layouts.has(layout.get_name()):
|
if layouts.has(layout.get_name()):
|
||||||
printerr(
|
push_warning(
|
||||||
(
|
(
|
||||||
"layout '%s' already exists and will be replaced by the new one"
|
"layout '%s' already exists and will be replaced by the new one"
|
||||||
% [layout.get_name()]
|
% [layout.get_name()]
|
||||||
|
|||||||
@ -15,14 +15,14 @@ func _init(path: String) -> void:
|
|||||||
var data: Variant = _load_json_file(path)
|
var data: Variant = _load_json_file(path)
|
||||||
if not data:
|
if not data:
|
||||||
failed = true
|
failed = true
|
||||||
printerr("%s: COULD NOT PARSE CUSTOM LAYOUT JSON" % _file_name)
|
push_error("%s: COULD NOT PARSE CUSTOM LAYOUT JSON" % _file_name)
|
||||||
print()
|
print()
|
||||||
return
|
return
|
||||||
|
|
||||||
var layout_rows := _deserialize(data, _file_name)
|
var layout_rows := _deserialize(data, _file_name)
|
||||||
if not layout_rows:
|
if not layout_rows:
|
||||||
failed = true
|
failed = true
|
||||||
printerr("%s: COULD NOT DESERIALIZE CUSTOM LAYOUT" % _file_name)
|
push_error("%s: COULD NOT DESERIALIZE CUSTOM LAYOUT" % _file_name)
|
||||||
print()
|
print()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -44,16 +44,16 @@ func _load_json_file(path: String) -> Variant:
|
|||||||
if not file:
|
if not file:
|
||||||
var file_err := FileAccess.get_open_error()
|
var file_err := FileAccess.get_open_error()
|
||||||
if file_err == ERR_FILE_NOT_FOUND:
|
if file_err == ERR_FILE_NOT_FOUND:
|
||||||
printerr("%s: file not found" % _file_name)
|
push_error("%s: file not found" % _file_name)
|
||||||
else:
|
else:
|
||||||
printerr("%s: error opening file: %s" % [_file_name, file_err])
|
push_error("%s: error opening file: %s" % [_file_name, file_err])
|
||||||
return []
|
return []
|
||||||
|
|
||||||
var content := file.get_as_text()
|
var content := file.get_as_text()
|
||||||
var json := JSON.new()
|
var json := JSON.new()
|
||||||
var err := json.parse(content)
|
var err := json.parse(content)
|
||||||
if err != OK:
|
if err != OK:
|
||||||
printerr(
|
push_error(
|
||||||
(
|
(
|
||||||
"%s: json parse error at line %s: %s"
|
"%s: json parse error at line %s: %s"
|
||||||
% [_file_name, json.get_error_line(), json.get_error_message()]
|
% [_file_name, json.get_error_line(), json.get_error_message()]
|
||||||
@ -73,7 +73,7 @@ func _deserialize(data: Variant, path: String) -> Array[Array]:
|
|||||||
elif data is Dictionary:
|
elif data is Dictionary:
|
||||||
parser = ParserQMK.new(data as Dictionary, path)
|
parser = ParserQMK.new(data as Dictionary, path)
|
||||||
else:
|
else:
|
||||||
printerr(
|
push_error(
|
||||||
"%s: top-level json item is neither an array nor a dictionary" % _file_name
|
"%s: top-level json item is neither an array nor a dictionary" % _file_name
|
||||||
)
|
)
|
||||||
return []
|
return []
|
||||||
|
|||||||
@ -259,7 +259,7 @@ func _get_keycode_from_legend(
|
|||||||
break
|
break
|
||||||
|
|
||||||
if keycode == KEY_NONE:
|
if keycode == KEY_NONE:
|
||||||
printerr("%s: could not recognize key label %s" % [_file_name, str(legend)])
|
push_warning("%s: could not recognize key label %s" % [_file_name, str(legend)])
|
||||||
_has_errors = true
|
_has_errors = true
|
||||||
|
|
||||||
return keycode
|
return keycode
|
||||||
|
|||||||
@ -182,7 +182,7 @@ func _init(data: Dictionary, file_name: String) -> void:
|
|||||||
or data[LAYOUTS] is not Dictionary
|
or data[LAYOUTS] is not Dictionary
|
||||||
or (data[LAYOUTS] as Dictionary).size() == 0
|
or (data[LAYOUTS] as Dictionary).size() == 0
|
||||||
):
|
):
|
||||||
printerr("%s: '%s' does not exist" % [_file_name, LAYOUTS])
|
push_error("%s: '%s' is missing" % [_file_name, LAYOUTS])
|
||||||
_has_errors = true
|
_has_errors = true
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -193,8 +193,8 @@ func _init(data: Dictionary, file_name: String) -> void:
|
|||||||
or not (data[LAYOUTS][layout_name] as Dictionary).has(LAYOUT)
|
or not (data[LAYOUTS][layout_name] as Dictionary).has(LAYOUT)
|
||||||
or data[LAYOUTS][layout_name][LAYOUT] is not Array
|
or data[LAYOUTS][layout_name][LAYOUT] is not Array
|
||||||
):
|
):
|
||||||
printerr(
|
push_error(
|
||||||
"%s: '%s.%s.%s' does not exist" % [_file_name, LAYOUTS, layout_name, LAYOUT]
|
"%s: '%s.%s.%s' is missing" % [_file_name, LAYOUTS, layout_name, LAYOUT]
|
||||||
)
|
)
|
||||||
_has_errors = true
|
_has_errors = true
|
||||||
return
|
return
|
||||||
@ -322,9 +322,9 @@ func _get_keymap_keys(data_keys: Array, json_file_name: String) -> Error:
|
|||||||
if not file:
|
if not file:
|
||||||
var file_err := FileAccess.get_open_error()
|
var file_err := FileAccess.get_open_error()
|
||||||
if file_err == ERR_FILE_NOT_FOUND:
|
if file_err == ERR_FILE_NOT_FOUND:
|
||||||
printerr("%s: file '%s' not found" % [_file_name, c_file_name])
|
push_error("%s: file '%s' not found" % [_file_name, c_file_name])
|
||||||
else:
|
else:
|
||||||
printerr(
|
push_error(
|
||||||
"%s: error opening file '%s': %s" % [_file_name, c_file_name, file_err]
|
"%s: error opening file '%s': %s" % [_file_name, c_file_name, file_err]
|
||||||
)
|
)
|
||||||
return FAILED
|
return FAILED
|
||||||
@ -341,7 +341,7 @@ func _get_keymap_keys(data_keys: Array, json_file_name: String) -> Error:
|
|||||||
|
|
||||||
var layout_match := layout_regex.search(content)
|
var layout_match := layout_regex.search(content)
|
||||||
if not layout_match:
|
if not layout_match:
|
||||||
printerr(
|
push_error(
|
||||||
"%s: no layout keymap definitions found in '%s'" % [_file_name, c_file_name]
|
"%s: no layout keymap definitions found in '%s'" % [_file_name, c_file_name]
|
||||||
)
|
)
|
||||||
return FAILED
|
return FAILED
|
||||||
@ -375,7 +375,7 @@ func _get_keycode_from_keymap_key(keymap_key_prefixed: String) -> Key:
|
|||||||
keycode = KEYCODE_MODIFIER_RIGHT_MAP[keymap_key]
|
keycode = KEYCODE_MODIFIER_RIGHT_MAP[keymap_key]
|
||||||
|
|
||||||
if keycode == KEY_NONE:
|
if keycode == KEY_NONE:
|
||||||
printerr(
|
push_warning(
|
||||||
"%s: could not recognize key label '%s'" % [_file_name, keymap_key_prefixed]
|
"%s: could not recognize key label '%s'" % [_file_name, keymap_key_prefixed]
|
||||||
)
|
)
|
||||||
_has_errors = true
|
_has_errors = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user