chainlib

Generic blockchain access library and tooling
Log | Files | Refs | README | LICENSE

commit 58b92837ffa45ebaca3032b97abd1ec3ecccec51
parent a3ddc31bfe182b93781f5d0eabe4edeb3674ba7d
Author: nolash <dev@holbrook.no>
Date:   Wed,  6 Oct 2021 07:14:31 +0200

Add override config defaults, reset arg flag method

Diffstat:
Mchainlib/cli/__init__.py | 1+
Mchainlib/cli/arg.py | 4++--
Mchainlib/cli/base.py | 7++++++-
Mchainlib/cli/config.py | 10+++++++++-
Mchainlib/cli/rpc.py | 4++++
Mrequirements.txt | 2+-
Msetup.cfg | 2+-
7 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/chainlib/cli/__init__.py b/chainlib/cli/__init__.py @@ -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 diff --git a/chainlib/cli/arg.py b/chainlib/cli/arg.py @@ -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 = [] diff --git a/chainlib/cli/base.py b/chainlib/cli/base.py @@ -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 diff --git a/chainlib/cli/config.py b/chainlib/cli/config.py @@ -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 = {} diff --git a/chainlib/cli/rpc.py b/chainlib/cli/rpc.py @@ -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() diff --git a/requirements.txt b/requirements.txt @@ -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 diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib -version = 0.0.9a9 +version = 0.0.9rc1 description = Generic blockchain access library and tooling author = Louis Holbrook author_email = dev@holbrook.no