PathsEntry#
A single entry in the paths.json
file.
no_link: bool
property
writable
#
Whether or not this file should be linked or not when installing the package.
Examples#
path_type: PathType
property
writable
#
Determines how to include the file when installing the package.
Examples#
prefix_placeholder: Optional[PrefixPlaceholder]
property
writable
#
Optionally the placeholder prefix used in the file. If this value is None
the prefix is not present in the file.
Examples#
>>> paths_json = PathsJson.from_path(
... "../test-data/conda-22.9.0-py38haa244fe_2-paths.json"
... )
>>> entry = paths_json.paths[0]
>>> entry.prefix_placeholder
>>> new_placeholder = PrefixPlaceholder(FileMode("text"), "placeholder")
>>> entry.prefix_placeholder = new_placeholder
>>> entry.prefix_placeholder
PrefixPlaceholder(file_mode=FileMode("text"), placeholder="placeholder")
>>>
sha256: Optional[bytes]
property
writable
#
A hex representation of the SHA256 hash of the contents of the file. This entry is only present in version 1 of the paths.json file.
Examples#
>>> paths_json = PathsJson.from_path(
... "../test-data/conda-22.9.0-py38haa244fe_2-paths.json"
... )
>>> entry = paths_json.paths[0]
>>> entry.sha256.hex()
'1323efbd9b3abb527b06435392b39de11710eb3a814e87a8174230c8f5a0826a'
>>> entry.sha256 = bytes.fromhex('058016a01bb3845320c81755882a367e03a449c1898a3de4f3ea54112fb3eba4')
>>> entry.sha256.hex()
'058016a01bb3845320c81755882a367e03a449c1898a3de4f3ea54112fb3eba4'
>>>
size_in_bytes: Optional[int]
property
writable
#
The size of the file in bytes. This entry is only present in version 1 of the paths.json file.
Examples#
__init__(relative_path, no_link, path_type, prefix_placeholder, sha256, size_in_bytes)
#
Create a new paths entry.
Parameters#
relative_path : str The relative path from the root of the package no_link : bool Whether or not this file should be linked when installing the package path_type : PathType How to include the file when installing the package (hardlink, softlink, or directory) prefix_placeholder : Optional[PrefixPlaceholder] The placeholder prefix used in the file, if any sha256 : Optional[bytes] The SHA256 hash of the file contents (only used in paths.json version 1) size_in_bytes : Optional[int] The size of the file in bytes (only used in paths.json version 1)
Examples#
>>> # Create a basic file entry
>>> entry = PathsEntry(
... relative_path="lib/file.txt",
... no_link=False,
... path_type=PathType("hardlink"),
... prefix_placeholder=None,
... sha256=None,
... size_in_bytes=None
... )
>>> entry.relative_path
'lib/file.txt'
>>> entry.no_link
False
>>> entry.path_type.hardlink
True
>>>
>>> # Create an entry with prefix placeholder
>>> placeholder = PrefixPlaceholder(FileMode("text"), "/old/prefix")
>>> sha256 = bytes.fromhex("c609c2f1a8594abf959388e559d76241e51b0216faa7b37f529255eb1fc2c5eb")
>>> entry = PathsEntry(
... relative_path="bin/script",
... no_link=False,
... path_type=PathType("hardlink"),
... prefix_placeholder=placeholder,
... sha256=sha256,
... size_in_bytes=1234
... )
>>> entry.prefix_placeholder.placeholder
'/old/prefix'
>>> entry.size_in_bytes
1234
>>>
__repr__()
#
Returns a representation of the PathsEntry.