Create an event generator for file or directory at given path string.
321284
def _GeneratorFromPath(path):
  """"""
  if not path:
    raise ValueError('path must be a valid string')
  if io_wrapper.IsTensorFlowEventsFile(path):
    return event_file_loader.EventFileLoader(path)
  else:
    return directory_watcher.DirectoryWatcher(
        path,
        event_file_loader.EventFileLoader,
        io_wrapper.IsTensorFlowEventsFile)
826580
public static VAlarm procedure(Trigger trigger, String path) {
		VAlarm alarm = new VAlarm(Action.procedure(), trigger);
		alarm.setDescription(path);
		return alarm;
	}
309938
def _per_file_event_handler(self):
        
        file_event_handler = PatternMatchingEventHandler()
        file_event_handler.on_created = self._on_file_created
        file_event_handler.on_modified = self._on_file_modified
        file_event_handler.on_moved = self._on_file_moved
        file_event_handler._patterns = [
            os.path.join(self._watch_dir, os.path.normpath('*'))]
        # Ignore hidden files/folders and output.log because we stream it specially
        file_event_handler._ignore_patterns = [
            '*/.*',
            '*.tmp',
            os.path.join(self._run.dir, OUTPUT_FNAME)
        ]
        for glob in self._api.settings("ignore_globs"):
            file_event_handler._ignore_patterns.append(
                os.path.join(self._run.dir, glob))

        return file_event_handler
23997
function fsReaddirAsync(root, opts, callback) {
  if (typeof root !== 'string') {
    throw new TypeError('fsReaddir: expect `root` to be string');
  }
  if (typeof opts === 'function') {
    callback = opts;
    opts = {
      objectMode: true,
      EventEmitter: false,
      emitterOptions: {maxListeners: 1},
    };
  }

  opts = opts || {};

  var aborted = false;
  var stream = false;
  var ____cb = callback || noop;

  if (typeof callback !== 'function') {
    opts.objectMode = opts.objectMode || true;
    stream = new ReaddirReadable(opts);
  } else {
    if (opts.EventEmitter) {
      opts.EventEmitter.prototype.destroy = ReaddirReadable.prototype.destroy;
      stream = new opts.EventEmitter(opts.emitterOptions);
    }
  }

  if (!stream) {
    stream = {push: noop, emit: noop, destroy: noop};
  }

  callback = function callbackAndEvents(err, res) {
    ____cb(err, res);
    if (err && err instanceof Error) {
      stream.emit('error', err);
      stream.destroy();
      return;
    }
    stream.push(res);
    stream.emit('finish', res);
    stream.destroy();
  }

  var res = [];
  fs.readdir(root, function(err, files) {
    if (aborted) {return;}
    if (err) {
      return callback(err);
    }

    var pending = files.length;
    if (!pending) {
      return callback(null, res);
    }

    files.forEach(function(fp) {
      if (aborted) {return;}
      fp = path.join(root, fp)

      fs.stat(fp, function(err, stats) {
        if (aborted) {return;}
        if (err) {
          return callback(err);
        }

        if (aborted === false && stats.isDirectory()) {
          stream.emit('folder', fp);
          stream.emit('directory', fp);

          return fsReaddirAsync(fp, function(err, fps) {
            if (aborted) {return;}
            if (err) {
              return callback(err);
            }

            res = res.concat(fps);
            pending -= 1;
            if (!pending) {
              return callback(null, res);
            }
          });
        }
        if (aborted === false && stats.isFile()) {
          stream.emit('file', fp);
          res.push(fp);
          pending -= 1;
          if (!pending) {
            return callback(null, res);
          }
        }
      });
    });
  });

  return stream;
}
403633
def dump_string_to_file(string, filepath):
    """"""
    create_dirs(
        os.path.dirname(filepath)
    )

    with open(filepath, 'a') as outfile:
        outfile.write(string)
        outfile.write('\n')
876344
def make_directory(path):
        
        try:
            makedirs(path)
            logging.debug('Directory created: {0}'.format(path))

        except OSError as e:
            if e.errno != errno.EEXIST:
                raise
957630
function createDir(srcPath, desPath) {
    var pathInfo = path.parse(desPath);
    var searchvalue = pathInfo.root[pathInfo.root.length - 1]
    var start = 0;
    var found = pathInfo.dir.indexOf(searchvalue);
    var subPath = '';
    var dirs = [];

    if (found != -1) {
        while (true) {
            subPath = pathInfo.dir.substr(start, found - start + 1);
            if (subPath != '') {
                dirs.push(subPath);
            }
            start = found + 1;
            found = pathInfo.dir.indexOf(searchvalue, start);
            if (found == -1) {
                if (start < pathInfo.dir.length) {
                    dirs.push(pathInfo.dir.substr(start));
                }
                break;
            }
        }
    }

    subPath = '';
    dirs.forEach(function (dir, num) {
        subPath += dir;
        if (!fs.existsSync(subPath)) {
            try {
                fs.mkdirSync(subPath);
            } catch (e) {
                if (e.code != 'EEXIST') {
                    console.log('[error] ', e);
                };
            }
            console.log('[info] create  dir:', subPath);
        }
        if (num == dirs.length - 1 && pathInfo.base != '') {
            copyFile(srcPath, desPath);
            //console.log('src file:', srcPath);
            //console.log('des file:', desPath);
        }
    });

}
1299085
def load(self, path):
        
        (folder, filename) = os.path.split(path)
        (name, extension) = os.path.splitext(filename)
        return Sound(name, Waveform.load(path))
176948
function File (name, path, type) {
  EventEmitter.call(this);

  this.name = name;
  this.path = path;
  this.type = type;
  this.size = 0;
  this.root = null;
  this.id = null;
  this.lastModified = new Date;
}
528759
public static WatchMonitor create(String path, WatchEvent.Kind<?>... events){
		return create(path, 0, events);
	}
517968
def watch(directory=None, auto_clear=False, extensions=[]):
    """"""
    if directory and not os.path.isdir(directory):
        raise ValueError('Directory not found: ' + directory)
    directory = os.path.abspath(directory)

    # Initial run
    event_handler = ChangeHandler(directory, auto_clear, extensions)
    event_handler.run()

    # Setup watchdog
    observer = Observer()
    observer.schedule(event_handler, path=directory, recursive=True)
    observer.start()

    # Watch and run tests until interrupted by user
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
1007590
def scantree(path: str) -> Generator:
    """"""
    for entry in os.scandir(path):
        if entry.is_dir(follow_symlinks=False):
            yield from scantree(entry.path)
        else:
            if entry.name.endswith('.py'):
                yield entry
217838
def open_file_like(f, mode):
    """"""
    new_fd = isinstance(f, (str, pathlib.Path))
    if new_fd:
        f = open(f, mode)
    try:
        yield f
    finally:
        if new_fd:
            f.close()
678024
function handleEvent(cmd, context, filename, callback) {
  var event = JSON.parse(cmd)
  eventline.route(event)
}
796526
function read (path) {
  return function (done) {
    fs.createReadStream(resolve(__dirname, path))
      .pipe(concat(function (data) {
        done(null, data.toString())
      }))
  }
}
986490
public static WatchMonitor create(Path path, WatchEvent.Kind<?>... events){
		return create(path, 0, events);
	}
576686
def trigger_event(self, event, client, args, force_dispatch=False):
        """"""
        self.controller.process_event(event, client, args, force_dispatch=force_dispatch)