Add override config defaults, reset arg flag method
This commit is contained in:
parent
a3ddc31bfe
commit
58b92837ff
@ -3,6 +3,7 @@ from .base import (
|
||||
argflag_std_read,
|
||||
argflag_std_write,
|
||||
argflag_std_base,
|
||||
reset,
|
||||
)
|
||||
from .arg import ArgumentParser
|
||||
from .config import Config
|
||||
|
@ -50,8 +50,8 @@ class ArgumentParser(argparse.ArgumentParser):
|
||||
:type epilog: str
|
||||
"""
|
||||
|
||||
def __init__(self, arg_flags=0x0f, env=os.environ, usage=None, description=None, epilog=None):
|
||||
super(ArgumentParser, self).__init__(usage=usage, description=description, epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
def __init__(self, arg_flags=0x0f, env=os.environ, usage=None, description=None, epilog=None, *args, **kwargs):
|
||||
super(ArgumentParser, self).__init__(usage=usage, description=description, epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter, *args, **kwargs)
|
||||
|
||||
self.process_flags(arg_flags, env)
|
||||
self.pos_args = []
|
||||
|
@ -2,7 +2,6 @@
|
||||
import enum
|
||||
import os
|
||||
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
default_config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||
@ -39,3 +38,9 @@ argflag_std_read = 0x23ff
|
||||
argflag_std_write = 0xff31ff
|
||||
argflag_std_base = 0x200f
|
||||
argflag_std_target = 0x00e000
|
||||
argflag_all = 0xffffff
|
||||
|
||||
def reset(flags, v):
|
||||
mask = ~(argflag_all & v)
|
||||
r = flags & mask
|
||||
return r
|
||||
|
@ -35,6 +35,15 @@ class Config(confini.Config):
|
||||
default_base_config_dir = default_parent_config_dir
|
||||
default_fee_limit = 0
|
||||
|
||||
|
||||
@staticmethod
|
||||
def override_defaults(base_dir=None, default_fee_limit=None):
|
||||
if base_dir != None:
|
||||
Config.default_base_config_dir = os.path.realpath(base_dir)
|
||||
if default_fee_limit != None:
|
||||
Config.default_fee_limit = int(default_fee_limit)
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_args(cls, args, arg_flags=0x0f, env=os.environ, extra_args={}, base_config_dir=None, default_config_dir=None, user_config_dir=None, default_fee_limit=None, logger=None, load_callback=logcallback, dump_writer=sys.stdout):
|
||||
"""Parses arguments in argparse.ArgumentParser instance, then match and override configuration values that match them.
|
||||
@ -157,7 +166,6 @@ class Config(confini.Config):
|
||||
config.process()
|
||||
|
||||
config.add(getattr(args, 'raw'), '_RAW')
|
||||
|
||||
|
||||
args_override = {}
|
||||
|
||||
|
@ -113,3 +113,7 @@ class Rpc:
|
||||
:returns: Wallet address in canonical string representation
|
||||
"""
|
||||
return self.wallet.signer_address
|
||||
|
||||
|
||||
def get_signer_address(self):
|
||||
return self.get_sender_address()
|
||||
|
@ -1,3 +1,3 @@
|
||||
crypto-dev-signer>=0.4.15a1,<=0.4.15
|
||||
crypto-dev-signer>=0.4.15rc2,<=0.4.15
|
||||
pysha3==1.0.2
|
||||
hexathon~=0.0.1a8
|
||||
|
Loading…
Reference in New Issue
Block a user