skppy.data_structure.document

Document metadata data classes.

These classes hold the non-geometric metadata extracted from a .skp file: the binary header, the ZIP container, and individual ZIP entries.

Example

doc = SkpDocument(filepath="model.skp", header=header,
                  zip_entries=entries, model_entry=model_entry)
doc.dump_zip("extracted/")
class skppy.data_structure.document.SkpDocument[source]

Bases: object

ZIP container metadata for a .skp file.

Parameters:
  • filepath (str) – Path to the original .skp file.

  • header (SkpHeader) – Parsed binary header.

  • zip_entries (list of SkpZipEntry) – All entries in the embedded ZIP archive.

  • model_entry (SkpZipEntry or None) – The model.dat entry, or None if missing.

Examples

>>> doc = SkpDocument(filepath="model.skp", header=header,
...                   zip_entries=entries, model_entry=model_entry)
>>> doc.dump_zip("extracted/")
PosixPath('extracted')
__init__(filepath: str, header: SkpHeader, zip_entries: List[SkpZipEntry], model_entry: SkpZipEntry | None) None
dump_zip(output_dir: str) Path[source]

Extract the ZIP contents to output_dir.

The output preserves the internal SKP folder structure.

Parameters:

output_dir (str) – Destination directory. Created if it does not exist.

Returns:

The resolved output directory path.

Return type:

Path

Raises:

ValueError – If an entry attempts to write outside output_dir (zip-slip guard).

Examples

>>> doc.dump_zip("extracted/")
PosixPath('extracted')
class skppy.data_structure.document.SkpZipEntry[source]

Bases: object

Metadata for a single ZIP entry in a .skp file.

Parameters:
  • name (str) – Entry name (path inside the ZIP).

  • file_size (int) – Uncompressed file size in bytes.

  • compress_size (int) – Compressed file size in bytes.

  • crc (int) – CRC-32 checksum.

  • is_dir (bool) – Whether this entry is a directory.

Examples

>>> entry = SkpZipEntry(name="model.dat", file_size=1024,
...                     compress_size=512, crc=12345, is_dir=False)
>>> entry.name
'model.dat'
>>> entry.is_dir
False
__init__(name: str, file_size: int, compress_size: int, crc: int, is_dir: bool) None