eth-monitor

Monitor and cache ethereum transactions with match filters
git clone git://git.defalsify.org/eth-monitor.git
Info | Log | Files | Refs | README | LICENSE

config.py (2242B)


      1 # local imports
      2 from .rules import (
      3         rules_address_args,
      4         rules_data_args,
      5         rules_txhash_args,
      6         to_config_names,
      7         )
      8 
      9 def process_config(config, arg, args, flags):
     10     arg_override = {}
     11 
     12     rules_args = rules_address_args + rules_data_args + rules_txhash_args
     13 
     14     for rules_arg in rules_args:
     15         (vy, vn) = to_config_names(rules_arg)
     16         arg = getattr(args, rules_arg)
     17         if arg == None:
     18             v = config.get(vy)
     19             if bool(v):
     20                 arg_override[vy] = v.split(',')
     21         else:
     22             arg_override[vy] = arg
     23 
     24         arg = getattr(args, 'x_' + rules_arg)
     25         if arg == None:
     26             v = config.get(vn)
     27             if bool(v):
     28                 arg_override[vn] = v.split(',')
     29         else:
     30             arg_override[vn] = arg
     31 
     32     arg_override['ETHMONITOR_INCLUDES_FILE'] = getattr(args, 'includes_file')
     33     arg_override['ETHMONITOR_EXCLUDES_FILE'] = getattr(args, 'excludes_file')
     34     arg_override['ETHMONITOR_INCLUDE_DEFAULT'] = getattr(args, 'include_default')
     35 
     36     arg_override['ETHMONITOR_RENDERER'] = getattr(args, 'renderer')
     37     arg_override['ETHMONITOR_FILTER'] = getattr(args, 'filter')
     38     arg_override['ETHMONITOR_BLOCK_FILTER'] = getattr(args, 'block_filter')
     39 
     40     arg_override['ETHMONITOR_STATE_DIR'] = getattr(args, 'state_dir')
     41 
     42     arg_override['ETHMONITOR_CONTEXT_KEY'] = getattr(args, 'context_key')
     43 
     44     arg_override['ETHMONITOR_MATCH_ALL'] = getattr(args, 'match_all')
     45 
     46     arg_override['ETHCACHE_STORE_BLOCK'] = getattr(args, 'store_block_data')
     47     arg_override['ETHCACHE_STORE_TX'] = getattr(args, 'store_tx_data')
     48 
     49     config.dict_override(arg_override, 'local cli args')
     50 
     51     for rules_arg in rules_args:
     52         (vy, vn) = to_config_names(rules_arg)
     53         if config.get(vy) == None:
     54             config.add([], vy, True)
     55         if config.get(vn) == None:
     56             config.add([], vn, True)
     57 
     58     config.add(getattr(args, 'session_id'), '_SESSION_ID', False)
     59     config.add(getattr(args, 'cache_dir'), '_CACHE_DIR', False)
     60     config.add(getattr(args, 'cache_spec'), '_CACHE_SPEC', False)
     61     config.add(getattr(args, 'run_dir'), '_RUN_DIR', False)
     62     config.add(getattr(args, 'fresh'), '_FRESH', False)
     63 
     64     return config