Compare commits
2 commits
9b6361a5dc
...
9f18680d6a
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f18680d6a | |||
| 22730c8c2d |
4 changed files with 35 additions and 13 deletions
|
|
@ -1,3 +1,9 @@
|
|||
## 0.1.0a1 (2025-11-21)
|
||||
|
||||
### Fix
|
||||
|
||||
- ExtentionError => ExtensionError
|
||||
|
||||
## 0.1.0a0 (2025-11-06)
|
||||
|
||||
### Feat
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
|||
|
||||
[project]
|
||||
name = "rougail.user_data_questionary"
|
||||
version = "0.1.0a0"
|
||||
version = "0.1.0a1"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "Rougail user_data questionary"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "0.1.0a0"
|
||||
__version__ = "0.1.0a1"
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue