Lookup gemspec file. If not found returns default path.

 Returns String of file path.
501551
def lookup_gemspec
      dot_gemspec = (project.root + '.gemspec').to_s
      if File.exist?(dot_gemspec)
        dot_gemspec.to_s
      else
        project.metadata.name + '.gemspec'
      end
    end
591802
def determine_path
      if source_line.file == SourceLine::DEFAULT_FILE
        return source_line.file
      end

      full_path = File.expand_path(source_line.file)
      pwd       = Dir.pwd

      if full_path.start_with?(pwd)
        from = Pathname.new(full_path)
        to   = Pathname.new(pwd)

        return from.relative_path_from(to).to_s
      else
        return full_path
      end
    end
1166443
def search_for_file(path_suffix)
      path_suffix = path_suffix + '.rb' unless path_suffix.ends_with? '.rb'
      load_paths.each do |root|
        path = File.join(root, path_suffix)
        return path if File.file? path
      end
      nil # Gee, I sure wish we had first_match ;-)
    end
1115318
def _find(self, spec):
        
        if spec.template_path is not None:
            return spec.template_path

        dir_path, file_name = self._find_relative(spec)

        locator = self.loader._make_locator()

        if dir_path is None:
            # Then we need to search for the path.
            path = locator.find_object(spec, self.loader.search_dirs, file_name=file_name)
        else:
            obj_dir = locator.get_object_directory(spec)
            path = os.path.join(obj_dir, dir_path, file_name)

        return path
1081447
def find_file(path, search_path):
    

    if isinstance(search_path, str):
        search_path = [search_path]
    for relative in search_path:
        candidate = os.path.normpath(os.path.join(relative, path))
        if os.path.isfile(candidate):
            return candidate

    return None
124267
private String findPathToGems() throws FileNotFoundException {
        String[] commandParams = cli.getCommandParams(GEM, ENVIRONMENT);
        List<String> lines = cli.runCmd(rootDirectory, commandParams);
        String path = null;
        if (!lines.isEmpty()) {
            path = lines.get(0) + fileSeparator + CACHE;
            if (new File(path).isDirectory() == false) {
                throw new FileNotFoundException();
            }
        }
        return path;
    }
1354128
def file_find(self, load):
        '''
        
        '''
        path = load.get('path')
        if not path:
            return {'path': '',
                    'rel': ''}
        tgt_env = load.get('saltenv', 'base')
        return self.find_file(path, tgt_env)
1346616
def build_default_filepath(self):
        ''''''
        return os.path.join(
            self.app_config.name,
            'scripts',
            self.template_relpath + '.js',
        )
207182
def GetFileEntryByPathSpec(self, path_spec):
    
    volume_index = apfs_helper.APFSContainerPathSpecGetVolumeIndex(path_spec)

    # The virtual root file has not corresponding volume index but
    # should have a location.
    if volume_index is None:
      location = getattr(path_spec, 'location', None)
      if location is None or location != self.LOCATION_ROOT:
        return None

      return apfs_container_file_entry.APFSContainerFileEntry(
          self._resolver_context, self, path_spec, is_root=True,
          is_virtual=True)

    if (volume_index < 0 or
        volume_index >= self._fsapfs_container.number_of_volumes):
      return None

    return apfs_container_file_entry.APFSContainerFileEntry(
        self._resolver_context, self, path_spec)
668461
def fallback_findfile(filename):
    
    mods = [m for m in sys.modules.values() if m and hasattr(m, "__file__") and filename in m.__file__]
    if len(mods) == 0:
        return None
    alt_fn = mods[0].__file__
    if alt_fn[-4:-1] == ".py":
        alt_fn = alt_fn[:-1]  # *.pyc or whatever
    if not os.path.exists(alt_fn) and alt_fn.startswith("./"):
        # Maybe current dir changed.
        alt_fn2 = _cur_pwd + alt_fn[1:]
        if os.path.exists(alt_fn2):
            return alt_fn2
        # Try dirs of some other mods.
        for m in ["__main__", "better_exchook"]:
            if hasattr(sys.modules.get(m), "__file__"):
                alt_fn2 = os.path.dirname(sys.modules[m].__file__) + alt_fn[1:]
                if os.path.exists(alt_fn2):
                    return alt_fn2
    return alt_fn
876547
def FindDefaultFileDir():
  """"""
  base = FindPy2ExeBase()
  if base:
    return os.path.join(base, 'schedule_viewer_files')
  else:
    # For all other distributions 'files' is in the gtfsscheduleviewer
    # directory.
    base = os.path.dirname(gtfsscheduleviewer.__file__)  # Strip __init__.py
    return os.path.join(base, 'files')
1108666
function findConfigFile(filePath) {
		let prev = null
		do {
			const testPath = path.join(filePath, 'tsconfig.json')
			if (fs.existsSync(testPath)) {
				return testPath
			}
			prev = filePath
			filePath = path.dirname(filePath)
		} while (prev !== filePath)
		return undefined
	}
665413
def gemspec
      @gemspec ||= begin
        raise Error.new("Unable to automatically determine gem name from specs in #{base}. Please set the gem name via #{self.class.name}.install_tasks(gem_name: 'name')") unless gem_name
        g = Bundler.load_gemspec(File.join(base, gem_name+'.gemspec'))
        # This is returning the path it would be in if installed normally,
        # override so we get the local path. Also for reasons that are entirely
        # beyond me, #tap makes Gem::Specification flip out so do it old-school.
        g.full_gem_path = base
        g
      end
    end
1162264
def fetch_gemspec(filename)
      Utils.logger.info(
        "Fetching gemspec #{filename} on #{@host}"
      )
      marshal = Gemirro::Configuration.marshal_identifier
      Http.get(host + "/quick/#{marshal}/#{filename}").body
    end
631210
def _get_default_cache_dir(self):
        

        return os.path.join(os.path.dirname(__file__), self._DATA_DIR)
882439
def fetch
      @source.gems.each do |gem|
        versions_for(gem).each do |versions|
          gem.platform = versions[1] if versions
          version = versions[0] if versions
          if gem.gemspec?
            gemfile = fetch_gemspec(gem, version)
            if gemfile
              Utils.configuration.mirror_gemspecs_directory
                   .add_file(gem.gemspec_filename(version), gemfile)
            end
          else
            gemfile = fetch_gem(gem, version)
            if gemfile
              Utils.configuration.mirror_gems_directory
                   .add_file(gem.filename(version), gemfile)
            end
          end
        end
      end
    end
263943
def GetTSKFileByPathSpec(self, path_spec):
    
    # Opening a file by inode number is faster than opening a file
    # by location.
    inode = getattr(path_spec, 'inode', None)
    location = getattr(path_spec, 'location', None)

    if inode is not None:
      tsk_file = self._tsk_file_system.open_meta(inode=inode)
    elif location is not None:
      tsk_file = self._tsk_file_system.open(location)
    else:
      raise errors.PathSpecError(
          'Path specification missing inode and location.')

    return tsk_file