MCPcopy Index your code
hub / github.com/BrendanParmer/NodeToPython / process_attr

Function process_attr

tools/node_settings_generator/parse_nodes.py:56–94  ·  view source on GitHub ↗
(attr, section, node: str, version: Version)

Source from the content-addressed store, hash-verified

54 log_file.write(message)
55
56def process_attr(attr, section, node: str, version: Version) -> None:
57 # Get name
58 name_section = attr.find(["code", "span"], class_="sig-name descname")
59 if not name_section:
60 raise ValueError(f"{version.tuple_str()} {node}: Couldn't find name section in\n\t{section}")
61 name = name_section.text
62
63 # Check for deprecation
64 if "Deprecated" in str(attr):
65 log(f"WARNING: {version.tuple_str()} Attribute {node}.{name} "
66 f"was marked deprecated, returning\n")
67 return
68
69 # Get type
70 type_section = attr.find("dd", class_="field-odd")
71 if not type_section:
72 raise ValueError(f"{version.tuple_str()} {node}.{name}: "
73 f"Couldn't find type section in\n\t{section}")
74 type_text = type_section.text
75
76 with mutex:
77 first_word = type_text.split()[0]
78 if first_word not in types_dict:
79 types_dict[first_word] = {type_text}
80 else:
81 types_dict[first_word].add(type_text)
82
83 ntp_type = types_utils.get_NTP_type(type_text)
84 if ntp_type is None:
85 # Read-only attribute, don't add to attribute list
86 log(f"WARNING: {version.tuple_str()} {node}.{name}'s "
87 f"type is being ignored:\n\t{type_text.strip()}\n")
88 return
89
90 ntp_setting = NTPNodeSetting(name, ntp_type)
91 with mutex:
92 if ntp_setting not in nodes_dict[node].attributes_:
93 nodes_dict[node].attributes_[ntp_setting] = []
94 nodes_dict[node].attributes_[ntp_setting].append(version)
95
96def process_node(node: str, section, version: Version):
97 global nodes_dict

Callers 1

process_nodeFunction · 0.85

Calls 3

logFunction · 0.85
tuple_strMethod · 0.80
NTPNodeSettingClass · 0.70

Tested by

no test coverage detected