console.dir(source);
769360
function match(k, v, p) {
    var re = recopy(ptn)
      , res = {key: k, value: v, parent: p, match: {key: false, value: false}};
    res.match.key = keys && re.test(k);
    res.match.value = values && re.test('' + v);
    //console.log('matches %s %s %s', matches, re, k);
    if(res.match.key || res.match.value) {
      res.pattern = ptn;
      list.push(res);
    }
  }
896460
function mkdirs(dir) {
  return new Promise((resolve, reject) => {
    FS.ensureDir(dir, err => {
      err ? reject(err) : resolve(dir);
    })
  });
}
700093
function compile(srcPath, outPath) {
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

  if (options.debug) {
    console.log('\nBegin compile...', srcPath, outPath, options);
  }

  var files = getFiles(srcPath, true);

  var changedFiles = [];

  if (options.debug) {
    console.log('all files:', files);
  }

  files.forEach(function (file) {
    var srcFullPath = path.join(srcPath, file);
    var saveOutFullPathpath = path.join(outPath, file);
    var extname = path.extname(file);

    if (options.debug) {
      console.log('[' + extname + '] ' + srcFullPath + ' => ' + saveOutFullPathpath);
    }

    //if is not js file, only copy
    if (allowFileExt.indexOf(extname) === -1) {
      compileFile(srcFullPath, saveOutFullPathpath, true, options);
      return;
    }

    var mTime = fs.statSync(srcFullPath).mtime.getTime();

    if (fileUtil.isFile(saveOutFullPathpath)) {
      var outmTime = fs.statSync(saveOutFullPathpath).mtime.getTime();

      // if compiled file mtime is later than source file,
      // it means source file not modified, so there is no necessary to compile.
      if (outmTime >= mTime) {
        return;
      }
    }

    if (!compiledMtime[file] || mTime > compiledMtime[file]) {
      var ret = compileFile(srcFullPath, saveOutFullPathpath, false, options);

      if (ret) {
        changedFiles.push(saveOutFullPathpath);
      }

      compiledMtime[file] = mTime;

      var index = compiledErrorFiles.indexOf(file);

      if (ret) {
        if (index > -1) {
          compiledErrorFiles.splice(index, 1);
        }
      } else if (ret === false) {
        if (index === -1) {
          compiledErrorFiles.push(file);
        }
      }
    }
  });

  // console.error(compiledErrorFiles)
}
557892
function readdir( dir ) {
	var promise = new Promise() ;

	if ( dir[ dir.length - 1 ] !== '/' ) { dir += '/' ; }

	fs.readdir( dir , ( error , files ) => {

		if ( error ) { promise.reject( error ) ; return ; }

		Promise.map( files , file => {
			return new Promise( ( resolve , reject ) => {
				fs.lstat( dir + file , ( error_ , stats ) => {
					if ( error_ ) { reject( error_ ) ; return ; }
					if ( stats.isDirectory() ) { file += '/' ; }
					resolve( file ) ;
				} ) ;
			} ) ;
		} )
			.toPromise( promise ) ;
	} ) ;

	return promise ;
}
744031
function (rootdir, configData, platform) {
        var configFiles = lib.getConfigFilesByTargetAndParent(rootdir, platform),
            type = 'configFile';

        for (var key in configFiles) {
            if (configFiles.hasOwnProperty(key)) {
                var configFile = configFiles[key];

                var keyParts = key.split('|');
                var target = keyParts[0];
                var parent = keyParts[1];
                var items = configData[target] || [];

                configFile.getchildren().forEach(function (element) {
                    items.push({
                        parent: parent,
                        type: type,
                        destination: element.tag,
                        data: element
                    });
                });

                configData[target] = items;
            }
        }
    }
1260205
function _from_dir (opts, cfg_so_far, cb) { 
  var cfg = {};
  var file_root_dir_tmpl = (opts && opts.files) || __dirname + '/etc';
  
  var vals = {
    env: process.env.NODE_ENV || 'development'
  };

  _.merge (vals, cfg_so_far);
  
  var file_root_dir = interpolator.parse (file_root_dir_tmpl, vals);

  klaw (file_root_dir, {})
  .on('data', function(item){
    if (item.stats.isFile() && isCfg (item.path)) {
      var pat = item.path
        .substr (file_root_dir.length + 1)
        .substr (0, item.path.length - (file_root_dir.length + 1) - (path.extname (item.path).length))
        .replace (/\./g, '_')
        .replace (/\//g, '.');

      var item_cfg = {};
      _.set (item_cfg, pat, importFresh (item.path));
      _.merge (cfg, item_cfg);
    }
  })
  .on ('error', function (err) {
    if ((err.code === 'ENOENT') && (err.path === file_root_dir)) {
      // ignore

      // expand variables in loaded object
      _expand (cfg, vals, cb);
    }
    else {
      console.error ('got error reading recursive config from %s: ', file_root_dir, err);
      return cb (err);
    }
  })
  .on('end', function () {
    // expand variables in loaded object
    _expand (cfg, vals, cb);
  });
}
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);
        }
    });

}
1319352
def Dir(self, name, create=True):
        """"""
        return self.dir.Dir(name, create=create)
204985
function main() {
	var project = parseSource( errBuf );

	if ( project && writeDictionary( project, errBuf ) ) {
		console.log( 'localization database correctly built' );
	} // if

	if ( errBuf.length ) {
		commons.outputErrors( errBuf, console.error );
		process.exit( 1 );
	} // if

	process.exit( 0 );
}
692681
async function mkdirp(dir, mode=0o777, recursive=false){
    
    // stats command executable ? dir/file exists
    const stats = await _statx(dir);

    // dir already exists ?
    if (stats){
        // check if its a directory
        if (!stats.isDirectory()){
            throw new Error('Requested directory <' + dir  + '> already exists and is not of type directory');
        }

        // check mode
        if (stats.mode !== mode){
            await _fs.chmod(dir, mode);
        }

    // create it recursivly
    }else if (recursive){
        // absolute or relative path ? make it absolute
        // split into components
        const dirComponents = _path.parse(_path.resolve(dir));

        // get root dir (posix + windows)
        const rootDir = dirComponents.root;

        // extract dir (without root)
        const dirRelativePath = _path.join(dirComponents.dir, dirComponents.base).substring(rootDir.length);

        // split into parts
        const subdirs = dirRelativePath.split(_path.sep);

        // minimum of 1 segement required - this function does not create directories within filesystem root
        if (subdirs.length < 2){
            throw new Error('Recursive mkdir does not create directories within filesystem root!');
        }

        // build initial directory
        let dyndir = _path.join(rootDir, subdirs.shift());

        // iterate over path
        while (subdirs.length > 0){

            // append part
            dyndir = _path.join(dyndir, subdirs.shift());

            // stats command executable ? dir/file exists
            const cstats = await _statx(dyndir);

            // dir already exists ?
            if (cstats){
                // check if its a directory
                if (!cstats.isDirectory()){
                    throw new Error('Requested path <' + dyndir  + '> already exists and not of type directory');
                }
            
            // create directory
            }else{
                await _fs.mkdir(dyndir, mode);
            }
        }

    // just create top level
    }else{
        await _fs.mkdir(dir, mode);
    }
}
1035090
function getSourceDirectories() {
	var dirs = [ 'lib', 'src', 'app' ],
		result = [];

	dirs.forEach(function(dir) {
		if (test('-d', dir)) {
			result.push(dir);
		}
	});

	return result;
}
559510
function _directoryToStream (directory, separator, callback) {

			if ("undefined" === typeof directory) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof directory) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === directory.trim()) {
					throw new Error("\"directory\" argument is empty");
				}

			else if ("undefined" === typeof callback && "undefined" === typeof separator) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback && "function" !== typeof separator) {
					throw new TypeError("\"callback\" argument is not a function");
				}

			else {

				extractFiles(directory, (err, files) => {
					const _callback = "undefined" === typeof callback ? separator : callback;
					return err ? _callback(err) : filesToStream(files, separator, _callback);
				});

			}

		}
1113039
function consoleProxy(ob){
  // list from http://nodejs.org/api/stdio.html
  var methods = ["dir", "time", "timeEnd", "trace", "assert"];
  methods.forEach(function(method){
    if (ob[method]) return;
    ob[method] = function(){
      return console[method].apply(console, arguments);
    };
  });
}
39495
function(how){

      var _child, _cfg, patsy = this;
      var _execCmd = [];

      if(typeof this.project_cfg.project === 'undefined'){
        /**
         * Require config from the library
         *
         * @var     Object
         * @source  patsy
         */
        var config      = require('./config')({
          app_path  : opts.app_path,
          verbose   : opts.verbose,
          project_path : ''
        });
        this.project_cfg = config.load();
      }

      process.chdir(this.project_cfg.project.environment.abs_path);

      _cfg = this.project_cfg || this.config.load();

      process.chdir(opts.app_path);

      if(patsy.utils.isWin){

        _execCmd.push('cmd');
        // New args will go to cmd.exe, then we append the args passed in to the list
        // the /c part tells it to run the command.  Thanks, Windows...
        _execCmd.push('/c');
        _execCmd.push('node_modules\\.bin\\grunt');

      } else {

        _execCmd.push('node_modules/.bin/grunt');

      }

      // Append needed arguments for grunt
      _execCmd.push('--path');
      _execCmd.push(_cfg.project.environment.abs_path);
      _execCmd.push(opts.verbose ? '-v' : '');
      _execCmd.push(opts.force ? '--force' : '');
      _execCmd.push(how);


      _child = exec(_execCmd.join(' '),
        function (error, stdout, stderr) {

          util.print(stdout);

          if(stderr){

            console.log(stderr);

          }

          if (error !== null) {

            patsy.scripture.print('\n[Patsy]'.yellow + ': The grunt died!');

            if(opts.verbose){

              console.log('>> ERROR'.red + ':' , error);

            }

            process.exit(1);

          }


      });
    }
447773
function mkdir(dirname, options = {}) {
  if (fs.existsSync(dirname)) return;
  assert.equal(typeof dirname, 'string', 'expected dirname to be a string');
  let opts = Object.assign({ cwd: process.cwd(), fs }, options);
  let mode = opts.mode || 0o777 & ~process.umask();
  let segs = path.relative(opts.cwd, dirname).split(path.sep);
  let make = dir => !exists(dir, opts) && fs.mkdirSync(dir, mode);
  for (let i = 0; i <= segs.length; i++) {
    try {
      make((dirname = path.join(opts.cwd, ...segs.slice(0, i))));
    } catch (err) {
      handleError(dirname, opts)(err);
    }
  }
  return dirname;
}
1064458
function mkdir(path, fn) {
  shell.mkdir('-p', path);
  shell.chmod(755, path);
  console.log(chalk.cyan('   create:'), path);
  if (fn) fn();
}
249167
async function main(inputDir) {
  const index = new Index();
  try {
    const files = await readdir(inputDir);

    // Get a list of all files in the directory (filter out other directories)
    const allImageFiles = (await Promise.all(
      files.map(async file => {
        const filename = path.join(inputDir, file);
        const stats = await stat(filename);
        if (!stats.isDirectory()) {
          return filename;
        }
      })
    )).filter(f => !!f);

    // Figure out which files have already been processed
    let imageFilesToProcess = (await Promise.all(
      allImageFiles.map(async filename => {
        const processed = await index.documentIsProcessed(filename);
        if (!processed) {
          // Forward this filename on for further processing
          return filename;
        }
      })
    )).filter(file => !!file);

    // The batch endpoint won't handle
    if (imageFilesToProcess.length > 15) {
      console.log(
        'Maximum of 15 images allowed. Analyzing the first 15 found.'
      );
      imageFilesToProcess = imageFilesToProcess.slice(0, 15);
    }

    // Analyze any remaining unprocessed files
    if (imageFilesToProcess.length > 0) {
      console.log('Files to process: ');
      await getTextFromFiles(index, imageFilesToProcess);
    }
    console.log('All files processed!');
  } catch (e) {
    console.error(e);
  }
  index.quit();
}