remove servcice_elt_attr_list
This commit is contained in:
parent
25d5307415
commit
d8e99fef54
@ -114,21 +114,21 @@ class ServiceAnnotator:
|
||||
def convert_service_to_family(self, service_name, service_family, service):
|
||||
# tranform service object to family object
|
||||
# add services, service_accesses, ...
|
||||
for elttype in self.objectspace.service_elt_attr_list:
|
||||
if hasattr(service, elttype):
|
||||
family = self.objectspace.family()
|
||||
if elttype.endswith('s'):
|
||||
family.name = elttype + 'es'
|
||||
else:
|
||||
family.name = elttype + 's'
|
||||
values = getattr(service, elttype)
|
||||
if isinstance(values, dict):
|
||||
values = list(values.values())
|
||||
family.family = self.convert_subelement_service(elttype,
|
||||
values,
|
||||
'services.{}.{}'.format(service_name, family.name))
|
||||
family.mode = None
|
||||
service_family[family.name] = family
|
||||
for elttype, values in vars(service).items():
|
||||
if elttype in ['name', 'index']:
|
||||
continue
|
||||
family = self.objectspace.family()
|
||||
if elttype.endswith('s'):
|
||||
family.name = elttype + 'es'
|
||||
else:
|
||||
family.name = elttype + 's'
|
||||
if isinstance(values, dict):
|
||||
values = list(values.values())
|
||||
family.family = self.convert_subelement_service(elttype,
|
||||
values,
|
||||
'services.{}.{}'.format(service_name, family.name))
|
||||
family.mode = None
|
||||
service_family[family.name] = family
|
||||
|
||||
def convert_subelement_service(self, name, elts, path):
|
||||
families = []
|
||||
|
@ -86,8 +86,6 @@ class CreoleObjSpace(object):
|
||||
self.redefine_variables = None
|
||||
self.probe_variables = []
|
||||
|
||||
# elt service's attrs list
|
||||
self.service_elt_attr_list = [] #
|
||||
# ['variable', 'separator', 'family']
|
||||
self.forced_text_elts = set()
|
||||
# ['disknod', 'follower', 'target', 'service', 'package', 'ip', 'value', 'tcpwrapper',
|
||||
@ -107,7 +105,6 @@ class CreoleObjSpace(object):
|
||||
if elt.type == 'mixed':
|
||||
forced_text_elt = True
|
||||
if elt.name == 'service':
|
||||
self.service_elt_attr_list = [elt.content.left.name]
|
||||
self.parse_dtd_right_left_elt(elt.content)
|
||||
for attr in elt.iterattributes():
|
||||
atomic = False
|
||||
@ -152,10 +149,7 @@ class CreoleObjSpace(object):
|
||||
|
||||
def parse_dtd_right_left_elt(self, elt):
|
||||
if elt.right.type == 'or':
|
||||
self.service_elt_attr_list.append(elt.right.left.name)
|
||||
self.parse_dtd_right_left_elt(elt.right)
|
||||
else:
|
||||
self.service_elt_attr_list.append(elt.right.name)
|
||||
|
||||
def _convert_boolean(self, value): # pylint: disable=R0201
|
||||
"""Boolean coercion. The Creole XML may contain srings like `True` or `False`
|
||||
|
Loading…
Reference in New Issue
Block a user