if the path isn't being watched, start watching it
            if it is, stop watching it
353939
def update(self, path, verbose=False):
        
        if path in self._by_path:
            self.remove(path)
        else:
            self.add(path, verbose)
288829
def watch(self, path, action, *args, **kwargs):
        
        if action is None:
            action = _set_changed
        event_handler = _WatchdogHandler(self, action)
        self._observer.schedule(event_handler, path=path, recursive=True)
416420
function watchFile(file, callback) {
	let absolutePath = File.find(file).path();
	let watcher = chokidar
		.watch(
			absolutePath,
			{
				persistent: true
			}
		)
		.on(
			'change',
			function () {
				if (typeof callback === 'function') {
					callback(file);
				}
				watcher.unwatch(absolutePath);
				watchFile(file, callback);
			}
		)
	;
}
900766
function(path) {
    var state = window.history.state,
        initialURL = get(this, '_initialURL');

    path = this.formatPath(path);

    if ((initialURL !== path && !state) || (state && state.path !== path)) {
      window.history.pushState({ path: path }, null, path);
    }
  }
214765
private void _watchNode(String path) throws ZooKeeperException {
        try {
            cacheNodeWatcher.get(path);
        } catch (Exception e) {
            if (e instanceof ZooKeeperException) {
                throw (ZooKeeperException) e;
            } else {
                throw new ZooKeeperException(e);
            }
        }
    }
551496
def specific_path_check(path, opt):
    """"""
    if opt.exclude:
        if path in opt.exclude:
            return False

    if opt.include:
        if path not in opt.include:
            return False

    return True
342357
def on_any_path?(paths)
	      path_found = false
	      paths.each do |path|
	       	path_found = on_path?(path) ? true : path_found
	      end
	      return path_found
	    end
278553
def ensure_stopped(self):
        """"""
        if not self.active:
            return self
        self.stop()
        self.observer.cancel()
        self._manager.remove_routes(self, self.get_routing_keys())
        self._active = False
        return self
487783
def pause(self):
        """"""
        if self.state == PygAnimation.PLAYING:
            self.elapsedAtPause = self.elapsed
            # only change state if it was playing
            self.state = PygAnimation.PAUSED

        elif self.state == PygAnimation.STOPPED:
            pass  # nothing to do

        elif self.state == PygAnimation.PAUSED:
            pass
1168717
function watchFile(path, base, rootPath) {
  path = normalize(path);

  var log = '  ' + chalk.gray('watching') + ' ' + chalk.cyan(path);
  if (!base) {
    base = path;
  } else {
    base = normalize(base);
    log += '\n    ' + chalk.gray('as a dependency of') + ' ';
    log += chalk.cyan(base);
  }

  if (watchList[path]) {
    if (watchList[path].indexOf(base) !== -1) return;
    consoleLog(log);
    watchList[path].push(base);
    return;
  }

  consoleLog(log);
  watchList[path] = [base];
  fs.watchFile(path, {persistent: true, interval: 200},
               function (curr, prev) {
    // File doesn't exist anymore. Keep watching.
    if (curr.mtime.getTime() === 0) return;
    // istanbul ignore if
    if (curr.mtime.getTime() === prev.mtime.getTime()) return;
    watchList[path].forEach(function(file) {
      tryRender(file, rootPath);
    });
  });
}
317779
def _checkpath(self, path):
        
        if path.startswith("/") or ".." in path or path.strip() != path:
            raise NotFoundException()
694627
def step(self, viewer=None):
        ""
        if not self.is_completed(self.state):
            for agent in self.agents:
                action = agent.program(self.percept(agent, self.state))
                next_state = self.do_action(self.state, action, agent)
                if viewer:
                    viewer.event(self.state, action, next_state, agent)
                self.state = next_state
                if self.is_completed(self.state):
                    return
7152
def _watch(self, path, current_level, max_level):
        

        # ephemeral znodes can't have children, so skip them
        stat = self._client.exists(path)
        if stat is None or stat.ephemeralOwner != 0:
            return

        try:
            children = self._client.get_children(path, self._watcher)
        except NoNodeError:
            children = []

        if max_level >= 0 and current_level + 1 > max_level:
            return

        for child in children:
            self._watch(os.path.join(path, child), current_level + 1, max_level)
1186184
def exit_if_path_not_found(path):
    
    if not os.path.exists(path):
        ui.error(c.MESSAGES["path_missing"], path)
        sys.exit(1)
1206646
public void watch(Watcher watcher) throws WatchException{
		if(isClosed){
			throw new WatchException("Watch Monitor is closed !");
		}
		registerPath();
//		log.debug("Start watching path: [{}]", this.path);
		
		while (false == isClosed) {
			WatchKey wk;
			try {
				wk = watchService.take();
			} catch (InterruptedException e) {
//				log.warn(e);
				return;
			}
			
			final Path currentPath = watchKeyPathMap.get(wk);
			WatchEvent.Kind<?> kind;
			for (WatchEvent<?> event : wk.pollEvents()) {
				kind = event.kind();
				if(null != this.filePath && false == this.filePath.endsWith(event.context().toString())){
//					log.debug("[{}] is not fit for [{}], pass it.", event.context(), this.filePath.getFileName());
					continue;
				}
				
				if(kind == StandardWatchEventKinds.ENTRY_CREATE){
					watcher.onCreate(event, currentPath);
				}else if(kind == StandardWatchEventKinds.ENTRY_MODIFY){
					watcher.onModify(event, currentPath);
				}else if(kind == StandardWatchEventKinds.ENTRY_DELETE){
					watcher.onDelete(event, currentPath);
				}else if(kind == StandardWatchEventKinds.OVERFLOW){
					watcher.onOverflow(event, currentPath);
				}
			}
			wk.reset();
		}
	}
242574
private synchronized WatchKey getWatchKeyForPath(final String path) throws IOException {
        WatchKey key = watchKeysByPath.get(path);
        if (key == null) {
            logger.debug("Lazy-instantiating watch key for path: {}", path);
            key = Paths.get(path).register(watchService, interested_types);
            watchKeysByPath.put(path, key);
            pathsByWatchKey.put(key, path);
            listenersByWatchKey.put(key, Collections.newSetFromMap(new ConcurrentHashMap<SFMF4JWatchListener, Boolean>()));
        }
        return key;
    }
508158
void showPreview( String path ) {
        synchronized (lockPreview) {
            if( path == null ) {
                pendingPreview = null;
            } else if( previewThread == null ) {
                pendingPreview = path;
                previewThread = new PreviewThread();
                previewThread.start();
            } else {
                pendingPreview = path;
            }
        }
    }