def __getitem__(self, index):
        """Return the database object.

        Args:
            Name of database object
        Returns:
            index(str): Name of database object.
        """
        if isinstance(index, six.string_types):
            ref = _funcs.nxdb_find_object(self._handle, self._type, index)
            return self._factory(_handle=ref)
        else:
            raise TypeError(index)
Ejemplo n.º 2
0
def find_object(
        parent_handle,  # type: int
        object_class,  # type: typing.Any
        object_name,  # type: typing.Text
):
    # type: (...) -> _database_object.DatabaseObject
    from nixnet.database._cluster import Cluster
    from nixnet.database._ecu import Ecu
    from nixnet.database._frame import Frame
    from nixnet.database._lin_sched import LinSched
    from nixnet.database._lin_sched_entry import LinSchedEntry
    from nixnet.database._pdu import Pdu
    from nixnet.database._signal import Signal
    from nixnet.database._subframe import SubFrame

    class_enum = {
        Cluster: constants.ObjectClass.CLUSTER,
        Ecu: constants.ObjectClass.ECU,
        Frame: constants.ObjectClass.FRAME,
        LinSched: constants.ObjectClass.LIN_SCHED,
        LinSchedEntry: constants.ObjectClass.LIN_SCHED_ENTRY,
        Pdu: constants.ObjectClass.PDU,
        Signal: constants.ObjectClass.SIGNAL,
        SubFrame: constants.ObjectClass.SUBFRAME,
    }.get(object_class)

    if class_enum is None:
        raise ValueError(
            "Unsupported value provided for argument object_class.",
            object_class)

    found_handle = _funcs.nxdb_find_object(parent_handle, class_enum,
                                           object_name)
    if found_handle == 0:
        _errors.raise_xnet_error(_cconsts.NX_ERR_DATABASE_OBJECT_NOT_FOUND)

    return object_class(_handle=found_handle)
Ejemplo n.º 3
0
def find_object(parent_object_ref, object_class, object_name):
    return _funcs.nxdb_find_object(parent_object_ref, object_class,
                                   object_name)
 def __delitem__(self, index):
     ref = _funcs.nxdb_find_object(self._handle, self._type, index)
     _funcs.nxdb_delete_object(ref)
Ejemplo n.º 5
0
 def __getitem__(self, index):
     if isinstance(index, six.string_types):
         ref = _funcs.nxdb_find_object(self._handle, self._type, index)
         return self._factory(ref)
     else:
         raise TypeError(index)