File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
1010### Added
1111
12+ * Added ` Model.has_element_with_name ` .
13+ * Added ` Model.find_element_with_name ` .
14+
1215### Changed
1316
1417### Removed
Original file line number Diff line number Diff line change @@ -290,6 +290,38 @@ def has_element(self, element: Element) -> bool:
290290 guid = str (element .guid )
291291 return guid in self ._elements
292292
293+ def has_element_with_name (self , name : str ) -> bool :
294+ """Returns True if the model contains an element with the given name.
295+
296+ Parameters
297+ ----------
298+ name : str
299+ The name to check.
300+
301+ Returns
302+ -------
303+ bool
304+
305+ """
306+ return any (element .name == name for element in self .elements ())
307+
308+ def find_element_with_name (self , name : str ) -> Optional [Element ]:
309+ """Returns True if the model contains an element with the given name.
310+
311+ Parameters
312+ ----------
313+ name : str
314+ The name to check.
315+
316+ Returns
317+ -------
318+ :class:`Element` or None
319+
320+ """
321+ for element in self .elements ():
322+ if element .name == name :
323+ return element
324+
293325 # =============================================================================
294326 # Groups
295327 # =============================================================================
You can’t perform that action at this time.
0 commit comments