2022-05-10 16:21:49 +02:00
|
|
|
# local imports
|
|
|
|
from .rules import (
|
|
|
|
rules_address_args,
|
|
|
|
rules_data_args,
|
|
|
|
to_config_names,
|
|
|
|
)
|
|
|
|
|
2022-05-14 22:58:21 +02:00
|
|
|
def process_config(config, arg, args, flags):
|
2022-05-10 13:25:05 +02:00
|
|
|
arg_override = {}
|
2022-05-10 16:21:49 +02:00
|
|
|
|
|
|
|
rules_args = rules_address_args + rules_data_args
|
|
|
|
|
|
|
|
for rules_arg in rules_args:
|
|
|
|
(vy, vn) = to_config_names(rules_arg)
|
|
|
|
arg = getattr(args, rules_arg)
|
|
|
|
if arg == None:
|
|
|
|
v = config.get(vy)
|
|
|
|
if bool(v):
|
|
|
|
arg_override[vy] = v.split(',')
|
|
|
|
else:
|
|
|
|
arg_override[vy] = arg
|
|
|
|
|
|
|
|
arg = getattr(args, 'x_' + rules_arg)
|
|
|
|
if arg == None:
|
|
|
|
v = config.get(vn)
|
|
|
|
if bool(v):
|
|
|
|
arg_override[vn] = v.split(',')
|
|
|
|
else:
|
|
|
|
arg_override[vn] = arg
|
|
|
|
|
|
|
|
arg_override['ETHMONITOR_INCLUDES_FILE'] = getattr(args, 'includes_file')
|
|
|
|
arg_override['ETHMONITOR_EXCLUDES_FILE'] = getattr(args, 'excludes_file')
|
2022-05-10 13:25:05 +02:00
|
|
|
arg_override['ETHMONITOR_INCLUDE_DEFAULT'] = getattr(args, 'include_default')
|
|
|
|
|
2022-05-10 16:21:49 +02:00
|
|
|
arg_override['ETHMONITOR_RENDERER'] = getattr(args, 'renderer')
|
|
|
|
arg_override['ETHMONITOR_FILTER'] = getattr(args, 'filter')
|
|
|
|
arg_override['ETHMONITOR_BLOCK_FILTER'] = getattr(args, 'block_filter')
|
|
|
|
|
|
|
|
arg_override['ETHMONITOR_STATE_DIR'] = getattr(args, 'state_dir')
|
|
|
|
|
2023-08-06 20:32:10 +02:00
|
|
|
arg_override['ETHMONITOR_CONTEXT_KEY'] = getattr(args, 'context_key')
|
|
|
|
|
2023-08-17 13:48:33 +02:00
|
|
|
arg_override['ETHMONITOR_MATCH_ALL'] = getattr(args, 'match_all')
|
|
|
|
|
2022-05-10 20:28:35 +02:00
|
|
|
arg_override['ETHCACHE_STORE_BLOCK'] = getattr(args, 'store_block_data')
|
|
|
|
arg_override['ETHCACHE_STORE_TX'] = getattr(args, 'store_tx_data')
|
|
|
|
|
2022-05-10 13:25:05 +02:00
|
|
|
config.dict_override(arg_override, 'local cli args')
|
|
|
|
|
2022-05-10 16:21:49 +02:00
|
|
|
for rules_arg in rules_args:
|
|
|
|
(vy, vn) = to_config_names(rules_arg)
|
|
|
|
if config.get(vy) == None:
|
|
|
|
config.add([], vy, True)
|
|
|
|
if config.get(vn) == None:
|
|
|
|
config.add([], vn, True)
|
|
|
|
|
2022-05-10 13:07:25 +02:00
|
|
|
config.add(getattr(args, 'session_id'), '_SESSION_ID', False)
|
|
|
|
config.add(getattr(args, 'cache_dir'), '_CACHE_DIR', False)
|
2024-06-27 17:10:30 +02:00
|
|
|
config.add(getattr(args, 'cache_spec'), '_CACHE_SPEC', False)
|
2023-08-19 12:04:52 +02:00
|
|
|
config.add(getattr(args, 'run_dir'), '_RUN_DIR', False)
|
2022-05-10 20:28:35 +02:00
|
|
|
config.add(getattr(args, 'fresh'), '_FRESH', False)
|
2022-05-10 13:07:25 +02:00
|
|
|
|
|
|
|
return config
|