PathsJson#
A representation of the paths.json
file found in package archives.
The paths.json
file contains information about every file included with the package.
paths: List[PathsEntry]
property
writable
#
All entries included in the package.
Examples#
>>> paths_json = PathsJson.from_path(
... "../test-data/conda-22.9.0-py38haa244fe_2-paths.json"
... )
>>> paths_json.paths
[PathsEntry(relative_path="Lib/site-packages/conda-22.9.0-py3.8.egg-info/PKG-INFO", no_link=False, path_type=PathType(hardlink=True), prefix_placeholder="None", sha256="1323efbd9b3abb527b06435392b39de11710eb3a814e87a8174230c8f5a0826a", size_in_bytes=1229), ...]
>>> paths_json.paths = [PathsEntry(relative_path="new/path", no_link=True, path_type=PathType("softlink"), prefix_placeholder=None, sha256=None, size_in_bytes=None)]
>>> len(paths_json.paths)
1
>>>
__repr__()
#
Returns a representation of the PathsJson.
from_deprecated_package_directory(path)
staticmethod
#
Constructs a new instance by reading older (deprecated) files from a package directory.
In older package archives the paths.json
file does not exist. These packages contain the
information normally present in the paths.json
file spread over different files in the
archive.
This function reads the different files and tries to reconstruct a paths.json
from it.
from_package_archive(path)
staticmethod
#
Parses the package file from archive.
Note: If you want to extract multiple info/*
files then this will be slightly
slower than manually iterating over the archive entries with
custom logic as this skips over the rest of the archive
from_package_directory(path)
staticmethod
#
Parses the object by looking up the appropriate file from the root of the specified Conda archive directory, using a format appropriate for the file type.
For example, if the file is in JSON format, this function reads the appropriate file from the archive, parse the JSON string and return the resulting object. If the file is not in a parsable format or if the file could not be read, this function returns an error.
from_package_directory_with_deprecated_fallback(path)
staticmethod
#
Reads the file from a package archive directory. If the paths.json
file could not be found
use the from_deprecated_package_directory
method as a fallback.
from_path(path)
staticmethod
#
Parses the object from a file specified by a path
, using a format
appropriate for the file type.
For example, if the file is in JSON format, this function reads the data from the file at the specified path, parse the JSON string and return the resulting object. If the file is not in a parsable format or if the file could not read, this function returns an error.
Examples#
from_str(string)
staticmethod
#
Parses the object from a string, using a format appropriate for the file type.
For example, if the file is in JSON format, this function parses the JSON string and returns the resulting object. If the file is not in a parsable format, this function returns an error.
package_path()
staticmethod
#
Returns the path to the file within the Conda archive.
The path is relative to the root of the archive and includes any necessary directories.