Ejemplo n.º 1
0
    def __getattr__(self, name):
        """
        Query the simulator for a object with the specified name
        and cache the result to build a tree of objects
        """
        if name in self._sub_handles:
            return self._sub_handles[name]

        if name in self._compat_mapping:
            if name not in _deprecation_warned:
                warnings.warn("Use of %s attribute is deprecated" % name)
                _deprecation_warned[name] = True
            return getattr(self, self._compat_mapping[name])

        new_handle = simulator.get_handle_by_name(self._handle, name)

        if not new_handle:
            # To find generated indices we have to discover all
            self._discover_all()
            if name in self._sub_handles:
                return self._sub_handles[name]
            raise AttributeError("%s contains no object named %s" %
                                 (self._name, name))
        self._sub_handles[name] = SimHandle(new_handle)
        return self._sub_handles[name]
Ejemplo n.º 2
0
 def __getattr__(self, name):
     """ Query the simulator for a object with the specified name
         and cache the result to build a tree
     """
     if name in self._sub_handles:
         return self._sub_handles[name]
     new_handle = simulator.get_handle_by_name(self._handle, name)
     if not new_handle:
         self._raise_testerror("%s contains no object named %s" % (self.name, name))
     self._sub_handles[name] = SimHandle(new_handle)
     return self._sub_handles[name]
Ejemplo n.º 3
0
 def __getattr__(self, name):
     """ Query the simulator for a object with the specified name
         and cache the result to build a tree
     """
     if name in self._sub_handles:
         return self._sub_handles[name]
     new_handle = simulator.get_handle_by_name(self._handle, name)
     if not new_handle:
         self._raise_testerror("%s contains no object named %s" %
                               (self.name, name))
     self._sub_handles[name] = SimHandle(new_handle)
     return self._sub_handles[name]
Ejemplo n.º 4
0
    def __hasattr__(self, name):
        """
        Since calling hasattr(handle, "something") will print out a
        backtrace to the log since usually attempting to access a
        non-existent member is an error we provide a 'peek function

        We still add the found handle to our dictionary to prevent leaking
        handles.
        """
        new_handle = simulator.get_handle_by_name(self._handle, name)
        if new_handle:
            self._sub_handles[name] = SimHandle(new_handle)
        return new_handle
Ejemplo n.º 5
0
    def __hasattr__(self, name):
        """
        Since calling hasattr(handle, "something") will print out a
        backtrace to the log since usually attempting to access a
        non-existent member is an error we provide a 'peek function

        We still add the found handle to our dictionary to prevent leaking
        handles.
        """
        if name in self._sub_handles:
            return self._sub_handles[name]
        new_handle = simulator.get_handle_by_name(self._handle, name)
        if new_handle:
            self._sub_handles[name] = SimHandle(new_handle)
        return new_handle
Ejemplo n.º 6
0
 def __getattr__(self, name):
     """ Query the simulator for a object with the specified name
         and cache the result to build a tree
     """
     # python's builtin dir and IPython's dir2 search for these, 
     # raise an AttributeError to avoid incorrect calls to _raise_testerror
     if name in ["__methods__","__members__","trait_names","_getAttributeNames"]:
         raise AttributeError(name)
     if name in self._sub_handles:
         return self._sub_handles[name]
     new_handle = simulator.get_handle_by_name(self._handle, name)
     if not new_handle:
         self._raise_testerror("%s contains no object named %s" %
                               (self.name, name))
     self._sub_handles[name] = SimHandle(new_handle)
     return self._sub_handles[name]
Ejemplo n.º 7
0
    def __getattr__(self, name):
        """Query the simulator for a object with the specified name
        and cache the result to build a tree of objects.
        """
        if name in self._sub_handles:
            sub = self._sub_handles[name]
            return self._sub_handles[name]

        if name.startswith("_"):
            return SimHandleBase.__getattr__(self, name)

        new_handle = simulator.get_handle_by_name(self._handle, name)

        if not new_handle:
            if name in self._compat_mapping:
                return SimHandleBase.__getattr__(self, name)
            raise AttributeError("%s contains no object named %s" % (self._name, name))
        self._sub_handles[name] = SimHandle(new_handle, self._child_path(name))
        return self._sub_handles[name]
Ejemplo n.º 8
0
    def __hasattr__(self, name):
        """Since calling ``hasattr(handle, "something")`` will print out a
        backtrace to the log (since usually attempting to access a
        non-existent member is an error) we provide a 'peek' function.

        We still add the found handle to our dictionary to prevent leaking
        handles.
        """
        if name in self._sub_handles:
            return self._sub_handles[name]

        if name in self._invalid_sub_handles:
            return None

        new_handle = simulator.get_handle_by_name(self._handle, name)
        if new_handle:
            self._sub_handles[name] = SimHandle(new_handle, self._child_path(name))
        else:
            self._invalid_sub_handles[name] = None
        return new_handle
Ejemplo n.º 9
0
    def __getattr__(self, name):
        """
        Query the simulator for a object with the specified name
        and cache the result to build a tree of objects
        """
        if name in self._sub_handles:
            return self._sub_handles[name]

        if name.startswith("_") or name in self._compat_mapping:
            return SimHandleBase.__getattr__(self, name)

        new_handle = simulator.get_handle_by_name(self._handle, name)

        if not new_handle:
            # To find generated indices we have to discover all
            self._discover_all()
            if name in self._sub_handles:
                return self._sub_handles[name]
            raise AttributeError("%s contains no object named %s" % (self._name, name))
        self._sub_handles[name] = SimHandle(new_handle, self._child_path(name))
        return self._sub_handles[name]
Ejemplo n.º 10
0
    def __getattr__(self, name):
        """
        Query the simulator for a object with the specified name
        and cache the result to build a tree of objects
        """
        if name in self._sub_handles:
            return self._sub_handles[name]

        if name.startswith("_") or name in self._compat_mapping:
            return SimHandleBase.__getattr__(self, name)

        new_handle = simulator.get_handle_by_name(self._handle, name)

        if not new_handle:
            # To find generated indices we have to discover all
            self._discover_all()
            if name in self._sub_handles:
                return self._sub_handles[name]
            raise AttributeError("%s contains no object named %s" % (self._name, name))
        self._sub_handles[name] = SimHandle(new_handle, self._child_path(name))
        return self._sub_handles[name]
Ejemplo n.º 11
0
    def __getattr__(self, name):
        """
        Query the simulator for a object with the specified name
        and cache the result to build a tree of objects
        """
        if name in self._sub_handles:
            return self._sub_handles[name]

        if name in self._compat_mapping:
            if name not in _deprecation_warned:
                warnings.warn("Use of %s attribute is deprecated" % name)
                _deprecation_warned[name] = True
            return getattr(self, self._compat_mapping[name])

        new_handle = simulator.get_handle_by_name(self._handle, name)

        if not new_handle:
            # To find generated indices we have to discover all
            self._discover_all()
            if name in self._sub_handles:
                return self._sub_handles[name]
            raise AttributeError("%s contains no object named %s" % (self._name, name))
        self._sub_handles[name] = SimHandle(new_handle)
        return self._sub_handles[name]
Ejemplo n.º 12
0
 def __hasattr__(self, name):
     """Since calling hasattr(handle, "something") will print out a
         backtrace to the log since usually attempting to access a
         non-existent member is an error we provide a 'peek function"""
     return bool(simulator.get_handle_by_name(self._handle, name))