The path, built as a hash, does not take the source code itself into account
because it would generate lots of file during development. (The source hash
is stored in the metadata instead).
971451
function getCacheFilePaths(props: {
  filePath: string,
  transformOptions: TransformOptions,
}): CacheFilePaths {
  const hasher = imurmurhash()
    .hash(props.filePath)
    .hash(jsonStableStringify(props.transformOptions) || '');
  const hash = toFixedHex(8, hasher.result());
  const prefix = hash.substr(0, 2);
  const fileName = `${hash.substr(2)}${path.basename(props.filePath)}`;
  const base = path.join(getCacheDirPath(), prefix, fileName);
  return {transformedCode: base, metadata: base + '.meta'};
}
894171
function sourcePath(path_request) {
    if (path_request.path) {
      path_request = path_request.path;
    }

    path_request = clean_path(path_request);
    var tmp = path_request.split('/');

    if (_.get(project, 'site.languages.' + tmp[0])) {
      tmp.shift();
    }

    return tmp.join('/');
  }
309164
function compile(source_file_path) {
    let pathParsed = path.parse(source_file_path);
    let nameParsed = path.parse(pathParsed.name);

    if (nameParsed.ext == '.module') {
      return Promise.reject({
        message: 'Modules are not supposed to be loaded'
      });
    }

    var str = fs.readFileSync(source_file_path, {
      encoding: 'utf8'
    });

    return getCompiler(str, source_file_path).render();
  }
398472
function buildSources (path, options) {
  var excludes = options.excludes;
  var sources = [];

  if (options.defaults) {
    sources = options.defaults.concat(sources);
  }

  var environment = getEnvironment(options);

  var basename = nodePath.basename(path);
  var ext = nodePath.extname(basename);

  var pathNoExt = path.slice(0, 0 - ext.length);

  if (!ext) {
    ext = '.json';
  }

  sources.push(pathNoExt + ext);

  if (excludes['env-file'] !== true) {
    sources.push(pathNoExt + '-' + environment + ext);
  }

  if (excludes['local-file'] !== true) {
    sources.push(pathNoExt + '-local' + ext);
  }

  if (excludes['env'] !== true) {
    sources.push(getEnvNodeConfig());
  }

  if (excludes['command-line'] !== true) {
    sources.push(getCommandLineNodeConfig());
  }

  if (options.overrides) {
    sources = sources.concat(options.overrides);
  }

  if (typeof options.sources === 'function') {
    var newSources = options.sources(sources);
    if (newSources != null) {
      sources = newSources;
    }
  }

  return sources;
}
1329856
def source_path options={}
      @source_path ||= if options[:relative]
        File.join collection_path, "#{self.id}.md"
      else
        File.join root_path, collection_path, "#{self.id}.md"
      end
    end
389306
function findByHash(config, hash) {
  const re = new RegExp(injectHashIntoPath(config.sourceMapPath, hash));

  return glob
    .sync('./**')
    .filter(file => re.test(file))
    .map(sourceMapPath => {
      // strip relative path characters
      const sourceMapPathMatch = sourceMapPath.match(re);

      if (sourceMapPathMatch) {
        const minifiedUrl = sourceMapPathMatch[0].replace(
          re,
          injectHashIntoPath(config.minifiedUrl, hash),
        );

        return {
          sourceMapPath,
          minifiedUrl,
        };
      }
    })
    .filter(Boolean);
}
1325845
function _samePaths(file, path2, meta) {
			if (file === null) {
				return path2 === null;
			}
			if (typeof file === 'undefined') {
				return typeof path2 === 'undefined';
			}
			if (path2 === null) {
				return file === null;
			}
			if (typeof path2 === 'undefined') {
				return typeof file === 'undefined';
			}
			//get rid of extensions and compare the names
			var loc = file.location ? file.location : file.Location;
			if (!loc) {
				return false;
			}
			var idx = loc.lastIndexOf('.');
			var p1 = loc;
			if (idx > -1) {
				p1 = loc.slice(0, idx);
			}
			if (path2 === p1) {
				return true; //could be that only the extension was missing from the other path
			}
			idx = path2.lastIndexOf('.');
			var p2 = path2;
			if (idx > -1) {
				p2 = path2.slice(0, idx);
			}
			if (p1 === p2) {
				return true;
			} else if (p1 === decodeURIComponent(p2)) {
				return true;
			}
			return false;
		}
504451
def construct_asset_path(asset_path, css_path, variant)
      public_path = absolute_path(asset_path, css_path)
      return "__EMBED__#{public_path}" if embeddable?(public_path, variant)
      source = asset_path.absolute? || ! Jammit.rewrite_relative_paths ? asset_path.to_s : relative_path(public_path)
      rewrite_asset_path(source, public_path)
    end
1269302
def write_and_get_hash(path, write_to_file, hash=None):
    
    hash = hash or hashlib.md5()
    try:
        # Access path
        r = config.DOWNLOAD_SESSION.get(path, stream=True)
        r.raise_for_status()
        for chunk in r:
            write_to_file.write(chunk)
            hash.update(chunk)

    except (MissingSchema, InvalidSchema):
        # If path is a local file path, try to open the file (generate hash if none provided)
        with open(path, 'rb') as fobj:
            for chunk in iter(lambda: fobj.read(2097152), b""):
                write_to_file.write(chunk)
                hash.update(chunk)

    assert write_to_file.tell() > 0, "File failed to write (corrupted)."

    return hash
767221
def append_path(path)
      self.config = hash_reassoc(config, :paths) do |paths|
        path = File.expand_path(path, config[:root]).freeze
        paths.push(path)
      end
    end
266964
def save_checksum(self, path):
        
        checksum = file_hash(path)
        kv = unitdata.kv()
        kv.set('hardening:%s' % path, checksum)
        kv.flush()
89986
function( /*String*/ path, /*String?*/ encoding) {
					path = frontSlash(path);
					if (encoding === 'utf-8') {
						encoding = 'utf8';
					}
					if (!encoding) {
						encoding = 'utf8';
					}

					var text = cache[path].contents + "";
					//Hmm, would not expect to get A BOM, but it seems to happen,
					//remove it just in case.
					if (text.indexOf('\uFEFF') === 0) {
						text = text.substring(1, text.length);
					}


					return text;
				}
685142
private boolean isInvalidEncodedPath(String path) {
		if (path.contains("%")) {
			try {
				// Use URLDecoder (vs UriUtils) to preserve potentially decoded UTF-8
				// chars
				String decodedPath = URLDecoder.decode(path, "UTF-8");
				if (isInvalidPath(decodedPath)) {
					return true;
				}
				decodedPath = processPath(decodedPath);
				if (isInvalidPath(decodedPath)) {
					return true;
				}
			}
			catch (IllegalArgumentException | UnsupportedEncodingException ex) {
				// Should never happen...
			}
		}
		return false;
	}
247002
def hashed(source_filename, prepared_options, thumbnail_extension, **kwargs):
    
    parts = ':'.join([source_filename] + prepared_options)
    short_sha = hashlib.sha1(parts.encode('utf-8')).digest()
    short_hash = base64.urlsafe_b64encode(short_sha[:9]).decode('utf-8')
    return '.'.join([short_hash, thumbnail_extension])
1093109
function createFilenameHash(uploadDir, files) {
    let hashPath = path.resolve(uploadDir, 'name.json');
    let hashContent;
    let result = [];

    if (hashFileExist || fs.existsSync(hashPath)) {
      try {
        let content = fs.readFileSync(hashPath, 'utf8');
        hashContent = JSON.parse(content);
      } catch (err) {
        debug('get hash file failed:' + err);
      }
    } else {
      hashContent = {};
    }

    for (let item in files) {
      let fileName = files[item].name;
      let hashName = getUniqueId(0, hashContent, fileName);

      let fileItem = getFileItem(files[item], uploadDir)
      hashContent[hashName] = fileItem;
      result.push(util._extend(fileItem, {
        filename: hashName
      }))
    }

    try {
      let file = JSON.stringify(hashContent, null, 2);
      fs.writeFileSync(hashPath, file);
    } catch (err) {
      debug('write hash file failed:' + err);
    }

    hashFileExist = true;

    return result;
  }
1127073
function(path) {
          var node = path.node;
          // console.log('literal node',node);
          if (typeof node.value === 'string') {
            options.sourceNameVariations.forEach(function(variation,index){
              var sourceIndex, typeIndex, segment;
              var sourceRegexp = new RegExp(variation);
              var destReplacement = options.destNameVariations[index];
              var variationIndex = node.value.indexOf(variation);
              if (variationIndex !== -1) {
                // console.log(node.value.indexOf(variation))
                // console.log('match: ',variation, destReplacement, node)
                if (variationIndex === 0 || node.value.charAt(variationIndex - 1) === ' ') {
                  hasSourceRef = true;
                  // console.log(node.value.replace(sourceRegexp, destReplacement))
                  node.value = node.value.replace(sourceRegexp, destReplacement);
                } else {

                  /*
                  example1: my-app/components/foo/bar/foo-bar.js
                  example2: my-app/components/bar/foo-bar.js
                  sourceName: bar/foo-bar.js
                  match the sourceName, determine if the sourcename is at
                  the type root (components for this example)

                  this probably needs to be handled at a structure level.
                  */
                  // console.log(variation + ' matched: ' + node.value + ', but was not first index');
                  sourceIndex = node.value.indexOf(options.sourceName);
                  typeIndex = node.value.indexOf(options.sourceTypeName);
                  segment = node.value.substr((typeIndex + options.sourceTypeName.length + 1), node.value.length);
                  // console.log('diff', segment, options.sourceName,typeIndex, (typeIndex + options.sourceTypeName.length), sourceIndex, options.sourceTypeName);
                  if (segment === options.sourceName) {
                    hasSourceRef = true;
                    node.value = node.value.replace(sourceRegexp, destReplacement);
                    // console.log('rewriting literal', node.value);
                  }
                }
              }
            });
          }
          this.traverse(path);
        }
1153220
def __get_pretty_filepath(path, article):
    
    short_filename = hashlib.sha256(article.filename.encode()).hexdigest()
    sub_dir = article.source_domain
    final_path = path + sub_dir + '/'
    if not os.path.exists(final_path):
        os.makedirs(final_path)
    return final_path + short_filename + '.json'