pycdlib.facade

Facade classes to make the main PyCdlib object easier to use.

class PyCdlibISO9660(pycdlib_obj: pycdlib.PyCdlib)

The class representing the PyCdlib ISO9660 facade.

get_file_from_iso(
local_path: str,
iso_path: str,
) → None

Fetch a single file from the ISO via an absolute ISO path and write it out to a local file.

Parameters:
  • local_path – The local file to write to.

  • iso_path – The absolute ISO9660 path to lookup on the ISO.

Returns:

Nothing.

get_file_from_iso_fp(
outfp: BinaryIO,
iso_path: str,
) → None

Fetch a single file from the ISO via an absolute ISO path and write it out to the file object.

Parameters:
  • outfp – The file object to write data to.

  • iso_path – The absolute ISO9660 path to lookup on the ISO.

Returns:

Nothing.

add_fp(
fp: BinaryIO,
length: int,
iso_path: str,
) → None

Add a file to the ISO. While using this facade, a file will only be added to the ISO9660 context (and by extension, the Rock Ridge context). If the ISO is a Rock Ridge one, then a Rock Ridge name will be generated from the ISO path. For more control over which contexts a file shows up in, use the pycdlib.pycdlib.PyCdlib.add_hard_link() API and/or use the regular PyCdlib object (not this facade). Note that the caller must ensure that ‘fp’ remains open for the lifetime of the PyCdlib object, as the PyCdlib class uses the file descriptor internally when writing (mastering) the ISO. To have PyCdlib manage this automatically, use add_file() instead.

Parameters:
  • fp – The file object to use for the contents of the new file.

  • length – The length of the data for the new file.

  • iso_path – The ISO9660 absolute path to the file destination on the ISO.

Returns:

Nothing.

add_file(
filename: str,
iso_path: str,
) → None

Add a file to the ISO. While using this facade, a file will only be added to the ISO9660 context (and by extension, the Rock Ridge context). If the ISO is a Rock Ridge one, then a Rock Ridge name will be generated from the ISO path. For more control over which contexts a file shows up in, use the pycdlib.pycdlib.PyCdlib.add_hard_link() API and/or use the regular PyCdlib object (not this facade).

Parameters:
  • filename – The filename to use for the data contents for the new file.

  • iso_path – The ISO9660 absolute path to the file destination on the ISO.

Returns:

Nothing.

add_directory(iso_path: str) → None

Add a directory to the ISO9660 context (and by extension, the Rock Ridge context). If the ISO is a Rock Ridge one, then a Rock Ridge name will be generated from the ISO path. For more control over which contexts a directory shows up in, use the regular PyCdlib object (not this facade).

Parameters:

iso_path – The ISO9660 absolute path to use for the directory.

Returns:

Nothing.

rm_file(iso_path: str) → None

Remove a file from the ISO. This removes the data and the listing of the file from all contexts. The contexts are tied together by the file’s data extent, and a zero-byte file has none, so for an ISO opened from disk a zero-byte file only has its entry in this facade’s context removed; call this method on each facade to remove it completely.

Parameters:

iso_path – The path to the file to remove.

Returns:

Nothing.

rm_directory(iso_path: str) → None

Remove a directory from the ISO. This removes the directory from just the ISO9660 context (and by extension, the Rock Ridge context). The directory must be empty.

Parameters:

iso_path – The path to the directory to remove.

Returns:

Nothing.

list_children(iso_path: str) → Generator

Generate a list of all of the file/directory objects in the specified location on the ISO.

Parameters:

iso_path – The absolute path on the ISO to list the children for.

Yields:

Children of this path.

Returns:

Nothing.

get_record(
iso_path: str,
) → DirectoryRecord

Get the directory record for a particular ISO path.

Parameters:

iso_path – The absolute path on the ISO9660 filesystem to get the record for.

Returns:

A dr.DirectoryRecord object that represents the path.

walk(iso_path: str) → Generator

Walk the entries on the ISO, starting at the given ISO path. Similar to os.walk(), yield a 3-tuple of (path-to-here, dirlist, filelist) for each directory level.

Parameters:

iso_path – The absolute ISO path to the starting entry on the ISO.

Yields:

3-tuples of (path-to-here, dirlist, filelist)

Returns:

Nothing.

open_file_from_iso(
iso_path: str,
) → pycdlibio.PyCdlibIO

Open a file for reading in a context manager. This allows the user to operate on the file in user-defined chunks (utilizing the read() method of the returned context manager).

Parameters:

iso_path – The absolute ISO path to the file on the ISO.

Returns:

A PyCdlibIO object allowing access to the file.

class PyCdlibJoliet(pycdlib_obj: pycdlib.PyCdlib)

The class representing the PyCdlib Joliet facade.

get_file_from_iso(
local_path: str,
joliet_path: str,
) → None

Fetch a single file from the ISO via an absolute Joliet path and write it out to a local file.

Parameters:
  • local_path – The local file to write to.

  • joliet_path – The absolute Joliet path to lookup on the ISO.

Returns:

Nothing.

get_file_from_iso_fp(
outfp: BinaryIO,
joliet_path: str,
) → None

Fetch a single file from the ISO via an absolute Joliet path and write it out to the file object.

Parameters:
  • outfp – The file object to write data to.

  • joliet_path – The absolute Joliet path to lookup on the ISO.

Returns:

Nothing.

add_fp(
fp: BinaryIO,
length: int,
joliet_path: str,
) → None

Add a file to the ISO. While using this facade, a file will only be added to the Joliet context. For more control over which contexts a file shows up in, use the pycdlib.pycdlib.PyCdlib.add_hard_link() API and/or use the regular PyCdlib object (not this facade). Note that the caller must ensure that ‘fp’ remains open for the lifetime of the PyCdlib object, as the PyCdlib class uses the file descriptor internally when writing (mastering) the ISO. To have PyCdlib manage this automatically, use add_file() instead.

Parameters:
  • fp – The file object to use for the contents of the new file.

  • length – The length of the data for the new file.

  • joliet_path – The Joliet absolute path to the file destination on the ISO.

Returns:

Nothing.

add_file(
filename: str,
joliet_path: str,
) → None

Add a file to the ISO. While using this facade, a file will only be added to the Joliet context. For more control over which contexts a file shows up in, use the pycdlib.pycdlib.PyCdlib.add_hard_link() API and/or use the regular PyCdlib object (not this facade).

Parameters:
  • filename – The filename to use for the data contents for the new file.

  • joliet_path – The Joliet absolute path to the file destination on the ISO.

Returns:

Nothing.

add_directory(joliet_path: str) → None

Add a directory to the Joliet context. For more control over which contexts a directory shows up in, use the regular PyCdlib object (not this facade).

Parameters:

iso_path – The ISO9660 absolute path to use for the directory.

Returns:

Nothing.

rm_file(joliet_path: str) → None

Remove a file from the ISO. This removes the data and the listing of the file from all contexts. The contexts are tied together by the file’s data extent, and a zero-byte file has none, so for an ISO opened from disk a zero-byte file only has its entry in this facade’s context removed; call this method on each facade to remove it completely.

Parameters:

joliet_path – The path to the file to remove.

Returns:

Nothing.

rm_directory(joliet_path: str) → None

Remove a directory from the ISO. This removes the directory from just the Joliet context. The directory must be empty.

Parameters:

joliet_path – The path to the directory to remove.

Returns:

Nothing.

list_children(joliet_path: str) → Generator

Generate a list of all of the file/directory objects in the specified location on the ISO.

Parameters:

joliet_path – The absolute path on the Joliet portion of the ISO to list the children for.

Yields:

Children of this path.

Returns:

Nothing.

get_record(
joliet_path: str,
) → DirectoryRecord

Get the directory record for a particular Joliet path.

Parameters:

joliet_path – The absolute path on the Joliet filesystem to get the record for.

Returns:

A dr.DirectoryRecord object that represents the path.

walk(joliet_path: str) → Generator

Walk the entries on the Joliet portion of the ISO, starting at the given Joliet path. Similar to os.walk(), yield a 3-tuple of (path-to-here, dirlist, filelist) for each directory level.

Parameters:

joliet_path – The absolute Joliet path to the starting entry on the ISO.

Yields:

3-tuples of (path-to-here, dirlist, filelist)

Returns:

Nothing.

open_file_from_iso(
joliet_path: str,
) → pycdlibio.PyCdlibIO

Open a file for reading in a context manager. This allows the user to operate on the file in user-defined chunks (utilizing the read() method of the returned context manager).

Parameters:

joliet_path – The absolute Joliet path to the file on the ISO.

Returns:

A PyCdlibIO object allowing access to the file.

class PyCdlibRockRidge(pycdlib_obj: pycdlib.PyCdlib)

The class representing the PyCdlib Rock Ridge facade.

get_file_from_iso(
local_path: str,
rr_path: str,
) → None

Fetch a single file from the ISO via an absolute Rock Ridge path and write it out to a local file.

Parameters:
  • local_path – The local file to write to.

  • rr_path – The absolute Rock Ridge path to lookup on the ISO.

Returns:

Nothing.

get_file_from_iso_fp(
outfp: BinaryIO,
rr_path: str,
) → None

Fetch a single file from the ISO via an absolute Rock Ridge path and write it out to the file object.

Parameters:
  • outfp – The file object to write data to.

  • joliet_path – The absolute Joliet path to lookup on the ISO.

Returns:

Nothing.

add_fp(
fp: BinaryIO,
length: int,
rr_path: str,
file_mode: int,
) → None

Add a file to the ISO. While using this facade, a file will only be added to the Rock Ridge context (and by extension, the ISO9660 context). For more control over which contexts a file shows up in, use the pycdlib.pycdlib.PyCdlib.add_hard_link() API and/or use the regular PyCdlib object (not this facade). Note that the caller must ensure that ‘fp’ remains open for the lifetime of the PyCdlib object, as the PyCdlib class uses the file descriptor internally when writing (mastering) the ISO. To have PyCdlib manage this automatically, use add_file() instead.

Parameters:
  • fp – The file object to use for the contents of the new file.

  • length – The length of the data for the new file.

  • rr_path – The Rock Ridge absolute path to the file destination on the ISO.

  • file_mode – The POSIX file_mode to apply to this file. If this is None (the default), the permissions from the original file are used.

Returns:

Nothing.

add_file(
filename: str,
rr_path: str,
file_mode: int,
) → None

Add a file to the ISO. While using this facade, a file will only be added to the Rock Ridge context (and by extension, the ISO9660 context). For more control over which contexts a file shows up in, use the pycdlib.pycdlib.PyCdlib.add_hard_link() API and/or use the regular PyCdlib object (not this facade).

Parameters:
  • filename – The filename to use for the data contents for the new file.

  • rr_path – The Rock Ridge absolute path to the file destination on the ISO.

  • file_mode – The POSIX file_mode to apply to this file. If this is None (the default), the permissions from the original file are used.

Returns:

Nothing.

add_directory(
rr_path: str,
file_mode: int,
) → None

Add a directory to the Rock Ridge context (and by extension, the ISO9660 context). For more control over which contexts a directory shows up in, use the regular PyCdlib object (not this facade).

Parameters:
  • rr_path – The Rock Ridge absolute path to use for the directory.

  • file_mode – The POSIX file mode to apply to this directory. If this is None, the directory is given mode 0o555.

Returns:

Nothing.

rm_file(rr_path: str) → None

Remove a file from the ISO. This removes the data and the listing of the file from all contexts. The contexts are tied together by the file’s data extent, and a zero-byte file has none, so for an ISO opened from disk a zero-byte file only has its entry in this facade’s context removed; call this method on each facade to remove it completely.

Parameters:

rr_path – The path to the file to remove.

Returns:

Nothing.

rm_directory(rr_path: str) → None

Remove a directory from the ISO. This removes the directory from just the Rock Ridge context (and by extension, the ISO9660 context). The directory must be empty.

Parameters:

rr_path – The path to the directory to remove.

Returns:

Nothing.

Add a symlink from rr_symlink_name to the rr_path.

Parameters:
  • rr_symlink_path – The absolute Rock Ridge path of the symlink itself on the ISO.

  • rr_target_path – The Rock Ridge path of the entry on the ISO that the symlink points to.

Returns:

Nothing.

list_children(rr_path: str) → Generator

Generate a list of all of the file/directory objects in the specified location on the ISO.

Parameters:

rr_path – The absolute path on the ISO to list the children for.

Yields:

Children of this path.

Returns:

Nothing.

get_record(
rr_path: str,
) → DirectoryRecord

Get the directory record for a particular ISO path.

Parameters:

rr_path – The absolute path on the Rock Ridge filesystem to get the record for.

Returns:

A dr.DirectoryRecord object that represents the path.

walk(rr_path: str) → Generator

Walk the entries on the ISO, starting at the given Rock Ridge path. Similar to os.walk(), yield a 3-tuple of (path-to-here, dirlist, filelist) for each directory level.

Parameters:

rr_path – The absolute Rock Ridge path to the starting entry on the ISO.

Yields:

3-tuples of (path-to-here, dirlist, filelist)

Returns:

Nothing.

open_file_from_iso(
rr_path: str,
) → pycdlibio.PyCdlibIO

Open a file for reading in a context manager. This allows the user to operate on the file in user-defined chunks (utilizing the read() method of the returned context manager).

Parameters:

rr_path – The absolute Rock Ridge path to the file on the ISO.

Returns:

A PyCdlibIO object allowing access to the file.

class PyCdlibUDF(pycdlib_obj: pycdlib.PyCdlib)

The class representing the PyCdlib UDF facade.

get_file_from_iso(
local_path: str,
udf_path: str,
) → None

Fetch a single file from the ISO via an absolute UDF path and write it out to a local file.

Parameters:
  • local_path – The local file to write to.

  • udf_path – The absolute UDF path to lookup on the ISO.

Returns:

Nothing.

get_file_from_iso_fp(
outfp: BinaryIO,
udf_path: str,
) → None

Fetch a single file from the ISO via an absolute UDF path and write it out to the file object.

Parameters:
  • outfp – The file object to write data to.

  • udf_path – The absolute UDF path to lookup on the ISO.

Returns:

Nothing.

add_fp(
fp: BinaryIO,
length: int,
udf_path: str,
) → None

Add a file to the ISO. While using this facade, a file will only be added to the UDF context. For more control over which contexts a file shows up in, use the pycdlib.pycdlib.PyCdlib.add_hard_link() API and/or use the regular PyCdlib object (not this facade). Note that the caller must ensure that ‘fp’ remains open for the lifetime of the PyCdlib object, as the PyCdlib class uses the file descriptor internally when writing (mastering) the ISO. To have PyCdlib manage this automatically, use add_file() instead.

Parameters:
  • fp – The file object to use for the contents of the new file.

  • length – The length of the data for the new file.

  • udf_path – The UDF absolute path to the file destination on the ISO.

Returns:

Nothing.

add_file(filename: str, udf_path: str) → None

Add a file to the ISO. While using this facade, a file will only be added to the UDF context. For more control over which contexts a file shows up in, use the pycdlib.pycdlib.PyCdlib.add_hard_link() API and/or use the regular PyCdlib object (not this facade).

Parameters:
  • filename – The filename to use for the data contents for the new file.

  • udf_path – The UDF absolute path to the file destination on the ISO.

Returns:

Nothing.

add_directory(udf_path: str) → None

Add a directory to the UDF context. For more control over which contexts a directory shows up in, use the regular PyCdlib object (not this facade).

Parameters:

udf_path – The UDF absolute path to use for the directory.

Returns:

Nothing.

rm_file(udf_path: str) → None

Remove a file from the ISO. This removes the data and the listing of the file from all contexts. The contexts are tied together by the file’s data extent, and a zero-byte file has none, so for an ISO opened from disk a zero-byte file only has its entry in this facade’s context removed; call this method on each facade to remove it completely.

Parameters:

udf_path – The path to the file to remove.

Returns:

Nothing.

rm_directory(udf_path: str) → None

Remove a directory from the ISO. This removes the directory from just the UDF context. The directory must be empty.

Parameters:

udf_path – The path to the directory to remove.

Returns:

Nothing.

Add a symlink from udf_symlink_path to udf_target.

Parameters:
  • udf_symlink_path – The UDF path of the symlink itself on the ISO.

  • udf_target – The UDF name of the entry on the ISO that the symlink points to.

Returns:

Nothing.

list_children(udf_path: str) → Generator

Generate a list of all of the file/directory objects in the specified location on the ISO.

Parameters:

udf_path – The absolute path on the ISO to list the children for.

Yields:

Children of this path.

Returns:

Nothing.

get_record(
udf_path: str,
) → UDFFileEntry

Get the directory record for a particular UDF path.

Parameters:

udf_path – The absolute path on the UDF filesystem to get the record for.

Returns:

A udf.UDFFileEntry object that represents the path.

walk(udf_path: str) → Generator

Walk the entries on the ISO, starting at the given UDF path. Similar to os.walk(), yield a 3-tuple of (path-to-here, dirlist, filelist) for each directory level.

Parameters:

udf_path – The absolute UDF path to the starting entry on the ISO.

Yields:

3-tuples of (path-to-here, dirlist, filelist)

Returns:

Nothing.

open_file_from_iso(
udf_path: str,
) → pycdlibio.PyCdlibIO

Open a file for reading in a context manager. This allows the user to operate on the file in user-defined chunks (utilizing the read() method of the returned context manager).

Parameters:

udf_path – The absolute UDF path to the file on the ISO.

Returns:

A PyCdlibIO object allowing access to the file.