Parse variable assignments passed as arguments in the command line
(keyvals)
| 2066 | |
| 2067 | |
| 2068 | def parse_variables(keyvals): |
| 2069 | """Parse variable assignments passed as arguments in the command line""" |
| 2070 | kv_pattern = r'(%s)=(.*)$' % (ImpalaShell.VALID_VAR_NAME_PATTERN,) |
| 2071 | vars = {} |
| 2072 | if keyvals: |
| 2073 | for keyval in keyvals: |
| 2074 | match = re.match(kv_pattern, keyval) |
| 2075 | if not match: |
| 2076 | print('Error: Could not parse key-value "%s". ' % (keyval,) |
| 2077 | + 'It must follow the pattern "KEY=VALUE".', file=sys.stderr) |
| 2078 | parser.print_help() |
| 2079 | raise FatalShellException() |
| 2080 | else: |
| 2081 | vars[match.groups()[0].upper()] = replace_variables(vars, match.groups()[1]) |
| 2082 | return vars |
| 2083 | |
| 2084 | |
| 2085 | def replace_variables(set_variables, input_string): |
no test coverage detected