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_read,
|
||||||
argflag_std_write,
|
argflag_std_write,
|
||||||
argflag_std_base,
|
argflag_std_base,
|
||||||
|
reset,
|
||||||
)
|
)
|
||||||
from .arg import ArgumentParser
|
from .arg import ArgumentParser
|
||||||
from .config import Config
|
from .config import Config
|
||||||
|
@ -50,8 +50,8 @@ class ArgumentParser(argparse.ArgumentParser):
|
|||||||
:type epilog: str
|
:type epilog: str
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, arg_flags=0x0f, env=os.environ, usage=None, description=None, epilog=None):
|
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)
|
super(ArgumentParser, self).__init__(usage=usage, description=description, epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter, *args, **kwargs)
|
||||||
|
|
||||||
self.process_flags(arg_flags, env)
|
self.process_flags(arg_flags, env)
|
||||||
self.pos_args = []
|
self.pos_args = []
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import enum
|
import enum
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
default_config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
default_config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||||
@ -39,3 +38,9 @@ argflag_std_read = 0x23ff
|
|||||||
argflag_std_write = 0xff31ff
|
argflag_std_write = 0xff31ff
|
||||||
argflag_std_base = 0x200f
|
argflag_std_base = 0x200f
|
||||||
argflag_std_target = 0x00e000
|
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_base_config_dir = default_parent_config_dir
|
||||||
default_fee_limit = 0
|
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
|
@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):
|
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.
|
"""Parses arguments in argparse.ArgumentParser instance, then match and override configuration values that match them.
|
||||||
@ -158,7 +167,6 @@ class Config(confini.Config):
|
|||||||
|
|
||||||
config.add(getattr(args, 'raw'), '_RAW')
|
config.add(getattr(args, 'raw'), '_RAW')
|
||||||
|
|
||||||
|
|
||||||
args_override = {}
|
args_override = {}
|
||||||
|
|
||||||
if arg_flags & Flag.PROVIDER:
|
if arg_flags & Flag.PROVIDER:
|
||||||
|
@ -113,3 +113,7 @@ class Rpc:
|
|||||||
:returns: Wallet address in canonical string representation
|
:returns: Wallet address in canonical string representation
|
||||||
"""
|
"""
|
||||||
return self.wallet.signer_address
|
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
|
pysha3==1.0.2
|
||||||
hexathon~=0.0.1a8
|
hexathon~=0.0.1a8
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = chainlib
|
name = chainlib
|
||||||
version = 0.0.9a9
|
version = 0.0.9rc1
|
||||||
description = Generic blockchain access library and tooling
|
description = Generic blockchain access library and tooling
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
Loading…
Reference in New Issue
Block a user