Skip to content

Commit d727803

Browse files
committedSep 25, 2024·
Fix corner case
attribute id is None MEI cluster
1 parent 22e4443 commit d727803

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎ClusterReader.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ def is_attribute_non_volatile(source, attribute_id):
2727
with open(source, 'r') as file:
2828
content = file.read()
2929

30+
print(f"source = {source}")
31+
print(f"attribute_id = {attribute_id}")
3032
soup = BeautifulSoup(content, 'lxml-xml')
3133

3234
# Debug: Print the parsed XML structure (for a quick visual check)
3335
# print("Parsed XML:", soup.prettify())
3436

3537
# Find the attribute with the given ID (convert hex ID from XML to integer for comparison)
36-
attribute = soup.find('attribute', {'id': lambda x: int(x, 16) == attribute_id})
38+
attribute = soup.find('attribute', {'id': lambda x: x is not None and int(x, 16) == attribute_id})
3739

3840
# Debug: Check if the attribute was found
3941
print("Attribute found:", attribute is not None)

‎ParseZap.py

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def find_ram_attributes_and_replace(data, replace=False):
5050
cluster_name = cluster.get('name')
5151
cluster_code = cluster.get('code')
5252

53+
if cluster_code > 0x7FFF: # Not standard cluster ID
54+
continue;
55+
5356
for attribute in cluster.get('attributes', []): # Iterate through the attributes
5457
attribute_code = attribute.get('code') # Get the attribute's code
5558
# Filter global element
@@ -59,6 +62,7 @@ def find_ram_attributes_and_replace(data, replace=False):
5962

6063
attribute_name = attribute.get('name') # Get the attribute's name
6164

65+
print(f"cluster_code = {cluster_code}, attribute_code={attribute_code}, attribute_name = {attribute_name}")
6266
spec_xml = id2XmlMap[cluster_code]['file']
6367
if not is_attribute_non_volatile(spec_xml, attribute_code):
6468
print(f"\033[41m Ignore cluster: {cluster_name}, name:{attribute_name} \033[0m")

0 commit comments

Comments
 (0)
Please sign in to comment.