/*
Does all the dirty laundry of capturing variable output, recursively

@param {any} obj
@param {objects} cache
@param {array} currentPath
@param {objects} options
@returns {string}
339340
function dumpObject(obj, cache, currentPath, options){
	// do this on the first call
	var data = '';
	var dataType = getDataType(obj);
	var isSimpleType = (SIMPLETYPES.indexOf(dataType) >= 0);
	var bFirstCall = (currentPath.length == 0);
	var label = dataType;
	var expand = true;
	var expandCells = true;

	if(bFirstCall){
		var topPath = TOP;
		cache.bFilteredLevel = false;
		if(options.label){
			label = options.label + ' - ' + label;
			/*topPath += ' ' + options.label;
			if(topPath.length > CIRCULARTOPSTRINGLIMIT)
				topPath = topPath.substr(0, CIRCULARTOPSTRINGLIMIT) + '...';
			topPath += ' - ' + dataType;*/
		}
		currentPath = [topPath];
	}

	var bEmpty = false;
	var bHeader = !isSimpleType;

	if(isSimpleType){ // Simple types

		switch(dataType){
			case 'Boolean':
				var val = '<span class="'+(obj ? 'nodedump-yes' : 'nodedump-no')+'">' + obj + '</span>';
				data = doRow(dataType, label, val, expand, expandCells);
			break;
			case 'String':
				if(obj.length === 0)
					bEmpty = true;
				else {
					var val = escapeHtml(obj);
					//var val = '<pre><code class="lang-html">' + hljs.highlight('xml', obj).value + '</code></pre>';
					data = doRow(dataType, label, val, expand, expandCells);
				}
			break;
			case 'Math':
			case 'Undefined':
			case 'Null':
				data = doRow1Col(dataType, label, expand);
			break;
			default:
				data = doRow(dataType, label, obj.toString(), expand, expandCells);
			break;
		}

	} else { // Non-Simple types

		// figure out if it should be expanded/collapsed
		expand = options.expand;
		if(typeof options.expand == 'object'){
			expand = expand.indexOf(dataType) > -1 || expand.indexOf(dataType.toLowerCase()) > -1;
		}
		if(expand){
			if(options.collapse == true || (
					typeof options.collapse == 'object' 
					&& (options.collapse.indexOf(dataType) > -1 || options.collapse.indexOf(dataType.toLowerCase()) > -1)
				)
			)
				expand = false;
		}

		switch(dataType){
			case 'RegExp':
			case 'Error':
				data += doRowHeader1Col(dataType, label, expand);
				data += doRow1Col(dataType, obj.toString(), expand);
			break;
			case 'Function':
				bHeader = true;
				data += doRowHeader1Col(dataType, label, expand);
				var txt = obj.toString();
				if(options.syntaxHighlight){
					var purtyText = hljs.highlight('javascript', txt);
					//var purtyText = hljs.highlightAuto(txt);
					txt = purtyText.value;
				} else {
					var txt = escapeHtml(obj.toString());
				}

				data += doRow1Col(dataType, '<pre><code class="lang-javascript">'+txt+'</code></pre>', expand);
				//data += doRow1Col(dataType, '<pre><code>'+escapeHtml(obj.toString())+'</code></pre>', expand);
			break;
			case 'Array':
			case 'Object':
			default:
				// set keys to collapse if an array of types was passed for expand and the current data-type is one of them
				expandCells = expand;
				if(typeof options.expand == 'object' && expand)
					expandCells = false;

				// check for circular references
				var circPath = getPathToCircularRef(obj, cache, currentPath);
				if(circPath.length > 0){
					dataType = CIRCULARREFERENCE;
					data = doRow(dataType, dataType, circPath.join(CIRCULARSPLITSTRING), expand);
				} else {
					var subPath;
					var loopObj = [];
					for(var key in obj)
						loopObj.push(key);
					if(dataType != 'Array' && options.sortKeys){
						loopObj.sort(function (a, b) {
							return a.toLowerCase().localeCompare(b.toLowerCase());
						});
					}

					cache.level++;
					var filtered = [];
					var bFilteredTop = false;
					var numTotalKeys = loopObj.length;
					var key, val;
					var numKeysShown = 0;
					var numKeysHidden = 0;
					var errThrown;
					for (var i = 0; i < loopObj.length; i++) {
						key = loopObj[i];
						errThrown = '';
						try{
							val = obj[key];
						} catch(err){
							errThrown = err.toString();
						}
						if(bFirstCall){
							if(!(!options.show || (options.show.length && (options.show.indexOf(key) >= 0 || options.show.indexOf(Number(key)) >= 0)))){
								numKeysHidden++;
								continue;
							} else if(options.hide && options.hide.length && (options.hide.indexOf(key) >= 0 || options.hide.indexOf(Number(key)) >= 0)){
								numKeysHidden++;
								continue;
							}
							if(options.top > 0 && numKeysShown === options.top){
								bFilteredTop = true;
								break;
							}
						}
						// skip any data types that should be hidden
						if(options.hideTypes){
							var subDataType = getDataType(val);
							if(options.hideTypes.indexOf(subDataType) > -1 || options.hideTypes.indexOf(subDataType.toLowerCase()) > -1){
								numKeysHidden++;
								continue;
							}
						}

						numKeysShown++;
						if(options.levels !== null && currentPath.length > options.levels){
							cache.bFilteredLevel = true;
							data += doRow(dataType, key, '', true);
							continue;
						}
						
						if(errThrown.length > 0){
							var errorRow = doRowHeader1Col(ERRORDATATYPE, ERRORDATATYPE, true)
											+ doRow1Col(ERRORDATATYPE, '<pre><code class="lang-javascript">'+hljs.highlight('javascript', errThrown).value+'</code></pre>', true);
											//+ doRow1Col(ERRORDATATYPE, errThrown, true);
							data += doRow(dataType, key, doTable(ERRORDATATYPE, errorRow), expandCells);
							continue;
						}
						subPath = clone(currentPath, 'Array');
						subPath.push(key);

						data += doRow(dataType, key, dumpObject(val, cache, subPath, options), expand, expandCells);
					}
					
					if(numTotalKeys === 0)
						bEmpty = true;
					else {
						if(bFirstCall){
							if(numKeysShown !== numTotalKeys){
								if(options.show || options.hideTypes){
									filtered.push(format(TITLEFILTEREDSHOWN, numKeysShown, numTotalKeys));
								} else if(options.hide){
									filtered.push(format(TITLEFILTEREDHIDDEN, numKeysHidden, numTotalKeys));
									numTotalKeys = numTotalKeys - numKeysHidden;
								}
								if(!(options.show || options.hideTypes) && bFilteredTop)
									filtered.push(format(TITLEFILTEREDTOP, numKeysShown, numTotalKeys));
							}
							if(cache.bFilteredLevel)
								filtered.push(format(TITLEFILTEREDLEVELS, options.levels));

						} else if(options.hideTypes && numKeysShown !== numTotalKeys){
							// show the filtered label for types being hidden
							filtered.push(format(TITLEFILTEREDSHOWN, numKeysShown, numTotalKeys));
						}
						if(filtered.length > 0)
							label += format(TITLEFILTERED, filtered.join(', '));

						data = doRowHeader(dataType, label, expand) + data;
					}
				}
			break;
		}

	}

    if(bEmpty)
            data = bHeader ? doRowHeaderEmpty(dataType, label) : doRowEmpty(dataType, label);

    return doTable(dataType, data);
}
1123635
function fetchCache(target, cache) {
        var x,
            length = cache.length,
            curr;

        for (x = 0; x < length; x += 1) {
            curr = cache[x];
            if (curr.target === target) {
                return curr.inspect;
            }
        }

        return null;
    }
1140833
function embed(sourcePath, relativePaths, name, done) {
  var items = '';
  each(relativePaths, function(relativePath, next) {
    var fullPath = path.join(sourcePath, relativePath);
    fs.readFile(fullPath, 'utf8', function(err, text) {
      if (err) return next(err);
      items += '  $templateCache.put(\'' +
        inline(relativePath) + '\', \'' +
        inline(text.trim()) + '\');\n';
      next();
    });
  }, function(err) {
    if (err) return done(err);
    console.log(
      'angular.module(\'' + inline(name) + '\', []).run([\'$templateCache\', function($templateCache) {\n' +
      items +
      '}]);');
    done();
  });
}
73780
function (subpath) {
    var pathAsArray = asArrayPath(subpath);
    var absolutePath = Util.joinPaths(this._path, pathAsArray);
    if (absolutePath.length > 0) {
      var absolutePathAsString = asStringPath(absolutePath);
      var cached = this._sharedInternals.cache[absolutePathAsString];

      if (cached) {
        return cached;
      } else {
        var subBinding = new Binding(absolutePath, this._sharedInternals);
        this._sharedInternals.cache[absolutePathAsString] = subBinding;
        return subBinding;
      }
    } else {
      return this;
    }
  }
169242
function deepValueGetter(obj, path) {
    if (obj == null)
        return '';
    if (!obj || !path)
        return obj;
    // check if path matches a root-level field
    // { "a.b.c": 123 }
    var current = obj[path];
    if (current !== undefined)
        return current;
    current = obj;
    var split = path.split('.');
    if (split.length) {
        for (var i = 0; i < split.length; i++) {
            current = current[split[i]];
            // if found undefined, return empty string
            if (current === undefined || current === null)
                return '';
        }
    }
    return current;
}
286463
function (view, options, uaIdentity) {
            logger.info('try to read cache for: ', view);
            var key = genKey(view, uaIdentity);
            var optsKey = JSON.stringify(options);
            var pool = cache[key] || [];
            var found = _.findWhere(pool, {options: optsKey});

            if (found && found.expireStamp > new Date().getTime()) {
                found.hit = found.hit + 1;
                logger.info('total cache copy: %s, found cache for: ', pool.length, view);
                return found.str;
            } else {
                logger.info('no cache for: ', view);
                return false;
            }
        }
722323
function(paths, callback, results, cached) {
        results = results || [];

        if(!paths.length) {
            callback.apply(null, results);
            return results;
        }

        var path = paths.shift();

        //what do we do if it's not a string ?
        if(typeof path !== 'string') {
            results.push(null);
            //um skip it?
            loadArray(paths, callback, results, cached);
            return;
        }

        acquire.loadPath(path, function(result) {
            results.push(result);
            loadArray(paths, callback, results, cached);
        }, cached);
    }
1060866
function (filepath) {

            // console.log('processing: ' + filepath);

            // read file source, saved in RAM
            var content = grunt.file.read(filepath);

            /*
             * Reset pattern's last search index to 0
             * at the beginning for each file content.
             *
             * NOTE:
             *   Since the pattern is always the same regex instance,
             *   property 'lastIndex' changes each time when .exec() is performed.
             *   To avoid 'lastIndex' affected by recursive function call,
             *   its value MUST be cached for each file content.
             */
            var cacheLastIndex = 0;
            _.pattern.lastIndex = cacheLastIndex;
            var matches = _.pattern.exec(content);
            cacheLastIndex = _.pattern.lastIndex;

            // While there are matches (of import-links) in file content
            while (matches !== null) {

                /*
                 * Construct the imported file's absolute path
                 *   (doesn't matter whether or not a relative path),
                 * and recursively search in imported file. (dept-first)
                 *
                 * NOTE:
                 *    - the regex uses capture group, the first match is the fragment file path.
                 */
                var currentDir = path.dirname(filepath),
                    relativeFilepath = matches[1].trim(),
                    importedFilepath = path.resolve(currentDir, relativeFilepath);

                var returnContent = getReplacedFileContent(importedFilepath);


                /*
                 * For current file content,
                 * replace import-link tag with return value.
                 *
                 * NOTE:
                 *   Because of dept-first search,
                 *   should ONLY replace the first match in current content.
                 *   rather than search globally.
                 */
                content = content.replace(_.patternNonGlobal, returnContent);
                // console.log(content);
                // console.log(matches);
                // console.log('-----');


                /*
                 * Keep searching in current file.
                 *
                 * NOTE:
                 *   After replacing part of the content (the step above),
                 *   the content's length changes accordingly.
                 *   Thus the 'lastIndex' property should shift to
                 *   the proper position to ensure next search.
                 */
                var deltaLength = returnContent.length - matches[0].length;

                _.pattern.lastIndex = cacheLastIndex + deltaLength;
                matches = _.pattern.exec(content);
                cacheLastIndex = _.pattern.lastIndex;
            }

            // When searching and replacing is done, return the result.
            return content;
        }
683357
function variableReplacementBuilder(v) {
        var pattern,
            name = v.name,
            from = v.from,
            to = v.to;

        if (util.isUndefined(to)) {
            grunt.log.error().error('"to" must be defined in a variable replacement instruction');
            return false;
        }

        if (util.isUndefined(name) && util.isUndefined(from)) {
            grunt.log.error().error('one of "name" or "from" must be defined in a variable replacement instruction');
            return false;
        }

        if (!util.isUndefined(name) && !util.isString(name) && !util.isRegex(name)) {
            grunt.log.error().error('"name" must be a string or a regex in a variable replacement instruction');
            return false;
        }

        if (!util.isUndefined(from) && !util.isString(from) && !util.isNumber(from) && !util.isBoolean(from)) {
            grunt.log.error().error('"from" must be a string, a number or a boolean in a variable replacement instruction');
            return false;
        }

        if (!util.isString(to) && !util.isNumber(to) && !util.isBoolean(to)) {
            grunt.log.error().error('"to" must be a string, a number or a boolean in a variable replacement instruction');
            return false;
        }

        pattern = buildVariableReplacementPattern(name, from, to);

        return {
            pattern: pattern,
            replacement: function (match, p1, p2, p3) {
                grunt.log
                    .debug('matching variable replacement'.bold)
                    .debug(('match=' + match).cyan)
                    .debug(('captured groups=' + grunt.log.wordlist([p1, p2, p3])).cyan);

                return p1 + to + p3;
            }
        };
    }
77363
async function(directory, params) {
  const {
    source,
    options = {},
    cacheIdentifier,
    cacheDirectory,
    cacheCompression,
  } = params;

  const file = path.join(directory, filename(source, cacheIdentifier, options));

  try {
    // No errors mean that the file was previously cached
    // we just need to return it
    return await read(file, cacheCompression);
  } catch (err) {}

  const fallback =
    typeof cacheDirectory !== "string" && directory !== os.tmpdir();

  // Make sure the directory exists.
  try {
    await mkdirp(directory);
  } catch (err) {
    if (fallback) {
      return handleCache(os.tmpdir(), params);
    }

    throw err;
  }

  // Otherwise just transform the file
  // return it to the user asap and write it in cache
  const result = await transform(source, options);

  try {
    await write(file, cacheCompression, result);
  } catch (err) {
    if (fallback) {
      // Fallback to tmpdir if node_modules folder not writable
      return handleCache(os.tmpdir(), params);
    }

    throw err;
  }

  return result;
}
813626
function getOutputFile(options) {
  var outFile = options.outFile;

  if (!outFile || typeof outFile !== 'string' || (!options.data && !options.file)) {
    return null;
  }

  return path.resolve(outFile);
}
11001
def in_cache(self, objpath, metahash):
        
        try:
            self.path_in_cache(objpath, metahash)
            return True
        except CacheMiss:
            return False
48271
function read(path, options, fn) {
  var str = readCache[path]

  // cached (only if cached is a string and not a compiled template function)
  if (options.cache && str && typeof str === 'string') return fn(null, str)

  // read
  fs.readFile(path, 'utf8', function(err, str) {
    if (err) return fn(err)
    if (options.cache) readCache[path] = str
    fn(null, str)
  })
}
731083
function (str, options, cb) {
    var self = this;
    if (self.cache(options)) return cb(null, self.cache(options));
    if (options.filename) {
      options.paths = options.paths || [dirname(options.filename)];
    }

    // If this.cache is enabled, compress by default
    if (options.compress !== true && options.compress !== false) {
      options.compress = options.cache || false;
    }

    var initial = this.engine(str);

    // Special handling for stylus js api functions
    // given { define: { foo: 'bar', baz: 'quux' } }
    // runs initial.define('foo', 'bar').define('baz', 'quux')

    var allowed = ['set', 'include', 'import', 'define', 'use'];
    var special = {}
    var normal = clone(options);
    for (var v in options) {
      if (allowed.indexOf(v) > -1) { special[v] = options[v]; delete normal[v]; }
    }

    // special options through their function names
    for (var k in special) {
      for (var v in special[k]) { initial[k](v, special[k][v]); }
    }

    // normal options through set()
    for (var k in normal) {
      initial.set(k, normal[k]);
    }

    initial.render(function (err, res) {
      if (err) return cb(err);
      self.cache(options, res);
      cb(null, res);
    });
  }
198941
function getUserCachePath(options) {
  // If we've manually set the static cache location
  if (options && options.cacheLocation) {
    return path.resolve(options.cacheLocation);
  }

  // Otherwise, find/use the python-ey appdirs cache location
  const dirs = new Appdir({
    appName: 'serverless-python-requirements',
    appAuthor: 'UnitedIncome'
  });
  return dirs.userCache();
}
1350905
function build (data, cache, scope) {
	scope = scope || { var: '' }

	return data
		.map(function (item) {
			return typeof item === 'string'
				? item
					: Buffer.isBuffer(item)
						? item.toString()
						: item.run(cache, scope)
		})
		.join('')
}
823696
function cache(options, compiled) {
  // cachable
  if (compiled && options.filename && options.cache) {
    delete templates[options.filename];
    cacheStore[options.filename] = compiled;
    return compiled;
  }
  // check cache
  if (options.filename && options.cache) {
    return cacheStore[options.filename];
  }
  return compiled;
}