mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
configdump: better logging; insert (still unsupported) array/dict raw value and 2do markers into produced dump JSON
This commit is contained in:
committed by
Igor Pečovnik
parent
f12015954a
commit
7d90b10f79
@@ -16,6 +16,7 @@ function cli_config_dump_json_run() {
|
||||
do_capturing_defs config_board_and_remove_useless < /dev/null # this sets CAPTURED_VARS_NAMES and CAPTURED_VARS_ARRAY; the < /dev/null is take away the terminal from stdin
|
||||
|
||||
# convert to JSON, using python helper; each var is passed via a command line argument; that way we avoid newline/nul-char separation issues
|
||||
display_alert "Dumping JSON" "for ${#CAPTURED_VARS_ARRAY[@]} variables" "ext"
|
||||
python3 "${SRC}/lib/tools/configdump2json.py" "--args" "${CAPTURED_VARS_ARRAY[@]}" # to stdout
|
||||
|
||||
return 0
|
||||
|
||||
@@ -14,6 +14,8 @@ log: logging.Logger = logging.getLogger("bash_declare_parser")
|
||||
|
||||
REGEX_BASH_DECLARE_DOUBLE_QUOTE = r"declare (-[-xr]) (.*?)=\"(.*)\""
|
||||
REGEX_BASH_DECLARE_SINGLE_QUOTE = r"declare (-[-xr]) (.*?)=\$'(.*)'"
|
||||
REGEX_BASH_DECLARE_ASSOCIATIVE_ARRAY = r"declare (-[A]) (.*?)=\((.*)\)"
|
||||
REGEX_BASH_DECLARE_SIMPLE_ARRAY = r"declare (-[a]) (.*?)=\((.*)\)"
|
||||
|
||||
|
||||
class BashDeclareParser:
|
||||
@@ -37,6 +39,18 @@ class BashDeclareParser:
|
||||
value = self.parse_dequoted_value(match.group(2), self.armbian_value_parse_single_quoted(match.group(3)))
|
||||
all_keys[match.group(2)] = value
|
||||
|
||||
if count_matches == 0:
|
||||
# try for the (A)ssociative Array version
|
||||
for matchNum, match in enumerate(re.finditer(REGEX_BASH_DECLARE_ASSOCIATIVE_ARRAY, one_declare, re.DOTALL), start=1):
|
||||
count_matches += 1
|
||||
all_keys[match.group(2)] = ["@TODO", "bash associative arrays aka dictionaries are not supported yet", match.group(3)]
|
||||
|
||||
if count_matches == 0:
|
||||
# try for the simple (a)rray version
|
||||
for matchNum, match in enumerate(re.finditer(REGEX_BASH_DECLARE_SIMPLE_ARRAY, one_declare, re.DOTALL), start=1):
|
||||
count_matches += 1
|
||||
all_keys[match.group(2)] = ["@TODO", "bash simple-arrays are not supported yet", match.group(3)]
|
||||
|
||||
if count_matches == 0:
|
||||
log.error(f"** No matches found for Bash declare regex (origin: {self.origin}), line ==>{one_declare}<==")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user