fix: adapt api for rougail-web-ui
This commit is contained in:
parent
c1ab106ba5
commit
a0843e08ca
3 changed files with 35 additions and 19 deletions
|
|
@ -119,27 +119,38 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
print(data)
|
||||
return ret
|
||||
|
||||
def load(self, reload=False):
|
||||
def load(self):
|
||||
self.dynamic_paths = {}
|
||||
config = self.conf.unrestraint
|
||||
self._populate_dynamics(config, reload)
|
||||
self.populate_dynamics(config=config)
|
||||
informations = self.parse_families(config)
|
||||
if informations is None:
|
||||
informations = {}
|
||||
self.informations = informations
|
||||
|
||||
def _populate_dynamics(self, family, reload) -> None:
|
||||
for child in family.list():
|
||||
def populate_dynamics(self, *, config=None, reload=False):
|
||||
if config is None:
|
||||
config = self.conf.unrestraint
|
||||
self._populate_dynamics(config, reload)
|
||||
|
||||
def _populate_dynamics(self, family, reload, uncalculated=False) -> None:
|
||||
def populate(child, uncalculated):
|
||||
if child.isoptiondescription():
|
||||
type_ = "family"
|
||||
else:
|
||||
type_ = "variable"
|
||||
if child.isdynamic():
|
||||
self.populate_dynamic(child, type_, reload)
|
||||
if child.isoptiondescription():
|
||||
self._populate_dynamics(child, reload)
|
||||
self.populate_dynamic(child, type_, reload, uncalculated)
|
||||
if not uncalculated and child.isoptiondescription():
|
||||
self._populate_dynamics(child, reload, uncalculated)
|
||||
for child in family.list(uncalculated=uncalculated):
|
||||
populate(child, uncalculated)
|
||||
if not uncalculated:
|
||||
for child in family.list(uncalculated=True):
|
||||
if child.isdynamic() and child.path(uncalculated=True) not in self.dynamic_paths:
|
||||
populate(family, uncalculated=True)
|
||||
|
||||
def populate_dynamic(self, obj, type_, reload) -> None:
|
||||
def populate_dynamic(self, obj, type_, reload, uncalculated) -> None:
|
||||
path = obj.path(uncalculated=True)
|
||||
if path not in self.dynamic_paths:
|
||||
new_name = True
|
||||
|
|
@ -158,6 +169,8 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
self.dynamic_paths[path]["description"] = self._convert_description(
|
||||
description, obj, type_, its_a_path=True
|
||||
)
|
||||
if uncalculated:
|
||||
return
|
||||
dynamic_obj = self.dynamic_paths[path]
|
||||
if reload and obj.identifiers() in dynamic_obj["identifiers"]:
|
||||
return
|
||||
|
|
@ -168,7 +181,7 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
informations = {}
|
||||
leader = None
|
||||
for child in family.list():
|
||||
if self._is_inaccessible_user_data(child):
|
||||
if self.is_inaccessible_user_data(child):
|
||||
continue
|
||||
if child.type(only_self=True) == "symlink":
|
||||
continue
|
||||
|
|
@ -178,7 +191,7 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
self.parse_family(child, informations)
|
||||
return informations
|
||||
|
||||
def _is_inaccessible_user_data(self, child):
|
||||
def is_inaccessible_user_data(self, child):
|
||||
"""If family is not accessible in read_write mode (to load user_data),
|
||||
do not comment this family
|
||||
"""
|
||||
|
|
@ -199,7 +212,7 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
uncalculated = variable.value.get(uncalculated=True)
|
||||
if (
|
||||
not isinstance(uncalculated, Calculation)
|
||||
and self._is_inaccessible_user_data(variable)
|
||||
and self.is_inaccessible_user_data(variable)
|
||||
and (
|
||||
condition == "when"
|
||||
and value == variable_value
|
||||
|
|
@ -214,11 +227,11 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
return True
|
||||
return False
|
||||
|
||||
def parse_family(self, family, informations: dict) -> None:
|
||||
def parse_family(self, family, informations: dict, *, force_injection=False) -> None:
|
||||
path = family.path(uncalculated=True)
|
||||
name = family.name(uncalculated=True)
|
||||
sub_informations = self.parse_families(family)
|
||||
if not sub_informations:
|
||||
if not force_injection and not sub_informations:
|
||||
return
|
||||
# if self.with_family:
|
||||
family_informations = self._populate_family(
|
||||
|
|
@ -709,7 +722,7 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
if prop in HIDDEN_PROPERTIES:
|
||||
return False
|
||||
variable = None
|
||||
if variable and self._is_inaccessible_user_data(variable):
|
||||
if variable and self.is_inaccessible_user_data(variable):
|
||||
try:
|
||||
variable_value = self._get_unmodified_default_value(variable)
|
||||
except VariableCalculationDependencyError:
|
||||
|
|
@ -779,7 +792,7 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
cpath = calc_path(path, identifiers=identifiers)
|
||||
if regexp and not regexp.search(cpath):
|
||||
continue
|
||||
if self._is_inaccessible_user_data(self.conf.option(cpath)):
|
||||
if self.is_inaccessible_user_data(self.conf.option(cpath)):
|
||||
if all_is_undocumented is None:
|
||||
all_is_undocumented = True
|
||||
msg = hidden_msg
|
||||
|
|
@ -806,7 +819,7 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
except AttributeError as err:
|
||||
pass
|
||||
else:
|
||||
if not isfollower and self._is_inaccessible_user_data(variable):
|
||||
if not isfollower and self.is_inaccessible_user_data(variable):
|
||||
try:
|
||||
uncalculated = variable.value.get(uncalculated=True)
|
||||
except PropertiesOptionError:
|
||||
|
|
@ -845,6 +858,6 @@ class RougailOutputDoc(Examples, Changelog):
|
|||
return child.value.get()
|
||||
if calculation["type"] == "variable":
|
||||
variable = self.conf.forcepermissive.option(calculation["value"])
|
||||
if variable and self._is_inaccessible_user_data(variable):
|
||||
if variable and self.is_inaccessible_user_data(variable):
|
||||
return self._get_unmodified_default_value(variable)
|
||||
raise VariableCalculationDependencyError()
|
||||
|
|
|
|||
|
|
@ -809,7 +809,10 @@ class CommonFormater:
|
|||
if isinstance(msg, list):
|
||||
if len(msg) == 1:
|
||||
submessage, elt = self.message_to_string(msg[0], submessage)
|
||||
submessage += self.list(elt)
|
||||
if isinstance(elt, list):
|
||||
submessage += self.list(elt)
|
||||
else:
|
||||
submessage += elt
|
||||
else:
|
||||
lst = []
|
||||
for p in msg:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ excludes = [
|
|||
]
|
||||
|
||||
test_ok = get_structures_list(excludes)
|
||||
test_ok = [HERE.parent.parent / "rougail-tests" / "structures" / "60_0family_dynamic_source_hidden"]
|
||||
#test_ok = [HERE.parent.parent / "rougail-tests" / "structures" / "60_0family_dynamic_source_hidden"]
|
||||
|
||||
os.environ['COLUMNS'] = '80'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue