Skip to content

SparseRepoData#

SparseRepoData #

A class to enable loading records from a repodata.json file on demand. Since most of the time you don't need all the records from the repodata.json this can help provide some significant speedups.

subdir: str property #

Returns the subdirectory from which this repodata was loaded.

Examples#
>>> from rattler import Channel, ChannelConfig
>>> channel = Channel("dummy", ChannelConfig())
>>> subdir = "test-data/dummy/noarch"
>>> path = "../test-data/channels/dummy/linux-64/repodata.json"
>>> sparse_data = SparseRepoData(channel, subdir, path)
>>> sparse_data.subdir
'test-data/dummy/noarch'
>>>

__repr__() #

Returns a representation of the SparseRepoData.

Examples#
>>> from rattler import Channel, ChannelConfig
>>> channel = Channel("dummy", ChannelConfig())
>>> subdir = "test-data/dummy/noarch"
>>> path = "../test-data/channels/dummy/linux-64/repodata.json"
>>> sparse_data = SparseRepoData(channel, subdir, path)
>>> sparse_data
SparseRepoData(subdir="test-data/dummy/noarch")
>>>

load_records(package_name) #

Returns all the records for the specified package name.

Examples#
>>> from rattler import Channel, ChannelConfig, RepoDataRecord, PackageName
>>> channel = Channel("dummy", ChannelConfig())
>>> subdir = "test-data/dummy/noarch"
>>> path = "../test-data/channels/dummy/linux-64/repodata.json"
>>> sparse_data = SparseRepoData(channel, subdir, path)
>>> package_name = PackageName(sparse_data.package_names()[0])
>>> records = sparse_data.load_records(package_name)
>>> records
[...]
>>> isinstance(records[0], RepoDataRecord)
True
>>>

load_records_recursive(repo_data, package_names) staticmethod #

Given a set of [SparseRepoData]s load all the records for the packages with the specified names and all the packages these records depend on. This will parse the records for the specified packages as well as all the packages these records depend on.

Examples#
>>> from rattler import Channel, ChannelConfig, PackageName
>>> channel = Channel("dummy")
>>> subdir = "test-data/dummy/linux-64"
>>> path = "../test-data/channels/dummy/linux-64/repodata.json"
>>> sparse_data = SparseRepoData(channel, subdir, path)
>>> package_name = PackageName("python")
>>> SparseRepoData.load_records_recursive([sparse_data], [package_name])
[...]
>>>

package_names() #

Returns a list over all package names in this repodata file. This works by iterating over all elements in the packages and conda_packages fields of the repodata and returning the unique package names.

Examples#
>>> from rattler import Channel, ChannelConfig
>>> channel = Channel("dummy", ChannelConfig())
>>> subdir = "test-data/dummy/noarch"
>>> path = "../test-data/channels/dummy/linux-64/repodata.json"
>>> sparse_data = SparseRepoData(channel, subdir, path)
>>> package_names = sparse_data.package_names()
>>> package_names
[...]
>>> isinstance(package_names[0], str)
True
>>>