/*
Loads up all the tasks found in the given path.
The default task name is as follows:
[dir.subdir.subdir]:[filename]
Ex:
app/start/notifications.js  -> app.start:notifications
rootTask.js -> rootTask
426583
function loadTasks() {
  Entry.setContext(CONTEXT);
  var paths = (this.config.path instanceof Array ? this.config.path : [this.config.path]);
  var valid = 0,
    self = this;
  _.forEach(paths, function(sPath) {
    var taskDir = Component.appPath(sPath);
    try {
      var list = crux.util.readDirectory(taskDir, 'js');
    } catch(e) {
      // No tasks
      log.warn('Crux.tasks: no task definitions found in: %s', sPath);
      return;
    }
    // For each task file found in the folder, we register it.
    list.forEach(function(taskPath) {
      var name = taskPath.replace(taskDir, '');
      if(name.charAt(0) === '/' || name.charAt(0) === "\\") name = name.substr(1);
      name = name.replace('.js','');
      name = name.replace(/\\/g,'.').replace(/\//g, '.');
      var split = name.split('.'),
        taskName = split.pop();
      if(split.length !== 0) {
        var ns = split.join('.');
        taskName = ns + ':' + taskName;
      }
      try {
        var taskModule = require(taskPath);
      } catch(e) {
        log.fatal('Crux.tasks: Failed to load task %s', taskName);
        log.debug(e);
        return;
      }
      var taskObj,
        taskConfig = (typeof self.config.tasks[taskName] === 'undefined' ? {} : self.config.tasks[taskName]);
      if(typeof taskModule === 'function') {
        taskObj = new Entry(taskName);
        taskModule.call(CONTEXT, taskObj, taskConfig);
      } else if(taskModule instanceof Entry) {
        taskObj = taskModule;
      }
      if(taskObj == null) return;
      if(!taskObj) {
        log.trace('Crux.tasks: task %s does not implement a crux.Tasks.Entry. Skipping.', taskName);
        return;
      }
      self.registerTask(taskObj);
      valid++;
    });
  });
  if(valid !== 0) {
    log.trace('Crux.tasks: Loaded %s tasks', valid);
  }
}
70005
def load_path(self, path):
        

        if not foundations.common.path_exists(path):
            return False

        if os.path.isfile(path):
            if path in self.list_files():
                self.set_current_editor(path)
            else:
                self.load_file(path)
        else:
            if not path in self.list_projects():
                self.add_project(path)
        return True
189823
function task(app, name, pattern, dependencies) {
  app.task(name, dependencies || [], function(cb) {
    app.src(pattern, {cwd: __dirname})
      .pipe(app.renderFile('*'))
      .pipe(utils.condense())
      .pipe(beautify({ indent_size: 2 }))
      .pipe(app.conflicts(app.cwd))
      .pipe(app.dest(app.cwd))
      .on('error', cb)
      .on('end', function() {
        app.build('prompt-install', cb);
      })
  });
}
561724
function(path) {
      var code = require('fs').readFileSync(path);
      var context = vm.createContext(initContext);
      context.flow = _conn.flow;
      vm.runInContext(code, context);
      for (var key in context) {
        if (!initContext[key]) {
          global[key] = context[key];
        }
      }
    }
996990
async function dirExists(path) {
  try {
    const stats = await stat(path);
    return stats.isDirectory() ? true : false;
  } catch (err) {
    return false;
  }
}
803199
function walkTree(dirPath) {
    let filesindir = [];
    return new Promise((res, rej) => {
        if (dirPath.match(/node_modules|.git|bower|LICENCE|tree.json/)) {
            rej([]);
        }

        const relative = `${dirPath}/`,
            readPath = dirPath === '.' ? ROOT + '/' : dirPath + '/';

        readdir(path.resolve(readPath))
            .then(files => {
                files.map(async(i) => {
                    let file;
                    if (fs.statSync(path.join(relative, i)).isDirectory()) {
                        file = {
                            name: i,
                            type: 'dir',
                            path: `${relative}${i}`,
                            files: {}
                        }
                    } else {
                        file = {
                            id: id,
                            name: i,
                            type: 'file',
                            path: `${relative}${i}`,
                            imports: [],
                            exports: []
                        }
                        AllFiles[id++] = file;
                    }
                    filesindir.push(file);
                })
                res(filesindir);
            })
            .catch(err => {
                console.error(err);
                rej([]);
            })
    })
}
794311
def load(cls, path, base=None):
        ''''''
        base = base or os.getcwd()
        absolute = os.path.abspath(path)
        parent = os.path.dirname(absolute)
        name, _, _ = os.path.basename(absolute).rpartition('.py')
        fobj, path, description = imp.find_module(name, [parent])
        try:
            imp.load_module(name, fobj, path, description)
        finally:
            if fobj:
                fobj.close()
        # Manipulate the full names of the tasks to be relative to the provided
        # base
        relative, _, _ = os.path.relpath(path, base).rpartition('.py')
        for task in cls._cache:
            parts = relative.split(os.path.sep)
            parts.append(task.name)
            # If it's either in shovel.py, or folder/__init__.py, then we
            # should consider it as being at one level above that file
            parts = [part.strip('.') for part in parts if part not in
                ('shovel', '.shovel', '__init__', '.', '..', '')]
            task.fullname = '.'.join(parts)
            logger.debug('Found task %s in %s' % (task.fullname, task.module))
        return cls.clear()
793021
function loadFromFile(path) {
    var data = fs.readFileSync(path, {encoding: "utf8"});
    _root = Repository.readObject(data);
    return _root;
}
1117259
def import_and_get_task(task_path):
    
    module, function = task_path.rsplit('.', 1)
    app_module = importlib.import_module(module)
    app_function = getattr(app_module, function)
    return app_function
1315873
function load(path, callback, errorCallback) {
  try {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", path, true);
    xhr.onreadystatechange = function() {
      if (xhr.readyState === 4) {
        if (xhr.status === 200 || xhr.status === 304) {
          try {
            var response = JSON.parse(xhr.responseText);
            callback(response);
          } catch (e) {
            errorCallback(e);
          }
        } else {
          errorCallback(xhr);
        }
      }
    };
    xhr.setRequestHeader("Content-Type", "application/json");
    xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    xhr.send();
  } catch (e) {
    errorCallback(e);
  }
}
129807
function importTasks(options) {
  const opts = parseOptions(options);
  const cwd = process.cwd();
  const dir = path.join(cwd, opts.dir);

  debug(`importing tasks from "${dir}"...`);

  // This synchronously reads the contents within the chosen directory then
  // loops through each item, verifies that it is in fact a file of the correct
  // file type, then creates the tasks object and registers it with gulp.
  fs.readdirSync(dir).forEach(
    handleFile(dir, opts)
  );

  debug(`finished importing tasks`);
}
1269986
function (path) {
    if (fs.existsSync(path) && fs.statSync(path).isDirectory()) {
      return true;
    }
    return false;
  }
1056324
function preload() {
		var path = config.gulpFiles;

		if (/^[^\/]/.test(path)) {
			path = config.basePath + '/' + path;
		}

		glob.sync(path + '/*/*.js').map(function(file) {
			return file.replace(path, '').split('/').filter(function(split) {
				return !!split;
			});
		}).forEach(function(file) {
			register(
				file[0],
				file[file.length - 1].replace(/\.js$/, ''),
				require(path + '/' + file.join('/'))
			);
		});

		console.log(chalk.cyan('Devour initialized'));

		if (config.verbose) {
			['task', 'pipe'].forEach(function(what) {
				console.log(
					'  - available %ss: %s',
					what,
					what in definitions ? chalk.green(Object.keys(definitions[what]).join(', ')) : chalk.yellow('none')
				);
			});
			console.log('');
		}
	}
81727
function filterRunnables(JSONs, paths, taskName) {
  // since the JSONS array might shrink, pass huxleyfile paths too and shrink
  // accordingly
  if (taskName == null) {
    return [JSONs, paths];
  }

  var filtered = JSONs.map(function(JSONContent) {
    return JSONContent.filter(function(task) {
      return task.name === taskName;
    });
  });

  var newJSONs = [];
  var newPaths = [];
  for (var i = 0; i < filtered.length; i++) {
    if (filtered[i].length !== 0) {
      newJSONs.push(filtered[i]);
      newPaths.push(paths[i]);
    }
  }

  return [newJSONs, newPaths];
}
8385
function startRequested() {
		var start = [];

		if (run.length) {
			run.forEach(function(task) {
				var exists = task.replace(/:.*$/, '') in definitions.task;

				console.log(
					'Task %s %s',
					exists ? chalk.green(task) : chalk.red(task),
					exists ? 'running' : 'not found!'
				);

				if (exists) {
					start.push(task);
				}
			});

			if (start.length) {
				gulp.start.apply(gulp, start.concat([function(error) {
					if (error) {
						throw new Error(error);
					}

					console.log('Complete');
				}]));
			}
			else {
				console.log(chalk.red('No tasks are running, exiting!'));
				process.exit(1);
			}
		}

		return !!start.length;
	}
912708
function filterFilesForUnchangedTasks(before, after, paths) {
  var pathsRes = [];
  var tasksRes = [];

  for (var i = 0; i < before.length; i++) {
    var unchangedTasks = filterUnchangedTasks(before[i], after[i]);
    if (unchangedTasks.length > 0) {
      tasksRes.push(unchangedTasks);
      pathsRes.push(paths[i]);
    }
  }

  return [tasksRes, pathsRes];
}
742325
function(arg1) {
        if (arg1 == null) { return null; }
        var args = ['init', name, 'root'].concat(grunt.utils.toArray(arguments));
        return grunt.task.getFile.apply(grunt.file, args);
      }