4
0
mirror of git://holbrook.no/eth-monitor.git synced 2024-11-19 03:06:47 +01:00
eth-monitor/eth_monitor/cli/config.py

60 lines
2.0 KiB
Python
Raw Normal View History

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):
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')
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')
arg_override['ETHCACHE_STORE_BLOCK'] = getattr(args, 'store_block_data')
arg_override['ETHCACHE_STORE_TX'] = getattr(args, 'store_tx_data')
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)
config.add(getattr(args, 'session_id'), '_SESSION_ID', False)
config.add(getattr(args, 'cache_dir'), '_CACHE_DIR', False)
config.add(getattr(args, 'fresh'), '_FRESH', False)
return config