semvec/pypi-packages huggingface dataset:
swisher 0.1.1
A simple stdlib SquashFS parser.
Requires Python: >=3.8
Keywords: squashfs, filesystem, parser, compression, archive

# swisher
A simple SquashFS parser written only with the Python standard library.

## FAQ
### Q: Why make this?
- This project fills the gap of a small SquashFS parser that can read files in a chunked manner and does not need to dump to disk or mount any volume.

## Usage

### Basic Example
```python
import swisher

# Open a SquashFS file
with open('filesystem.squashfs', 'rb') as f:
    parser = swisher.SquashFSParser(f)

    # Iterate over all entries (depth-first alphabetized order)
    for entry in parser.parse():
        print(f"{entry.path} - {entry.size} bytes")

        # Read file data in chunks if it's a regular file
        if not entry.is_dir and entry.read_data:
            for chunk in entry.read_data():
                # Process chunk
                pass
```

### `swisher.SquashFSParser`
Main parser class for reading SquashFS filesystems.

**Constructor:**
- `SquashFSParser(file, chunk_size=32768)`: Initialize parser with a file object
  - `file`: Binary file object opened in read mode
  - `chunk_size`: Size of chunks when reading file data (default: 32KB)

**Methods:**
- `parse()`: Returns an iterator of `SquashFSFileEntry` objects in depth-first alphabetized order
- `parse_tree()`: Returns the root `SquashFSFileEntry` with all children populated as a hierarchical tree
- `read_file_entry_data_chunked(entry)`: Yields file data in chunks for the given entry
- `close()`: Close the underlying file

### `swisher.SquashFSFileEntry`
Represents a file or directory entry in the SquashFS filesystem.

**Attributes:**
- `name`: Filename (str)
- `path`: Full path as a `pathlib.Path` object
- `timestamp`: Last modification time as a `datetime.datetime` object
- `permissions`: Unix-style permission bits (int)
- `size`: File size in bytes (int)
- `physical_offset`: Physical offset of the entry in the SquashFS image (int)
- `is_dir`: True if this entry is a directory (bool)
- `data_info`: File data block information (Optional[`FileDataInfo`])
- `flags`: SquashFS inode flags (int)
- `symlink_target`: Target path if this is a symbolic link (Optional[str])
- `read_data`: Callable that yields file data in chunks (Optional[Callable])
- `inode_type`: SquashFS inode type identifier (int)
- `inode_number`: SquashFS inode number (Optional[int])
- `children`: List of child entries if this is a directory (List[`SquashFSFileEntry`])

### `swisher.FileDataInfo`
Named tuple containing information about how file data is stored in the SquashFS image.

**Attributes:**
- `file_size`: Total size of the file in bytes (int)
- `blocks`: List of `DataBlock` objects representing full data blocks (List[`DataBlock`])
- `fragment`: Fragment information for the file's tail data (Optional[`FragmentInfo`])
- `block_size`: Size of data blocks used in this filesystem (int)