pyctr.type.save.partdesc.dpfs module

exception pyctr.type.save.partdesc.dpfs.DPFSReadOnlyError[source]

Bases: PartitionDescriptorError

The DPFS level is read-only.

class pyctr.type.save.partdesc.dpfs.DPFS(lv1, lv2, lv3)[source]

Bases: NamedTuple

Parameters:
lv1: LevelData

Alias for field number 0

lv2: LevelData

Alias for field number 1

lv3: LevelData

Alias for field number 2

classmethod from_bytes(data)[source]
Parameters:

data (bytes) –

to_bytes()[source]
class pyctr.type.save.partdesc.dpfs.DPFSLevelChunkBase[source]

Bases: object

u32_list: List[int]
get_active_bit(bit)[source]
Parameters:

bit (int) –

get_all_active_bits()[source]
class pyctr.type.save.partdesc.dpfs.DPFSLevel1(data, tree_selector)[source]

Bases: DPFSLevelChunkBase

Reads the contents of DPFS Level 1. In the DPFS tree, this contains bits that determine which blocks are active in DPFS Level 2.

Parameters:
  • data (bytes) –

  • tree_selector (int) –

class pyctr.type.save.partdesc.dpfs.DPFSLevel2(data, block_size, lv1)[source]

Bases: DPFSLevelChunkBase

Reads the contents of DPFS Level 2. In the DPFS tree, this contains bits that determine which blocks are active in DPFS Level 3.

Parameters:
  • data (bytes) – The DPFS Level 2 data.

  • block_size_log2 – Block size in log2.

  • lv1 (DPFSLevel1) – Level 1 to read active bits from.

  • block_size (int) –

class pyctr.type.save.partdesc.dpfs.DPFSLevel3FileIO(lv3)[source]

Bases: RawIOBase

Parameters:

lv3 (DPFSLevel3) –

read(size=-1)[source]
Parameters:

size (int) –

Return type:

bytes

seek(offset, whence=0)[source]

Change stream position.

Change the stream position to the given byte offset. The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • 0 – start of stream (the default); offset should be zero or positive

  • 1 – current stream position; offset may be negative

  • 2 – end of stream; offset is usually negative

Return the new absolute position.

Parameters:
  • offset (int) –

  • whence (int) –

Return type:

int

write(data)[source]
Parameters:

data (bytes) –

Return type:

int

tell()[source]

Return current stream position.

Return type:

int

readable()[source]

Return whether object was opened for reading.

If False, read() will raise OSError.

Return type:

bool

writable()[source]

Return whether object was opened for writing.

If False, write() will raise OSError.

Return type:

bool

seekable()[source]

Return whether object supports random access.

If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().

Return type:

bool

class pyctr.type.save.partdesc.dpfs.DPFSLevel3(fp, size, block_size, lv2)[source]

Bases: object

Reads the contents of DPFS Level 3. In the DPFS tree, this contains the actual data.

Parameters:
  • fp (BinaryIO) – A file-like object with the DPFS Level 3 data.

  • size (int) – Size of the level. This should be the size of the final data, meaning the actual data read would be twice this size to account for the two chunks.

  • block_size (int) – Block size.

  • lv2 (DPFSLevel2) – Level 2 to read active bits from.

get_data(offset, size)[source]
Parameters:
  • offset (int) –

  • size (int) –

write_data(offset, data)[source]
Parameters: