@@ -348,7 +348,7 @@ def parse_attributes(self) -> dict[uint, XmlAttribute]:
348
348
), read_access = Clusters .AccessControl .Enums .AccessControlEntryPrivilegeEnum .kView , write_access = Clusters .AccessControl .Enums .AccessControlEntryPrivilegeEnum .kUnknownEnumValue , write_optional = False )
349
349
return attributes
350
350
351
- def get_command_direction (self , element : ElementTree .Element ) -> CommandType :
351
+ def get_command_type (self , element : ElementTree .Element ) -> CommandType :
352
352
try :
353
353
if element .attrib ['direction' ].lower () == 'responsefromserver' :
354
354
return CommandType .GENERATED
@@ -360,7 +360,7 @@ def get_command_direction(self, element: ElementTree.Element) -> CommandType:
360
360
def parse_unknown_commands (self ) -> list [XmlCommand ]:
361
361
commands = []
362
362
for element , conformance_xml , access_xml in self .command_elements :
363
- if self .get_command_direction (element ) != CommandType .UNKNOWN :
363
+ if self .get_command_type (element ) != CommandType .UNKNOWN :
364
364
continue
365
365
code = int (element .attrib ['id' ], 0 )
366
366
conformance = self .parse_conformance (conformance_xml )
@@ -370,7 +370,7 @@ def parse_unknown_commands(self) -> list[XmlCommand]:
370
370
def parse_commands (self , command_type : CommandType ) -> dict [uint , XmlCommand ]:
371
371
commands = {}
372
372
for element , conformance_xml , access_xml in self .command_elements :
373
- if self .get_command_direction (element ) != command_type :
373
+ if self .get_command_type (element ) != command_type :
374
374
continue
375
375
code = int (element .attrib ['id' ], 0 )
376
376
conformance = self .parse_conformance (conformance_xml )
@@ -412,7 +412,16 @@ def get_problems(self) -> list[ProblemNotice]:
412
412
return self ._problems
413
413
414
414
415
- def add_cluster_data_from_xml (xml : ElementTree .Element , clusters : dict [int , XmlCluster ], derived_clusters : dict [str , XmlCluster ], ids_by_name : dict [str , int ], problems : list [ProblemNotice ]) -> None :
415
+ def add_cluster_data_from_xml (xml : ElementTree .Element , clusters : dict [int , XmlCluster ], pure_base_clusters : dict [str , XmlCluster ], ids_by_name : dict [str , int ], problems : list [ProblemNotice ]) -> None :
416
+ ''' Adds cluster data to the supplied dicts as appropriate
417
+
418
+ xml: XML element read from from the XML cluster file
419
+ clusters: dict of id -> XmlCluster. This function will append new clusters as appropriate to this dict.
420
+ pure_base_clusters: dict of base name -> XmlCluster. This data structure is used to hold pure base clusters that don't have
421
+ an ID. This function will append new pure base clusters as approrpriate to this dict.
422
+ ids_by_name: dict of cluster name -> ID. This function will append new IDs as appropriate to this dict.
423
+ problems: list of any problems encountered during spec parsing. This function will append problems as appropriate to this list.
424
+ '''
416
425
cluster = xml .iter ('cluster' )
417
426
for c in cluster :
418
427
name = c .attrib ['name' ]
@@ -433,7 +442,7 @@ def add_cluster_data_from_xml(xml: ElementTree.Element, clusters: dict[int, XmlC
433
442
if cluster_id :
434
443
clusters [cluster_id ] = new
435
444
else :
436
- derived_clusters [name ] = new
445
+ pure_base_clusters [name ] = new
437
446
438
447
439
448
def check_clusters_for_unknown_commands (clusters : dict [int , XmlCluster ], problems : list [ProblemNotice ]):
@@ -446,14 +455,14 @@ def check_clusters_for_unknown_commands(clusters: dict[int, XmlCluster], problem
446
455
def build_xml_clusters () -> tuple [list [XmlCluster ], list [ProblemNotice ]]:
447
456
dir = os .path .join (os .path .dirname (os .path .realpath (__file__ )), '..' , '..' , 'data_model' , 'clusters' )
448
457
clusters : dict [int , XmlCluster ] = {}
449
- derived_clusters : dict [str , XmlCluster ] = {}
458
+ pure_base_clusters : dict [str , XmlCluster ] = {}
450
459
ids_by_name : dict [str , int ] = {}
451
460
problems : list [ProblemNotice ] = []
452
461
for xml in glob .glob (f"{ dir } /*.xml" ):
453
462
logging .info (f'Parsing file { xml } ' )
454
463
tree = ElementTree .parse (f'{ xml } ' )
455
464
root = tree .getroot ()
456
- add_cluster_data_from_xml (root , clusters , derived_clusters , ids_by_name , problems )
465
+ add_cluster_data_from_xml (root , clusters , pure_base_clusters , ids_by_name , problems )
457
466
458
467
# There are a few clusters where the conformance columns are listed as desc. These clusters need specific, targeted tests
459
468
# to properly assess conformance. Here, we list them as Optional to allow these for the general test. Targeted tests are described below.
@@ -475,11 +484,11 @@ def remove_problem(location: typing.Union[CommandPathLocation, FeaturePathLocati
475
484
clusters [action_id ].accepted_commands [c ].conformance = optional ()
476
485
remove_problem (CommandPathLocation (endpoint_id = 0 , cluster_id = action_id , command_id = c ))
477
486
478
- combine_derived_clusters_with_base (clusters , derived_clusters , ids_by_name )
487
+ combine_derived_clusters_with_base (clusters , pure_base_clusters , ids_by_name )
479
488
480
489
for alias_base_name , aliased_clusters in CLUSTER_ALIASES .items ():
481
490
for id , (alias_name , pics ) in aliased_clusters .items ():
482
- base = derived_clusters [alias_base_name ]
491
+ base = pure_base_clusters [alias_base_name ]
483
492
new = deepcopy (base )
484
493
new .derived = alias_base_name
485
494
new .name = alias_name
@@ -514,7 +523,7 @@ def remove_problem(location: typing.Union[CommandPathLocation, FeaturePathLocati
514
523
return clusters , problems
515
524
516
525
517
- def combine_derived_clusters_with_base (xml_clusters : dict [int , XmlCluster ], derived_clusters : dict [str , XmlCluster ], ids_by_name : dict [str , int ]) -> None :
526
+ def combine_derived_clusters_with_base (xml_clusters : dict [int , XmlCluster ], pure_base_clusters : dict [str , XmlCluster ], ids_by_name : dict [str , int ]) -> None :
518
527
''' Overrides base elements with the derived cluster values for derived clusters. '''
519
528
520
529
def combine_attributes (base : dict [uint , XmlAttribute ], derived : dict [uint , XmlAttribute ], cluster_id : uint ) -> dict [uint , XmlAttribute ]:
@@ -547,7 +556,7 @@ def combine_attributes(base: dict[uint, XmlAttribute], derived: dict[uint, XmlAt
547
556
if base_name in ids_by_name :
548
557
base = xml_clusters [ids_by_name [c .derived ]]
549
558
else :
550
- base = derived_clusters [base_name ]
559
+ base = pure_base_clusters [base_name ]
551
560
552
561
feature_map = deepcopy (base .feature_map )
553
562
feature_map .update (c .feature_map )
0 commit comments