init
This commit is contained in:
parent
2b40ea7f71
commit
915e441af4
3 changed files with 64 additions and 0 deletions
8
bin/rougail
Executable file
8
bin/rougail
Executable file
|
@ -0,0 +1,8 @@
|
|||
#! /usr/bin/python3 -sP
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from rougail.cli.__main__ import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
0
src/rougail/cli/__init__.py
Normal file
0
src/rougail/cli/__init__.py
Normal file
56
src/rougail/cli/__main__.py
Normal file
56
src/rougail/cli/__main__.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
||||
from tiramisu import Config
|
||||
from pathlib import Path
|
||||
|
||||
from rougail import Rougail
|
||||
from rougail.config import get_rougail_config
|
||||
from rougail.utils import load_modules
|
||||
|
||||
|
||||
def main():
|
||||
rougailconfig = get_rougail_config(backward_compatibility=False)
|
||||
cmd_config = rougailconfig.config
|
||||
cmd_config.property.read_write()
|
||||
cmd_config.property.add('not_for_commandline')
|
||||
parser = TiramisuCmdlineParser(cmd_config,
|
||||
add_no_option_to_boolean=False,
|
||||
short_name_max_len=2,
|
||||
)
|
||||
parser.parse_args()
|
||||
cmd_config.property.remove('not_for_commandline')
|
||||
cmd_config.property.read_only()
|
||||
user_data_names = rougailconfig['step.user_data']
|
||||
output_name = rougailconfig['step.output']
|
||||
# structural
|
||||
rougail = Rougail(rougailconfig)
|
||||
for user_data_name in user_data_names:
|
||||
rougail.converted.plugins.append('user_data_' + user_data_name)
|
||||
rougail.converted.plugins.append('output_' + output_name)
|
||||
config = rougail.get_config()
|
||||
# data user
|
||||
if not user_data_names:
|
||||
user_datas = None
|
||||
else:
|
||||
config.property.read_write()
|
||||
user_datas = {'errors': [],
|
||||
'warnings': [],
|
||||
}
|
||||
for user_data_name in user_data_names:
|
||||
path = Path(__file__).parent.parent / ('user_data_' + user_data_name) / 'cli.py'
|
||||
if not path.is_file():
|
||||
raise Exception(f'cannot find cli file for "user_data" module "{user_data_name}"')
|
||||
module = load_modules('rougail.user_data_' + user_data_name + '.cli', str(path))
|
||||
module.run(rougailconfig,
|
||||
config,
|
||||
user_datas,
|
||||
)
|
||||
# output
|
||||
config.property.read_only()
|
||||
path = Path(__file__).parent.parent / ('output_' + output_name) / 'cli.py'
|
||||
if not path.is_file():
|
||||
raise Exception(f'cannot find cli file for "output_name" module "{output_name}"')
|
||||
module = load_modules('rougail.output_' + output_name + '.cli', str(path))
|
||||
module.run(rougailconfig,
|
||||
config,
|
||||
user_datas,
|
||||
)
|
Loading…
Reference in a new issue