<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scan(self, **params):
 """ This method should be called periodically if files were added with "missing=False". It will check for the appearance of missing files and ensure an event will be triggered for any that appear. It also needs to be called if the instance could be in WF_POLLING mode as file system changes will only be detected in WF_POLLING mode when scan() is called. The method should be called frequently (perhaps every 1-5 seconds) as part of idle processing in a select/poll loop. The approach is intended to support file appearance and disappearance using kqueue/kevent on BSD while retaining the ability in the future to transparently support inotify on Linux without any code or efficiency impact on callers. For WF_KQUEUE and WF_INOTIFYX mode, processing consists of determining that a pending path is now accessible, and then calling commit() to make the necessary adjustments. This will be efficient as long as the list of pending paths is small. At some point this should be optimized by watching the directory of a pending target (assuming it exists). If the directory changes to indicate the pending path might have appeared, then the next get() call should perform a scan(). For WF_POLLING mode, the entire list of open files is also scanned looking for significant differences in the os.fstat info. If/when inotify is supported here, it is expected that the scan() method would be a no-op. """

        log = self._getparam('log', self._discard, **params)
        pending = len(self.paths_pending)
        log.debug("Checking %d pending path%s", pending, ses(pending))
        for path in self.paths_pending:
            if os.path.exists(path):
                log.debug("pending path %s now accessible, triggering commit()", path)
                self.commit(**params)
                return
        if self._mode == WF_POLLING:
            log.debug("Checking %d open path%s", len(self._poll_stat), ses(len(self._poll_stat)))
            for fd in list(self._poll_stat):
                fstate = self._poll_get_stat(fd, self.fds_open[fd])
                if fstate is None or self._poll_stat[fd] != fstate:
                    self._poll_trigger()
                    break