@@ -549,68 +549,130 @@ def parse_object_table(self, table, rules = None, match = None, exclude = None):
549549 # Object matching for existing objects
550550 if "for" in table :
551551 for obj_name in table ["for" ]:
552- if obj_name not in self .object_entries_by_name :
553- raise ValueError (f"The object '{ obj_name } ' is not known. Please ensure it is not referenced before it's declared. This is a current limitation." )
552+ if obj_name == "*" :
553+ all_object_entry_names = list (self .object_entries_by_name .keys ())
554+ for target_obj_name in all_object_entry_names :
555+ target = self .object_entries_by_name [target_obj_name ]
556+ new_entries = []
557+ target_match = target ["match" ] if "match" in target and target ["match" ] is not None else dict ()
558+ target_exclude = target ["exclude" ] if "exclude" in target and target ["exclude" ] is not None else dict ()
559+ target_rules = target ["rules" ] if "rules" in target and target ["rules" ] is not None else dict ()
560+
561+ parent_match = (match or dict ())
562+ parent_exclude = (exclude or dict ())
563+
564+ # print(target["name"], len(list(target_match.keys())))
565+ # don't add nodes with no matching property, those are groups
566+ if len (list (target_match .keys ())) > 0 :
567+ # print(f"{name}: {target['name']}")
568+ # add the entry itself
569+ new_entries .append (dict (
570+ match = {
571+ ** target_match , # target, i.e. for-matches
572+ ** parent_match , # parent
573+ },
574+ exclude = {
575+ ** target_exclude ,
576+ ** parent_exclude ,
577+ },
578+ rules = {
579+ ** target_rules ,
580+ ** rules ,
581+ },
582+ name = f"{ name } : { target ['name' ]} "
583+ ))
584+
585+ # add the entries children
586+ if "children" in target :
587+ children = target ["children" ]
588+ for child in children :
589+ child_match = child ["match" ] if child and "match" in child and child ["match" ] is not None else dict ()
590+ child_exclude = child ["exclude" ] if child and "exclude" in child and child ["exclude" ] is not None else dict ()
591+
592+ # don't add children with no matching property, those are groups
593+ if len (list (child_match .keys ())) > 0 :
594+ new_entries .append (dict (
595+ match = {
596+ ** child_match ,
597+ ** parent_match
598+ },
599+ rules = {
600+ ** child ["rules" ],
601+ ** rules ,
602+ },
603+ exclude = {
604+ ** child_exclude ,
605+ ** parent_exclude
606+ },
607+ name = f"{ name } : { child ['name' ]} "
608+ ))
609+
610+ for new_entry in new_entries :
611+ self .object_entries_by_name [new_entry ["name" ]] = new_entry
612+ self .object_entries .append (new_entry )
554613 else :
555- target = self .object_entries_by_name [obj_name ]
556- new_entries = []
557- target_match = target ["match" ] if "match" in target and target ["match" ] is not None else dict ()
558- target_exclude = target ["exclude" ] if "exclude" in target and target ["exclude" ] is not None else dict ()
559- target_rules = target ["rules" ] if "rules" in target and target ["rules" ] is not None else dict ()
560-
561- parent_match = (match or dict ())
562- parent_exclude = (exclude or dict ())
563-
564- # print(target["name"], len(list(target_match.keys())))
565- # don't add nodes with no matching property, those are groups
566- if len (list (target_match .keys ())) > 0 :
567- # print(f"{name}: {target['name']}")
568- # add the entry itself
569- new_entries .append (dict (
570- match = {
571- ** target_match , # target, i.e. for-matches
572- ** parent_match , # parent
573- },
574- exclude = {
575- ** target_exclude ,
576- ** parent_exclude ,
577- },
578- rules = {
579- ** target_rules ,
580- ** rules ,
581- },
582- name = f"{ name } : { target ['name' ]} "
583- ))
584-
585- # add the entries children
586- if "children" in target :
587- children = target ["children" ]
588- for child in children :
589- child_match = child ["match" ] if "match" in child and child ["match" ] is not None else dict
590- child_exclude = child ["exclude" ] if "exclude" in child and child ["exclude" ] is not None else dict ()
591-
592- # print(child["name"], len(list(child_match.keys())))
593- # don't add children with no matching property, those are groups
594- if len (list (child_match .keys ())) > 0 :
595- new_entries .append (dict (
596- match = {
597- ** child_match ,
598- ** parent_match
599- },
600- rules = {
601- ** child ["rules" ],
602- ** rules ,
603- },
604- exclude = {
605- ** child_exclude ,
606- ** parent_exclude
607- },
608- name = f"{ name } : { child ['name' ]} "
609- ))
610-
611- for new_entry in new_entries :
612- self .object_entries_by_name [new_entry ["name" ]] = new_entry
613- self .object_entries .append (new_entry )
614+ if obj_name not in self .object_entries_by_name :
615+ raise ValueError (f"The object '{ obj_name } ' is not known. Please ensure it is not referenced before it's declared. This is a current limitation." )
616+ else :
617+ target = self .object_entries_by_name [obj_name ]
618+ new_entries = []
619+ target_match = target ["match" ] if "match" in target and target ["match" ] is not None else dict ()
620+ target_exclude = target ["exclude" ] if "exclude" in target and target ["exclude" ] is not None else dict ()
621+ target_rules = target ["rules" ] if "rules" in target and target ["rules" ] is not None else dict ()
622+
623+ parent_match = (match or dict ())
624+ parent_exclude = (exclude or dict ())
625+
626+ # print(target["name"], len(list(target_match.keys())))
627+ # don't add nodes with no matching property, those are groups
628+ if len (list (target_match .keys ())) > 0 :
629+ # print(f"{name}: {target['name']}")
630+ # add the entry itself
631+ new_entries .append (dict (
632+ match = {
633+ ** target_match , # target, i.e. for-matches
634+ ** parent_match , # parent
635+ },
636+ exclude = {
637+ ** target_exclude ,
638+ ** parent_exclude ,
639+ },
640+ rules = {
641+ ** target_rules ,
642+ ** rules ,
643+ },
644+ name = f"{ name } : { target ['name' ]} "
645+ ))
646+
647+ # add the entries children
648+ if "children" in target :
649+ children = target ["children" ]
650+ for child in children :
651+ child_match = child ["match" ] if child and "match" in child and child ["match" ] is not None else dict ()
652+ child_exclude = child ["exclude" ] if child and "exclude" in child and child ["exclude" ] is not None else dict ()
653+
654+ # print(child["name"], len(list(child_match.keys())))
655+ # don't add children with no matching property, those are groups
656+ if len (list (child_match .keys ())) > 0 :
657+ new_entries .append (dict (
658+ match = {
659+ ** child_match ,
660+ ** parent_match
661+ },
662+ rules = {
663+ ** child ["rules" ],
664+ ** rules ,
665+ },
666+ exclude = {
667+ ** child_exclude ,
668+ ** parent_exclude
669+ },
670+ name = f"{ name } : { child ['name' ]} "
671+ ))
672+
673+ for new_entry in new_entries :
674+ self .object_entries_by_name [new_entry ["name" ]] = new_entry
675+ self .object_entries .append (new_entry )
614676
615677 # Discard this entry, do not add to the list without the items it matched with "for"
616678 return
0 commit comments