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
|
||||
__all__ = ('RougailUserDataQuestionary',)
|
||||
from .data import RougailUserEnvironment
|
||||
__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)
|
||||
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
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
from .data import RougailUserDataQuestionary
|
||||
from .data import RougailUserDataEnvironment
|
||||
|
||||
|
||||
def run(rougailconfig,
|
||||
config,
|
||||
user_datas,
|
||||
):
|
||||
RougailUserDataQuestionary(config,
|
||||
RougailUserDataEnvironment(config,
|
||||
rougailconfig=rougailconfig,
|
||||
).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)
|
||||
Copyright (C) 2024
|
||||
|
@ -24,12 +24,12 @@ def get_rougail_config(*,
|
|||
backward_compatibility=True,
|
||||
) -> dict:
|
||||
options = """
|
||||
questionary:
|
||||
environment:
|
||||
description: Define value interactivly
|
||||
disabled:
|
||||
type: jinja
|
||||
jinja: |
|
||||
{% if 'questionary' not in step.user_data %}
|
||||
{% if 'environment' not in step.user_data %}
|
||||
disabled
|
||||
{% endif %}
|
||||
mandatory:
|
||||
|
@ -47,10 +47,10 @@ questionary:
|
|||
variable: __.exporter.show_secrets
|
||||
optional: true
|
||||
"""
|
||||
return {'name': 'questionary',
|
||||
return {'name': 'environment',
|
||||
'process': 'user data',
|
||||
'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.config import RougailConfig
|
||||
from tiramisu.error import ValueOptionError
|
||||
from questionary import text, select, confirm, password, Validator, ValidationError, print as qprint
|
||||
|
||||
class RougailUserDataQuestionary:
|
||||
class RougailUserDataEnvironment:
|
||||
def __init__(self,
|
||||
config: 'Config',
|
||||
*,
|
||||
|
@ -34,19 +33,19 @@ class RougailUserDataQuestionary:
|
|||
if rougailconfig is None:
|
||||
rougailconfig = RougailConfig
|
||||
user_data = rougailconfig['step.user_data']
|
||||
if 'questionary' not in user_data:
|
||||
user_data.append('questionary')
|
||||
if 'environment' not in user_data:
|
||||
user_data.append('environment')
|
||||
rougailconfig['step.user_data'] = user_data
|
||||
user_data = rougailconfig['step.user_data']
|
||||
if 'questionary' not in user_data:
|
||||
raise Exception('questionary is not set in step.user_data')
|
||||
if 'environment' not in user_data:
|
||||
raise Exception('environment is not set in step.user_data')
|
||||
self.rougailconfig = rougailconfig
|
||||
self.errors = []
|
||||
self.warnings = []
|
||||
|
||||
def run(self):
|
||||
self.config.property.read_write()
|
||||
if self.rougailconfig['questionary.mandatory']:
|
||||
if self.rougailconfig['environment.mandatory']:
|
||||
current_titles = []
|
||||
while True:
|
||||
mandatories = self.config.value.mandatory()
|
||||
|
@ -64,7 +63,7 @@ class RougailUserDataQuestionary:
|
|||
current_titles = current_titles[0:idx]
|
||||
current_titles.append(p)
|
||||
self.print(current_config.description(), idx)
|
||||
self.display_questionary(mandatory)
|
||||
self.display_environment(mandatory)
|
||||
else:
|
||||
self.parse(self.config)
|
||||
self.config.property.read_only()
|
||||
|
@ -75,12 +74,12 @@ class RougailUserDataQuestionary:
|
|||
self.print(option.description(), title_level)
|
||||
self.parse(option, title_level + 1)
|
||||
else:
|
||||
self.display_questionary(option)
|
||||
self.display_environment(option)
|
||||
|
||||
def print(self, title, title_level):
|
||||
qprint(' ' * title_level + '📂 ' + title, 'bold')
|
||||
|
||||
def display_questionary(self, option):
|
||||
def display_environment(self, option):
|
||||
kwargs = {}
|
||||
option_type = option.information.get('type')
|
||||
isdefault = option.owner.isdefault()
|
||||
|
@ -99,7 +98,7 @@ class RougailUserDataQuestionary:
|
|||
kwargs['choices'] = option.value.list()
|
||||
elif option_type == 'boolean':
|
||||
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
|
||||
else:
|
||||
question_funtion = text
|
||||
|
|
Loading…
Reference in a new issue