def override_from_cfg_file(cfg_data): from mmgen.util import die, strip_comments, set_for_type import re from mmgen.protocol import CoinProtocol for n, l in enumerate(cfg_data.splitlines(), 1): # DOS-safe l = strip_comments(l) if l == '': continue m = re.match(r'(\w+)\s+(\S+)$', l) if not m: die(2, "Parse error in file '{}', line {}".format(g.cfg_file, n)) name, val = m.groups() if name in g.cfg_file_opts: pfx, cfg_var = name.split('_', 1) if pfx in CoinProtocol.coins: tn = False cv1, cv2 = cfg_var.split('_', 1) if cv1 in ('mainnet', 'testnet'): tn, cfg_var = (cv1 == 'testnet'), cv2 cls, attr = CoinProtocol(pfx, tn), cfg_var else: cls, attr = g, name setattr( cls, attr, set_for_type(val, getattr(cls, attr), attr, src=g.cfg_file)) else: die(2, "'{}': unrecognized option in '{}'".format(name, g.cfg_file))
def override_from_cfg_file(cfg_data): from mmgen.util import die, strip_comments, set_for_type import re for n, l in enumerate(cfg_data.splitlines(), 1): # DOS-safe l = strip_comments(l) if l == '': continue m = re.match(r'(\w+)\s+(\S+)$', l) if not m: die(2, "Parse error in file '{}', line {}".format(g.cfg_file, n)) name, val = m.groups() if name in g.cfg_file_opts: setattr(g, name, set_for_type(val, getattr(g, name), name, src=g.cfg_file)) else: die(2, "'{}': unrecognized option in '{}'".format(name, g.cfg_file))
def override_from_cfg_file(cfg_data): from mmgen.util import die,strip_comments,set_for_type import re from mmgen.protocol import CoinProtocol for n,l in enumerate(cfg_data.splitlines(),1): # DOS-safe l = strip_comments(l) if l == '': continue m = re.match(r'(\w+)\s+(\S+)$',l) if not m: die(2,"Parse error in file '{}', line {}".format(g.cfg_file,n)) name,val = m.groups() if name in g.cfg_file_opts: pfx,cfg_var = name.split('_',1) if pfx in CoinProtocol.coins: cls,attr = CoinProtocol(pfx,False),cfg_var else: cls,attr = g,name setattr(cls,attr,set_for_type(val,getattr(cls,attr),attr,src=g.cfg_file)) # pmsg(cls,attr,getattr(cls,attr)) else: die(2,"'{}': unrecognized option in '{}'".format(name,g.cfg_file))