Make flag and arg preparations stateless

This commit is contained in:
lash 2022-05-13 10:32:56 +00:00
parent 139e2772af
commit e5a18d1abf
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 55 additions and 57 deletions

View File

@ -1,12 +1,12 @@
# standard imports
import os
# local imports
from .base import *
from .arg import process_flags
from .config import process_config
__script_dir = os.path.dirname(os.path.realpath(__file__))
data_dir = os.path.join(os.path.dirname(__script_dir), 'data')
config_dir = os.path.join(data_dir, 'config')
## standard imports
#import os
#
## local imports
#from .base import *
#from .arg import process_flags
#from .config import process_config
#
#
#__script_dir = os.path.dirname(os.path.realpath(__file__))
#data_dir = os.path.join(os.path.dirname(__script_dir), 'data')
#config_dir = os.path.join(data_dir, 'config')

View File

@ -1,17 +1,21 @@
# local imports
from .base import ChaindFlag
def apply_flag(flag):
flag.add('session')
flag.add('dispatch')
flag.add('socket')
flag.add('socket_client')
flag.add('token')
def process_flags(argparser, flags):
if flags & ChaindFlag.SESSION > 0:
argparser.add_argument('--session-id', dest='session_id', type=str, help='Session to store state and data under')
argparser.add_argument('--runtime-dir', dest='runtime_dir', type=str, help='Directory to store volatile data')
argparser.add_argument('--data-dir', dest='data_dir', type=str, help='Directory to store persistent data')
flag.alias('chaind_base', 'session')
flag.alias('chaind_socket_client', 'session', 'socket', 'socket_client')
if flags & ChaindFlag.SOCKET > 0:
argparser.add_argument('--socket-path', dest='socket', type=str, help='UNIX socket path')
return flag
if flags & ChaindFlag.SOCKET_CLIENT > 0:
argparser.add_argument('--send-socket', dest='socket_send', action='store_true', help='Send to UNIX socket')
if flags & ChaindFlag.TOKEN > 0:
argparser.add_argument('--token-module', dest='token_module', type=str, help='Python module path to resolve tokens from identifiers')
def apply_arg(arg):
arg.add_long('session-id', 'session', help='Session to store state and data under')
arg.add_long('runtime-dir', 'session', help='Directory to store volatile data')
arg.add_long('data-dir', 'session', help='Directory to store persistent data')
arg.add_long('socket-path', 'socket', help='UNIX socket path')
arg.add_long('send-socket', 'socket_client', typ=bool, help='Send to UNIX socket')
arg.add_long('token-module', 'token', help='Python module path to resolve tokens from identifiers')
return arg

View File

@ -68,18 +68,13 @@ def process_session(settings, config):
settings.set('SESSION_RUNTIME_DIR', runtime_dir)
settings.set('SESSION_DIR', session_dir)
settings.set('SESSION_DATA_DIR'], data_dir)
settings.set('SESSION_DATA_DIR', data_dir)
settings.set('SESSION_ID', session_id)
return settings
def process_sync_interface(settings, config):
raise NotImplementedError('no sync interface implementation defined')
def process_sync(settings, config):
settings = process_sync_interface(settings, config)
settings = process_sync_range(settings, config)
return settings
@ -137,24 +132,22 @@ def process_chaind_queue(settings, config):
return settings
def process_settings(settings, config):
settings = process_common(settings, config)
if settings = include_queue:
settings = process_queue_backend(settings, config)
if settings = include_sync:
settings = process_sync_backend(settings, config)
settings = process_backend(settings, config)
settings = process_session(settings, config)
if settings = include_sync:
settings = process_sync(settings, config)
if settings = include_queue:
settings = process_chaind_queue(settings, config)
settings = process_dispatch(settings, config)
settings = process_token(settings, config)
settings = process_socket(settings, config)
return settings
#def process_settings(settings, config):
# if settings = include_queue:
# settings = process_queue_backend(settings, config)
# if settings = include_sync:
# settings = process_sync_backend(settings, config)
#
# settings = process_backend(settings, config)
# settings = process_session(settings, config)
#
# if settings = include_sync:
# settings = process_sync(settings, config)
# if settings = include_queue:
# settings = process_chaind_queue(settings, config)
# settings = process_dispatch(settings, config)
# settings = process_token(settings, config)
#
# settings = process_socket(settings, config)
#
# return settings

View File

@ -1,6 +1,6 @@
chainlib~=0.2.0
chainqueue~=0.1.16
chainsyncer~=0.4.9
confini~=0.6.0
chainlib~=0.3.0
chainqueue~=0.1.17
chainsyncer~=0.4.11
confini~=0.6.1
funga~=0.5.2
pyxdg~=0.26

View File

@ -1,6 +1,6 @@
[metadata]
name = chaind
version = 0.2.12
version = 0.2.13
description = Base package for chain queue service
author = Louis Holbrook
author_email = dev@holbrook.no
@ -30,6 +30,7 @@ packages =
# chaind.runnable
chaind.adapters
chaind.unittest
chaind.data
chaind.cli
#[options.entry_points]