MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / get_component_by_path

Method get_component_by_path

python/binaryview.py:7085–7115  ·  view source on GitHub ↗

Lookup a Component by its pathname :note: This is a convenience method, and for performance-sensitive lookups, GetComponentByGuid is very highly recommended. Lookups are done based on the .display_name of the Component. All lookups are absolute from the root component, and are case-sensi

(self, path: str)

Source from the content-addressed store, hash-verified

7083 return component.Component(bn_component)
7084
7085 def get_component_by_path(self, path: str) -> Optional[component.Component]:
7086 """
7087 Lookup a Component by its pathname
7088
7089 :note: This is a convenience method, and for performance-sensitive lookups, GetComponentByGuid is very highly recommended.
7090
7091 Lookups are done based on the .display_name of the Component.
7092
7093 All lookups are absolute from the root component, and are case-sensitive. Pathnames are delimited with "/"
7094
7095 :param path: Pathname of the desired Component
7096 :return: The Component at that pathname
7097
7098 :Example:
7099
7100 >>> c = bv.create_component(name="MyComponent")
7101 >>> c2 = bv.create_component(name="MySubComponent", parent=c)
7102 >>> bv.get_component_by_path("/MyComponent/MySubComponent") == c2
7103 True
7104 >>> c3 = bv.create_component(name="MySubComponent", parent=c)
7105 >>> c3
7106 <Component "MySubComponent (1)" "(20712aff...")>
7107 >>> bv.get_component_by_path("/MyComponent/MySubComponent (1)") == c3
7108 True
7109 """
7110 if not isinstance(path, str):
7111 raise TypeError("Pathname must be a string")
7112 bn_component = core.BNGetComponentByPath(self.handle, path)
7113 if bn_component is None:
7114 return None
7115 return component.Component(bn_component)
7116
7117 @property
7118 def root_component(self) -> component.Component:

Callers

nothing calls this directly

Calls 1

ComponentMethod · 0.80

Tested by

no test coverage detected