fix: ExtentionError => ExtensionError

This commit is contained in:
egarette@silique.fr 2025-11-21 08:00:21 +01:00
parent 9b6361a5dc
commit 22730c8c2d

View file

@ -18,12 +18,13 @@ 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
"""
import warnings
from questionary import text, select, confirm, password, Validator, ValidationError, print as qprint
from rougail.tiramisu import CONVERT_OPTION
from rougail.config import RougailConfig
from rougail.error import ExtentionError
from tiramisu.error import ValueOptionError
from rougail.error import ExtensionError
from tiramisu.error import ValueOptionError, ValueErrorWarning, ValueWarning
class RougailUserDataQuestionary:
@ -45,15 +46,22 @@ class RougailUserDataQuestionary:
rougailconfig['step.user_data'] = user_data
user_data = rougailconfig['step.user_data']
if 'questionary' not in user_data:
raise ExtentionError('questionary is not set in step.user_data')
raise ExtensionError('questionary is not set in step.user_data')
self.rougailconfig = rougailconfig
self.errors = []
self.warnings = []
warnings.simplefilter("always", ValueErrorWarning)
warnings.simplefilter("always", ValueWarning)
def run(
self,
) -> None:
self.config.property.read_write()
# self.config.property.read_write()
if 'demoting_error_warning' not in self.config.property.get():
add_demoting = True
self.config.property.add('demoting_error_warning')
else:
add_demoting = False
if self.rougailconfig['questionary.mandatory']:
current_titles = []
while True:
@ -75,16 +83,14 @@ class RougailUserDataQuestionary:
self.display_questionary(mandatory)
else:
self.parse(self.config)
self.config.property.read_only()
return {'errors': [],
'warnings': [],
}
if add_demoting:
self.config.property.remove('demoting_error_warning')
return [
{
"source": 'Questionary',
"errors": self.errors,
"warnings": self.warnings,
"values": values,
"values": [],
}
]
@ -103,7 +109,9 @@ class RougailUserDataQuestionary:
kwargs = {}
option_type = option.information.get('type')
isdefault = option.owner.isdefault()
default = option.value.get()
with warnings.catch_warnings():
warnings.simplefilter("ignore")
default = option.value.get()
ismulti = option.ismulti()
type_obj = None
type_obj = CONVERT_OPTION.get(option_type, {}).get("func")
@ -159,7 +167,15 @@ class RougailValidator(Validator):
value.append(val)
if validate:
try:
self.option.value.set(value)
with warnings.catch_warnings(record=True) as warns:
self.option.value.set(value)
for warn in warns:
if isinstance(warn.message, ValueErrorWarning):
warn.message.prefix = ''
raise ValidationError(
message=str(warn.message),
cursor_position=len(document),
)
except ValueOptionError as err:
err.prefix = ''
raise ValidationError(