Save filenames in dir structure. @param {String} path @param {Object} opts @param {Object} obj @param {Function} cb
487747
function saveFiles(path, opts, obj, cb) {
  const noDot = opts.noDot
  var root  = ''

  walk.walk(path, walkFn, function (err) {
    if (err) cb(err)
    cb(null, obj)
  })

  function walkFn(baseDir, filename, stat, next) {
    if (!root) root = baseDir
    baseDir = stripLeadingSlash(baseDir.split(root)[1])

    if (stat.isDirectory()) return next()
    if (noDot) {
      if (/^\./.test(filename)) return next()
    }
    pushArr(baseDir, obj, filename)
    next()
  }
}
910330
function readFileSync( path, opts ) {
	var file;
	try {
		if ( arguments.length > 1 ) {
			file = fs.readFileSync( path, opts );
		} else {
			file = fs.readFileSync( path );
		}
	} catch ( err ) {
		return err;
	}
	return file;
}
368032
def save(obj, path):
    
    with open(path, 'wb') as f:
        try:
            pickle.dump(obj, f, protocol=pickle.HIGHEST_PROTOCOL)
        except Exception as e:
            print('Pickling failed for object {0}, path {1}'.format(obj, path))
            print('Error message: {0}'.format(e))
875330
function load(opts, cb) {
  if(typeof opts === 'function') {
    cb = opts;
    opts = undefined;
  }

  if(typeof opts === 'string') {
    file = opts;
  }else if(typeof opts === 'object') {
    file = opts.file;
  }

  if(file === undefined) file = DEFAULT_FILE;

  var sync = typeof cb !== 'function'
    , stream
    , file
    , reader
    , decoder = new Decoder(this, this.options, file);

  if(!file || typeof file !== 'string' && !(file instanceof Readable)){
    return this.emit('error',
      new Error('cannot load configuration, path or stream expected'));
  }

  // need absolute path to be able to
  // correctly find circular references
  if(typeof file === 'string') {
    file = resolve(file);
  }

  this._file = file;

  if(sync && file && typeof file === 'string') {
    this._lines = (fs.readFileSync(file) + '').split(this.options.eol);
    decoder.parse(this._lines);
    if(opts && opts.directives) {
      this.directives(opts.directives);
    }
    return decoder;
  }

  if(file instanceof Readable) {
    stream = file;
  }else{
    /* istanbul ignore next: cannot mock stdin, readable only */
    stream = opts && opts.stdin ? process.stdin
      : fs.createReadStream(file, this.options.read)
  }

  reader = new LineReader(this.options);

  this.once('load', cb);

  function onEnd() {

    if(opts && opts.directives) {
      this.directives(opts.directives);
    }

    decoder.removeAllListeners('error');
    reader.removeAllListeners('error');
    stream.removeAllListeners('error');

    //console.dir(opts);
    //
    this.onLoad();

    this.emit('load', this);
  }

  function onLines(lines) {
    this._lines = this._lines.concat(lines);
  }

  var onError = this.onError.bind(this);
  decoder.on('error', onError);
  stream.on('error', onError);
  reader.on('error', onError);

  // listen for includes
  this.on('include', this.onInclude.bind(this))

  // listen for lines on the primary configuration.
  decoder.on('lines', onLines.bind(this));

  stream.on('end', onEnd.bind(this));
  stream.pipe(reader).pipe(decoder);
  return reader;
}
676473
function load(opts, cb) {
  if(typeof opts === 'function') {
    cb = opts;
    opts = null;
  }
  opts = opts || {};
  var files = opts.commands || []
    , i = 0
    , list = []
    , conf = opts.conf
    , rename = conf.get(ConfigKey.RENAME_COMMAND) || []
    , commands = {};

  if(!Array.isArray(files)) {
    files = [files];
  }

  function complete(err) {
    if(err) return cb(err);
    if(Object.keys(commands).length === 0) {
      return cb(new Error('no command definitions found'));
    }
    cb(null, commands);
  }

  /**
   *  Requires the array of files.
   */
  function include(list) {
    var cmd, clazz, i, file, j, name, newname;
    for(i = 0;i < list.length;i++) {
      file = list[i];
      try {
        clazz = require(file);
        // assume it is already instantiated
        if(typeof clazz === 'object') {
          cmd = clazz;
        }else{
          cmd = new clazz(clazz.definition);
        }

        // rename and delete commands
        if(cmd && cmd.definition && cmd.definition.name) {
          for(j = 0;j < rename.length;j++) {
            name = rename[j][0];
            newname = rename[j][1];
            if(name
              && name.toLowerCase() === cmd.definition.name.toLowerCase()) {
              newname = (newname || '').toLowerCase();
              // actually renaming
              if(newname) {
                log.warning(
                  'rename command %s -> %s', cmd.definition.name, newname);
                cmd.definition.name = newname;
              // deleting the command, mark as deleted with false
              }else{
                log.warning(
                  'deleted command %s (%s)', cmd.definition.name, file);
                commands[cmd.definition.name] = false;
                // clear the module cache
                delete require.cache[file];
              }
              break;
            }
          }
        }

        // deleted the command
        if(!require.cache[file]) continue;

        // sanity checks
        if(!(cmd instanceof CommandExec)) {
          throw new Error(
            util.format(
              'module does not export a command exec instance (%s)', file));
        }else if(
          !cmd.definition
          || !cmd.definition.constructor
          || cmd.definition.constructor.name !== Command.name) {
          throw new Error(
            util.format(
              'command does not have a valid definition (%s)', file));
        }else if(!cmd.definition.name) {
          throw new Error(
            util.format(
              'command definition does not have a name (%s)', file));
        }

        if(opts.override !== true && commands[cmd.definition.name]) {
          throw new Error(util.format(
              'duplicate command %s (%s)', cmd.definition.name, file));
        }

        log.debug('loaded %s (%s)', cmd.definition.name, file);

        // map of command names to command exec handlers
        commands[cmd.definition.name] = cmd;
      }catch(e) {
        return complete(e);
      }
    }
    complete();
  }

  /**
   *  Walk the file list array.
   */
  function walk(files, cb, list) {
    var i = 0;
    list = list || [];

    function check(file, cb) {
      fs.stat(file, function onStat(err, stats) {
        if(err) return cb(err);
        if(stats.isFile() && !/\.js$/.test(file)) {
          log.warning('ignoring %s', file);
          return cb();
        }
        if(stats.isFile()) {
          list.push(file);
          return cb(null, list);
        }else{
          return fs.readdir(file, function onRead(err, files) {
            if(err) return cb(err);
            if(!files.length) return cb();
            files = files.map(function(nm) {
              return path.join(file, nm);
            })
            //files.forEach()
            return walk(files, cb, list);
          })
        }
      });
    }

    check(files[i], function onCheck(err, list) {
      if(err) return cb(err);
      if(i === files.length - 1) {
        return cb(null, list);
      }
      i++;
      check(files[i], onCheck);
    });
  }

  walk(files, function onList(err, list) {
    if(err) return complete(err);
    if(list.length === 0) {
      return complete(new Error('no command files found'));
    }
    include(list);
  });
}
1280353
function (opts) {

	// minimal error checking
	if (!_.isObject(opts)) {
		throw new Error('an opts obj must be passed to ReplaceText contructor');
	}
	if (!_.isString(opts.filePath)) {
		throw new Error('filePath must be a string:' + this.filePath.toString && this.filePath.toString());
	}

	this.newVersion = opts.newVersion;

	/////////////////////////////////////////////////
	// file PATH > for creating/deleting old files //
	/////////////////////////////////////////////////
	this.filePath = opts.filePath;
	this.filePathBeg = removeSuffix(this.filePath);
	this.filePathSuffix = returnSuffix(this.filePath);
	this.requireJs = (opts.requireJs === true) && (this.filePathSuffix === '.js');

	///////////////////////////////////////////////
	// file NAME > for grepping > find + replace //
	///////////////////////////////////////////////
	this.fileName = opts.filePath.split('/').pop();
	this.fileNameBeg = removeSuffix(this.fileName);
	this.fileNameSuffix = returnSuffix(this.fileName);
	this.regedFileNameSuffix = escapeRegExp(this.fileNameSuffix);
	this.regedFileNameBeg = escapeRegExp(this.fileNameBeg);
	this.cdnPath = opts.cdnPath;

	// regexes
	this.oldVersionFileNameRegex = new RegExp('(^|\/)' + this.regedFileNameBeg + '\\.[a-z0-9]+' + this.regedFileNameSuffix + '$', "ig");
	this.fileNameRegex = new RegExp('(^|\'|\")(([^\'"]*\/)?)(' + this.regedFileNameBeg + '(\\.[a-z0-9]+' + this.regedFileNameSuffix + ')|' + this.regedFileNameBeg + '(' + this.regedFileNameSuffix + '))', "ig");
	// this.fileNameRegexRequireJs = new RegExp(this.regedFileNameBeg + '\\.[a-z0-9]+(?!' + this.regedFileNameSuffix + ')(?!=)|' + this.regedFileNameBeg + '(?!' + this.regedFileNameSuffix + ')(?!=)', "ig");
	this.fileNameRegexRequireJs = new RegExp(this.regedFileNameBeg + '\\.[a-z0-9]+(?!' + this.regedFileNameSuffix + ')(?!=)("|\')|' + this.regedFileNameBeg + '(?!' + this.regedFileNameSuffix + ')(?!=)("|\')', "ig");

	return _(this).bindAll('assignNewVersion', 'addOutputFileAttrs', 'run');
}
403875
function installPaths(cb) {
  async.parallel({
    node: asyncPath('node'),
    npm: asyncPath('npm'),
    slc: asyncPath('slc')
  }, cb);
}
335944
function ask(file, opts, cb) {
  if (typeof opts === 'function') {
    cb = opts;
    opts = {};
  }
  opts = opts || {};
  var prompt = lazy.inquirer.createPromptModule();
  var fp = path.relative(process.cwd(), file.path);

  var questions = {
    name: 'action',
    type: 'expand',
    message: 'Overwrite `' + fp + '`?',
    value: 'nothing',
    choices: [{
      key: 'n',
      name: 'do not overwrite',
      value: 'skip'
    }, {
      key: 'y',
      name: 'overwrite',
      value: 'write'
    }, {
      key: 'a',
      name: 'overwrite this and all others',
      value: 'force'
    }, {
      key: 'x',
      name: 'abort',
      value: 'abort'
    }, {
      key: 'd',
      name: 'diff comparison between the current and new:',
      value: 'diff'
    }]
  };

  prompt([questions], function (answers) {
    var msg = answers.action;

    switch(answers.action) {
      case 'skip':
        cb(answers.action);
        process.exit(0);

      case 'abort':
        msg = utils.red(utils.error) + ' Aborted. No action was taken.';
        if (!opts.silent) console.log(msg);
        cb(answers.action);
        process.exit(0);

      case 'diff':
        var existing = opts.existing || fs.readFileSync(fp, 'utf8');
        if (lazy.isBinary(existing) && typeof opts.binaryDiff === 'function') {
          opts.binaryDiff(existing, file.contents);
        } else {
          stringDiff(existing, file.contents.toString());
        }
        return ask(file, opts, cb);

      case 'force':
        opts.force = true;
        break;

      case 'write':
        msg = utils.green(utils.success) + ' file written to';
        opts.force = true;
        break;

      default: {
        msg = utils.red(utils.error) + utils.red(' Aborted.') + ' No action was taken.';
        if (!opts.silent) console.log(msg);
        cb(answers.action);
        process.exit(0);
      }
    }

    var rel = path.relative(process.cwd(), fp);
    var filepath = utils[answers.action](rel);
    if (!opts.silent) {
      console.log(msg, filepath);
    }
    return cb(answers.action);
  });
}
484811
function getFileNames(path, extension)
{
    var docPath = __dirname + '/' + path;
    var fileNames = [];
    var findPattern = new RegExp("." + extension + "$");
    var replacePattern = new RegExp("." + extension + "$","g");
    fs.readdirSync( docPath ).forEach( function(fileName ) {
        if( fileName.match( findPattern ) ) {
            fileNames.push( fileName.replace( replacePattern, "" ) );
        }
    });

    verbose && console.log('Read "' + extension + '" files from ' + docPath );

    return fileNames;
}
318247
function readdirRoot (path, cb) {
    if (cb) {
      ancestor.readdir(path, function (error, entries) {
        if (error) return cb(error);
        entries.push('snapshot');
        cb(null, entries);
      });
    } else {
      var entries = ancestor.readdirSync(path);
      entries.push('snapshot');
      return entries;
    }
  }
728647
function(file, cb) {
    zip.entry(fs.createReadStream(file.path), { name: file.name }, cb);
  }
679043
function (opts, cb) {
            var self = this;
            cb = cb || function () {
                };
            opts = opts || {};
            var url = this._getlisturi(opts);
            this.client.get({
                uri: url,
                data:opts
            }, cb);
        }
250972
function makeSrcFile(path, srcDir, name) {
	if (JSDOC.opt.s) return;
	
	if (!name) {
		name = path.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_");
		name = name.replace(/\:/g, "_");
	}
	
	var src = {path: path, name:name, charset: IO.encoding, hilited: ""};
	
	if (defined(JSDOC.PluginManager)) {
		JSDOC.PluginManager.run("onPublishSrc", src);
	}

	if (src.hilited) {
		IO.saveFile(srcDir, name+publish.conf.ext, src.hilited);
	}
}
1028123
function tree (dir, opts, cb) {
  var i = 0
  findPackage(dir, function (err, pkg) {
    pull(
      pull.depthFirst(pkg, function (pkg) {
        pkg.tree = {}
        return pull(
          pfs.readdir(path.resolve(pkg.path, 'node_modules')),
          paramap(maybe(readPackage)),
          pull.filter(function (_pkg) {
            if(!_pkg) return
            _pkg.parent = pkg
            
            pkg.tree[_pkg.name] = _pkg
            return pkg
          })
        )
      }),
      opts.post ? paramap(function (data, cb) {
        //run a post install-style hook.
        opts.post(data, cb)
      }) : pull.through(),
      pull.drain(null, function (err) {
        cb(err === true ? null : err, clean(pkg))
      })
    )
  })
}
365758
function createPathOptions(str, opts) {
    var pathProxy = createPathProxyFromString(str);
    opts = opts || {};
    opts.buildPath = function (path) {
        if (path.setData) {
            path.setData(pathProxy.data);
            // Svg and vml renderer don't have context
            var ctx = path.getContext();
            if (ctx) {
                path.rebuildPath(ctx);
            }
        }
        else {
            var ctx = path;
            pathProxy.rebuildPath(ctx);
        }
    };

    opts.applyTransform = function (m) {
        transformPath(pathProxy, m);
        this.dirty(true);
    };

    return opts;
}
140911
function (opts) {
			var options = extend(true, defaults, opts);

			requireDir(process.cwd() + options.path, {recurse: options.recurse});
		}
958732
function(path, callback, opts) {

		if (!callback) callback = function() { };

		var fallbacks = [];
		if (path.each) {
			if (path.length==0) return;
			fallbacks = path;
			path      = fallbacks.shift()+"";
		}

		//Stuff that will make us not want to load files.
		if (this.failedFiles.contains(path)) return;

		opts = opts || {};
		var file = this.worldPath+path+'.js';
		if (opts.rootPath) file = path+'.js';

		var my = this;
		var err;
		var handleData = function(e,raw) {
			data = false;
			if (!raw) {
				err = e;
				my.failedFiles.push(path);
				/* Continue down our list of fallbacks. */
				if (fallbacks.length>0) {
					my.loadFile(fallbacks, callback, opts);
				} else {
					log_error("File not found: "+file);
				}
			} else {
				try { eval('data='+raw); }
				catch (e) { log_error(e); }
			} callback(err, data);
			return data;
		};

		if (opts.sync) {
			try {
				var data = fs.readFileSync(file);
			} catch (e) {
				this.failedFiles.push(path);
				/* Continue down our list of fallbacks. */
				if (fallbacks.length>0) {
					return this.loadFile(fallbacks, callback, opts);
				} else return e;
			} return handleData(false,data);
		} else {
			fs.readFile(file, handleData);
		}
	}