renaming to environment
This commit is contained in:
parent
34d16cfb37
commit
ab1f1bb5c3
4 changed files with 25 additions and 26 deletions
|
@ -1,2 +1,2 @@
|
||||||
from .data import RougailUserDataQuestionary
|
from .data import RougailUserEnvironment
|
||||||
__all__ = ('RougailUserDataQuestionary',)
|
__all__ = ('RougailUserEnvironment',)
|
||||||
|
|
6
cli.py
6
cli.py
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Cli code for Rougail-user-data-questionary
|
Cli code for Rougail-user-data-environment
|
||||||
|
|
||||||
Silique (https://www.silique.fr)
|
Silique (https://www.silique.fr)
|
||||||
Copyright (C) 2024
|
Copyright (C) 2024
|
||||||
|
@ -20,14 +20,14 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
from .data import RougailUserDataQuestionary
|
from .data import RougailUserDataEnvironment
|
||||||
|
|
||||||
|
|
||||||
def run(rougailconfig,
|
def run(rougailconfig,
|
||||||
config,
|
config,
|
||||||
user_datas,
|
user_datas,
|
||||||
):
|
):
|
||||||
RougailUserDataQuestionary(config,
|
RougailUserDataEnvironment(config,
|
||||||
rougailconfig=rougailconfig,
|
rougailconfig=rougailconfig,
|
||||||
).run()
|
).run()
|
||||||
|
|
||||||
|
|
10
config.py
10
config.py
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Config file for Rougail-user-data-questionary
|
Config file for Rougail-user-data-environment
|
||||||
|
|
||||||
Silique (https://www.silique.fr)
|
Silique (https://www.silique.fr)
|
||||||
Copyright (C) 2024
|
Copyright (C) 2024
|
||||||
|
@ -24,12 +24,12 @@ def get_rougail_config(*,
|
||||||
backward_compatibility=True,
|
backward_compatibility=True,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
options = """
|
options = """
|
||||||
questionary:
|
environment:
|
||||||
description: Define value interactivly
|
description: Define value interactivly
|
||||||
disabled:
|
disabled:
|
||||||
type: jinja
|
type: jinja
|
||||||
jinja: |
|
jinja: |
|
||||||
{% if 'questionary' not in step.user_data %}
|
{% if 'environment' not in step.user_data %}
|
||||||
disabled
|
disabled
|
||||||
{% endif %}
|
{% endif %}
|
||||||
mandatory:
|
mandatory:
|
||||||
|
@ -47,10 +47,10 @@ questionary:
|
||||||
variable: __.exporter.show_secrets
|
variable: __.exporter.show_secrets
|
||||||
optional: true
|
optional: true
|
||||||
"""
|
"""
|
||||||
return {'name': 'questionary',
|
return {'name': 'environment',
|
||||||
'process': 'user data',
|
'process': 'user data',
|
||||||
'options': options,
|
'options': options,
|
||||||
'level': 60,
|
'level': 70, # FIXME : what for ?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
21
data.py
21
data.py
|
@ -22,9 +22,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
from rougail.object_model import CONVERT_OPTION
|
from rougail.object_model import CONVERT_OPTION
|
||||||
from rougail.config import RougailConfig
|
from rougail.config import RougailConfig
|
||||||
from tiramisu.error import ValueOptionError
|
from tiramisu.error import ValueOptionError
|
||||||
from questionary import text, select, confirm, password, Validator, ValidationError, print as qprint
|
|
||||||
|
|
||||||
class RougailUserDataQuestionary:
|
class RougailUserDataEnvironment:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
config: 'Config',
|
config: 'Config',
|
||||||
*,
|
*,
|
||||||
|
@ -34,19 +33,19 @@ class RougailUserDataQuestionary:
|
||||||
if rougailconfig is None:
|
if rougailconfig is None:
|
||||||
rougailconfig = RougailConfig
|
rougailconfig = RougailConfig
|
||||||
user_data = rougailconfig['step.user_data']
|
user_data = rougailconfig['step.user_data']
|
||||||
if 'questionary' not in user_data:
|
if 'environment' not in user_data:
|
||||||
user_data.append('questionary')
|
user_data.append('environment')
|
||||||
rougailconfig['step.user_data'] = user_data
|
rougailconfig['step.user_data'] = user_data
|
||||||
user_data = rougailconfig['step.user_data']
|
user_data = rougailconfig['step.user_data']
|
||||||
if 'questionary' not in user_data:
|
if 'environment' not in user_data:
|
||||||
raise Exception('questionary is not set in step.user_data')
|
raise Exception('environment is not set in step.user_data')
|
||||||
self.rougailconfig = rougailconfig
|
self.rougailconfig = rougailconfig
|
||||||
self.errors = []
|
self.errors = []
|
||||||
self.warnings = []
|
self.warnings = []
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.config.property.read_write()
|
self.config.property.read_write()
|
||||||
if self.rougailconfig['questionary.mandatory']:
|
if self.rougailconfig['environment.mandatory']:
|
||||||
current_titles = []
|
current_titles = []
|
||||||
while True:
|
while True:
|
||||||
mandatories = self.config.value.mandatory()
|
mandatories = self.config.value.mandatory()
|
||||||
|
@ -64,7 +63,7 @@ class RougailUserDataQuestionary:
|
||||||
current_titles = current_titles[0:idx]
|
current_titles = current_titles[0:idx]
|
||||||
current_titles.append(p)
|
current_titles.append(p)
|
||||||
self.print(current_config.description(), idx)
|
self.print(current_config.description(), idx)
|
||||||
self.display_questionary(mandatory)
|
self.display_environment(mandatory)
|
||||||
else:
|
else:
|
||||||
self.parse(self.config)
|
self.parse(self.config)
|
||||||
self.config.property.read_only()
|
self.config.property.read_only()
|
||||||
|
@ -75,12 +74,12 @@ class RougailUserDataQuestionary:
|
||||||
self.print(option.description(), title_level)
|
self.print(option.description(), title_level)
|
||||||
self.parse(option, title_level + 1)
|
self.parse(option, title_level + 1)
|
||||||
else:
|
else:
|
||||||
self.display_questionary(option)
|
self.display_environment(option)
|
||||||
|
|
||||||
def print(self, title, title_level):
|
def print(self, title, title_level):
|
||||||
qprint(' ' * title_level + '📂 ' + title, 'bold')
|
qprint(' ' * title_level + '📂 ' + title, 'bold')
|
||||||
|
|
||||||
def display_questionary(self, option):
|
def display_environment(self, option):
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
option_type = option.information.get('type')
|
option_type = option.information.get('type')
|
||||||
isdefault = option.owner.isdefault()
|
isdefault = option.owner.isdefault()
|
||||||
|
@ -99,7 +98,7 @@ class RougailUserDataQuestionary:
|
||||||
kwargs['choices'] = option.value.list()
|
kwargs['choices'] = option.value.list()
|
||||||
elif option_type == 'boolean':
|
elif option_type == 'boolean':
|
||||||
question_funtion = confirm
|
question_funtion = confirm
|
||||||
elif option_type == 'secret' and not self.rougailconfig['questionary.show_secrets']:
|
elif option_type == 'secret' and not self.rougailconfig['environment.show_secrets']:
|
||||||
question_funtion = password
|
question_funtion = password
|
||||||
else:
|
else:
|
||||||
question_funtion = text
|
question_funtion = text
|
||||||
|
|
Loading…
Reference in a new issue