mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-03 08:48:40 +02:00
[common] DictModel get does not raise errors as in Python
getr raises an error if the key does not exist
This commit is contained in:
parent
09525a364e
commit
c986b4a134
4 changed files with 42 additions and 25 deletions
|
@ -43,7 +43,9 @@ class QObjectListModel(QtCore.QAbstractListModel):
|
|||
return self.size() > 0
|
||||
|
||||
def __getitem__(self, index):
|
||||
""" Enables the [] operator """
|
||||
""" Enables the [] operator.
|
||||
Only accepts index (integer).
|
||||
"""
|
||||
return self._objects[index]
|
||||
|
||||
def data(self, index, role):
|
||||
|
@ -96,9 +98,17 @@ class QObjectListModel(QtCore.QAbstractListModel):
|
|||
@QtCore.Slot(str, result=QtCore.QObject)
|
||||
def get(self, key):
|
||||
"""
|
||||
Raises a KeyError if key is not in the map.
|
||||
:param key:
|
||||
:return:
|
||||
:return: the value or None if not found
|
||||
"""
|
||||
return self._objectByKey.get(key)
|
||||
|
||||
@QtCore.Slot(str, result=QtCore.QObject)
|
||||
def getr(self, key):
|
||||
"""
|
||||
Get or raise an error if the key does not exists.
|
||||
:param key:
|
||||
:return: the value
|
||||
"""
|
||||
return self._objectByKey[key]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue