init
This commit is contained in:
71
README.md
Normal file
71
README.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# py-pwr
|
||||
|
||||
Minimal Python client for wharf/pwr files. It parses the wire format,
|
||||
protobuf messages, and can apply patch ops when you provide file index
|
||||
to path mappings.
|
||||
|
||||
## Features
|
||||
- Read `.pwr`, `.pws`, `.pwm`, `.pww` files.
|
||||
- Iterate sync ops and bsdiff controls.
|
||||
- Apply patches for RSYNC and BSDIFF series using target/output file lists.
|
||||
- Optional decompression for brotli/zstd if the modules are installed.
|
||||
|
||||
## Limitations
|
||||
- TLC container decoding is not included. You can pass a decoder to
|
||||
`PatchReader`/`SignatureReader` to parse the raw container bytes.
|
||||
|
||||
## Usage
|
||||
|
||||
Patch inspection:
|
||||
|
||||
```python
|
||||
from pwr import PatchReader
|
||||
|
||||
with PatchReader.open("update.pwr") as reader:
|
||||
for entry in reader.iter_file_entries():
|
||||
if entry.is_rsync():
|
||||
for op in entry.sync_ops:
|
||||
pass
|
||||
elif entry.is_bsdiff():
|
||||
for ctrl in entry.bsdiff_controls:
|
||||
pass
|
||||
```
|
||||
|
||||
Apply a patch (requires file index mappings):
|
||||
|
||||
```python
|
||||
from pwr import PatchReader, apply_patch
|
||||
|
||||
target_paths = [
|
||||
"old/file0.bin",
|
||||
"old/file1.bin",
|
||||
]
|
||||
|
||||
output_paths = [
|
||||
"new/file0.bin",
|
||||
"new/file1.bin",
|
||||
]
|
||||
|
||||
with PatchReader.open("update.pwr") as reader:
|
||||
apply_patch(reader, target_paths, output_paths)
|
||||
```
|
||||
|
||||
Apply to folders (uses embedded TLC container paths):
|
||||
|
||||
```python
|
||||
from pwr import apply_patch_to_folders
|
||||
|
||||
apply_patch_to_folders("update.pwr", "old_folder", "new_folder")
|
||||
```
|
||||
|
||||
Quick inspect:
|
||||
|
||||
```bash
|
||||
python py-pwr/main.py path/to/file.pwr
|
||||
```
|
||||
|
||||
Apply via CLI:
|
||||
|
||||
```bash
|
||||
python py-pwr/main.py apply update.pwr /path/to/old_folder /path/to/new_folder
|
||||
```
|
||||
Reference in New Issue
Block a user