Class: Dependabot::Python::Package::PackageRegistryFinder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/package/package_registry_finder.rb

Constant Summary collapse

PYPI_BASE_URL =
"https://pypi.org/simple/"
ENVIRONMENT_VARIABLE_REGEX =
/\$\{.+\}/
UrlsHash =
T.type_alias { { main: T.nilable(String), extra: T::Array[String] } }

Instance Method Summary collapse

Constructor Details

#initialize(dependency_files:, credentials:, dependency:) ⇒ PackageRegistryFinder

Returns a new instance of PackageRegistryFinder.



27
28
29
30
31
# File 'lib/dependabot/python/package/package_registry_finder.rb', line 27

def initialize(dependency_files:, credentials:, dependency:)
  @dependency_files = T.let(dependency_files, T::Array[Dependabot::DependencyFile])
  @credentials      = T.let(credentials, T::Array[Dependabot::Credential])
  @dependency       = T.let(dependency, Dependabot::Dependency)
end

Instance Method Details

#registry_urlsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dependabot/python/package/package_registry_finder.rb', line 34

def registry_urls
  extra_index_urls =
    config_variable_index_urls[:extra] +
    pipfile_index_urls[:extra] +
    requirement_file_index_urls[:extra] +
    pip_conf_index_urls[:extra] +
    pyproject_index_urls[:extra]

  extra_index_urls = extra_index_urls.map do |url|
    clean_check_and_remove_environment_variables(url)
  end

  # URL encode any `@` characters within registry URL creds.
  # TODO: The test that fails if the `map` here is removed is likely a
  # bug in Ruby's URI parser, and should be fixed there.
  [main_index_url, *extra_index_urls].map do |url|
    url.rpartition("@").tap { |a| a.first.gsub!("@", "%40") }.join
  end.uniq
end