Update config handlnig

This commit is contained in:
lash 2022-05-14 16:14:16 +00:00
parent 1adecdde2d
commit cad695c676
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -1,19 +1,15 @@
# external imports def process_config(config, arg, args, flags):
from chainsyncer.cli import SyncFlag
def process_config(config, args, flags):
args_override = {} args_override = {}
args_override['SYNCER_BACKEND'] = getattr(args, 'backend') args_override['SYNCER_BACKEND'] = getattr(args, 'backend')
if flags & SyncFlag.RANGE: if arg.match('range', flags):
args_override['SYNCER_OFFSET'] = getattr(args, 'offset') args_override['SYNCER_OFFSET'] = getattr(args, 'offset')
args_override['SYNCER_LIMIT'] = getattr(args, 'until') args_override['SYNCER_LIMIT'] = getattr(args, 'until')
config.dict_override(args_override, 'local cli args') config.dict_override(args_override, 'local cli args')
if flags & SyncFlag.HEAD: if arg.match('head', flags):
config.add(getattr(args, 'keep_alive'), '_KEEP_ALIVE') config.add(getattr(args, 'keep_alive'), '_KEEP_ALIVE')
config.add(getattr(args, 'head'), '_HEAD') config.add(getattr(args, 'head'), '_HEAD')