remove servcice_elt_attr_list

This commit is contained in:
Emmanuel Garette 2020-02-14 21:34:47 +01:00
parent 25d5307415
commit d8e99fef54
2 changed files with 15 additions and 21 deletions

View File

@ -114,14 +114,14 @@ class ServiceAnnotator:
def convert_service_to_family(self, service_name, service_family, service): def convert_service_to_family(self, service_name, service_family, service):
# tranform service object to family object # tranform service object to family object
# add services, service_accesses, ... # add services, service_accesses, ...
for elttype in self.objectspace.service_elt_attr_list: for elttype, values in vars(service).items():
if hasattr(service, elttype): if elttype in ['name', 'index']:
continue
family = self.objectspace.family() family = self.objectspace.family()
if elttype.endswith('s'): if elttype.endswith('s'):
family.name = elttype + 'es' family.name = elttype + 'es'
else: else:
family.name = elttype + 's' family.name = elttype + 's'
values = getattr(service, elttype)
if isinstance(values, dict): if isinstance(values, dict):
values = list(values.values()) values = list(values.values())
family.family = self.convert_subelement_service(elttype, family.family = self.convert_subelement_service(elttype,

View File

@ -86,8 +86,6 @@ class CreoleObjSpace(object):
self.redefine_variables = None self.redefine_variables = None
self.probe_variables = [] self.probe_variables = []
# elt service's attrs list
self.service_elt_attr_list = [] #
# ['variable', 'separator', 'family'] # ['variable', 'separator', 'family']
self.forced_text_elts = set() self.forced_text_elts = set()
# ['disknod', 'follower', 'target', 'service', 'package', 'ip', 'value', 'tcpwrapper', # ['disknod', 'follower', 'target', 'service', 'package', 'ip', 'value', 'tcpwrapper',
@ -107,7 +105,6 @@ class CreoleObjSpace(object):
if elt.type == 'mixed': if elt.type == 'mixed':
forced_text_elt = True forced_text_elt = True
if elt.name == 'service': if elt.name == 'service':
self.service_elt_attr_list = [elt.content.left.name]
self.parse_dtd_right_left_elt(elt.content) self.parse_dtd_right_left_elt(elt.content)
for attr in elt.iterattributes(): for attr in elt.iterattributes():
atomic = False atomic = False
@ -152,10 +149,7 @@ class CreoleObjSpace(object):
def parse_dtd_right_left_elt(self, elt): def parse_dtd_right_left_elt(self, elt):
if elt.right.type == 'or': if elt.right.type == 'or':
self.service_elt_attr_list.append(elt.right.left.name)
self.parse_dtd_right_left_elt(elt.right) 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 def _convert_boolean(self, value): # pylint: disable=R0201
"""Boolean coercion. The Creole XML may contain srings like `True` or `False` """Boolean coercion. The Creole XML may contain srings like `True` or `False`