automaticly create choice/property_/Leadership object
This commit is contained in:
parent
54df7aca12
commit
4223e7e5a3
@ -144,13 +144,13 @@ class GroupAnnotator:
|
||||
break
|
||||
elif variable.name == leader_name:
|
||||
# it's a leader
|
||||
if isinstance(variable, self.objectspace.Leadership):
|
||||
if isinstance(variable, self.objectspace.leadership):
|
||||
# append follower to an existed leadership
|
||||
leader_space = variable
|
||||
# if variable.hidden:
|
||||
# leader_is_hidden = True
|
||||
else:
|
||||
leader_space = self.objectspace.Leadership(variable.xmlfiles)
|
||||
leader_space = self.objectspace.leadership(variable.xmlfiles)
|
||||
if hasattr(group, 'name'):
|
||||
leadership_name = group.name
|
||||
else:
|
||||
@ -540,7 +540,7 @@ class VariableAnnotator:
|
||||
family.name = normalize_family(family.name)
|
||||
if hasattr(family, 'variable'):
|
||||
for variable in family.variable.values():
|
||||
if isinstance(variable, self.objectspace.Leadership):
|
||||
if isinstance(variable, self.objectspace.leadership):
|
||||
for idx, follower in enumerate(variable.variable):
|
||||
if idx == 0:
|
||||
variable_type = 'master'
|
||||
@ -591,7 +591,7 @@ class VariableAnnotator:
|
||||
for family in variables.family.values():
|
||||
if hasattr(family, 'variable'):
|
||||
for variable in family.variable.values():
|
||||
if isinstance(variable, self.objectspace.Leadership):
|
||||
if isinstance(variable, self.objectspace.leadership):
|
||||
for follower in variable.variable:
|
||||
_convert_auto_freeze(follower, namespace)
|
||||
else:
|
||||
@ -753,7 +753,7 @@ class ConstraintAnnotator:
|
||||
variable = self.objectspace.paths.get_variable_obj(target.name)
|
||||
family = self.objectspace.paths.get_family_obj(target.name.rsplit('.', 1)[0])
|
||||
# it's a leader, so apply property to leadership
|
||||
if isinstance(family, self.objectspace.Leadership) and family.name == variable.name:
|
||||
if isinstance(family, self.objectspace.leadership) and family.name == variable.name:
|
||||
return family, family.variable
|
||||
return variable, [variable]
|
||||
# it's a family
|
||||
@ -1151,7 +1151,7 @@ class FamilyAnnotator:
|
||||
for family in family.family.values():
|
||||
mode = modes_level[-1]
|
||||
for variable in family.variable.values():
|
||||
if isinstance(variable, self.objectspace.Leadership):
|
||||
if isinstance(variable, self.objectspace.leadership):
|
||||
variable_mode = variable.variable[0].mode
|
||||
variable.variable[0].mode = None
|
||||
variable.mode = variable_mode
|
||||
@ -1217,7 +1217,7 @@ class FamilyAnnotator:
|
||||
if hasattr(family, 'variable'):
|
||||
for variable in family.variable.values():
|
||||
|
||||
if isinstance(variable, self.objectspace.Leadership):
|
||||
if isinstance(variable, self.objectspace.leadership):
|
||||
mode = modes_level[-1]
|
||||
for idx, follower in enumerate(variable.variable):
|
||||
if follower.auto_save is True:
|
||||
@ -1284,7 +1284,7 @@ class PropertyAnnotator:
|
||||
self.convert_property(family)
|
||||
if hasattr(family, 'variable'):
|
||||
for variable in family.variable.values():
|
||||
if isinstance(variable, self.objectspace.Leadership):
|
||||
if isinstance(variable, self.objectspace.leadership):
|
||||
self.convert_property(variable)
|
||||
for follower in variable.variable:
|
||||
self.convert_property(follower)
|
||||
|
@ -33,13 +33,15 @@ from .error import OperationError, SpaceObjShallNotBeUpdated, DictConsistencyErr
|
||||
from .path import Path
|
||||
from .config import Config
|
||||
|
||||
# RougailObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type
|
||||
# RougailObjSpace's elements that shall be forced to the Redefinable type
|
||||
FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables')
|
||||
# RougailObjSpace's elements that shall be forced to the UnRedefinable type
|
||||
FORCE_UNREDEFINABLES = ('value',)
|
||||
# RougailObjSpace's elements that shall be set to the UnRedefinable type
|
||||
# RougailObjSpace's elements that shall not be modify
|
||||
UNREDEFINABLE = ('multi', 'type')
|
||||
|
||||
# RougailObjSpace's elements that did not created automaticly
|
||||
FORCE_ELEMENTS = ('choice', 'property_', 'leadership')
|
||||
# XML text are convert has name
|
||||
FORCED_TEXT_ELTS_AS_NAME = ('choice', 'property', 'value', 'target')
|
||||
|
||||
|
||||
@ -64,35 +66,26 @@ class UnRedefinable(RootRougailObject):
|
||||
pass
|
||||
|
||||
|
||||
class ObjSpace:
|
||||
"""
|
||||
Base object space
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class RougailObjSpace:
|
||||
"""DOM XML reflexion free internal representation of a Rougail Dictionary
|
||||
"""
|
||||
choice = type('Choice', (RootRougailObject,), dict())
|
||||
property_ = type('Property', (RootRougailObject,), dict())
|
||||
# Rougail ObjectSpace's Leadership variable class type
|
||||
Leadership = type('Leadership', (RootRougailObject,), dict())
|
||||
"""
|
||||
This Atom type stands for singleton, that is
|
||||
an Object Space's atom object is present only once in the
|
||||
object space's tree
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, dtdfilename): # pylint: disable=R0912
|
||||
self.index = 0
|
||||
class ObjSpace: # pylint: disable=R0903
|
||||
"""
|
||||
Base object space
|
||||
"""
|
||||
self.space = ObjSpace()
|
||||
self.paths = Path()
|
||||
self.xmlreflector = XMLReflector()
|
||||
self.xmlreflector.parse_dtd(dtdfilename)
|
||||
self.redefine_variables = None
|
||||
self.check_removed = None
|
||||
self.condition_removed = None
|
||||
|
||||
# ['variable', 'separator', 'family']
|
||||
self.forced_text_elts = set()
|
||||
self.forced_text_elts_as_name = set(FORCED_TEXT_ELTS_AS_NAME)
|
||||
self.list_conditions = {}
|
||||
@ -138,6 +131,12 @@ class RougailObjSpace:
|
||||
|
||||
# create ObjectSpace object
|
||||
setattr(self, dtd_elt.name, type(dtd_elt.name.capitalize(), (clstype,), attrs))
|
||||
for elt in FORCE_ELEMENTS:
|
||||
name = elt.capitalize()
|
||||
if name.endswith('_'):
|
||||
name = name[:-1]
|
||||
setattr(self, elt, type(name, (RootRougailObject,), dict()))
|
||||
self.Leadership = self.leadership
|
||||
|
||||
def create_or_populate_from_xml(self,
|
||||
namespace,
|
||||
@ -148,8 +147,6 @@ class RougailObjSpace:
|
||||
"""
|
||||
for xmlfile, document in self.xmlreflector.load_xml_from_folders(xmlfolders):
|
||||
self.redefine_variables = []
|
||||
self.check_removed = []
|
||||
self.condition_removed = []
|
||||
self.xml_parse_document(xmlfile,
|
||||
document,
|
||||
self.space,
|
||||
|
Loading…
Reference in New Issue
Block a user