Skip to main content

asar

Library for working with Electron's ASAR archive files.

PyPI - Version PyPI - Python Version

Installation

pip install asar

Usage

  • pack and extract asar.
    from pathlib import Path
    from asar import create_archive, extract_archive
    
    create_archive(Path("src"), Path("app.asar"))
    extract_archive(Path("app.asar"), Path("dst"))
    
  • with unpack expression
    create_archive(Path("src"), Path("app.asar"), unpack="*.exe")
    
    then we got:
    .
    ├── app.asar
    └── app.asar.unpacked
        └── f2.exe
    
  • list files of asar
    from pathlib import Path
    from asar import AsarArchive
    
    with AsarArchive(Path("app.asar"), mode="r") as archive:
        print(archive.list())
    
    then we got:
    [Path('assets'), Path('assets/icon.png'), ...]
    
  • read one file from asar by random access
    from pathlib import Path
    from asar import AsarArchive
    
    with AsarArchive(Path("app.asar"), mode="r") as archive:
        print(archive.read(Path("f1.txt"), follow_link=True))
    
    then we got:
    b'Hello, Asar'
    
  • create an asar from another asar, without extracting to filesystem.
    import io 
    from pathlib import Path
    from asar import AsarArchive
    
    with AsarArchive(Path("app.asar"), mode="r") as reader, AsarArchive(Path("app.new.asar"), "w") as writer:
        writer.pack_other_asar(reader)
        writer.pack_file(path_in=Path("assets/added1.txt"), file_path=Path("added.txt"))
        writer.pack_stream(path_in=Path("assets/added2.txt"), file_reader=io.BytesIO(b"some text"))
    
    then we got app.new.asar, extract it:
    app_new_asar_extract
            ├── assets
            │     ├── added1.txt
            │     ├── added2.txt
            │     └── ... other files from app.asar 
            └── ... other files from app.asar
    

Metadata

Release files for asar 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asar 0.1.3
File Size Uploaded
asar-0.1.3.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asar 0.1.3
File Interpreter ABI Platform
asar-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 18.6 kB

Release files / asar-0.1.3.tar.gz

Download URL asar-0.1.3.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1acf1ff02bf1422e768696fbaeb35672b5801ee066f78fdee4edfeaa65215ea1
BLAKE2b-256 checksum
How to use checksums
669dce3ae33175999332a0ab70f819761c09223c344c8c73076e32758db9a754
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / asar-0.1.3-py3-none-any.whl

Download URL asar-0.1.3-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63aec0413baa681aa69a99cb0a10c518c98b6ad6bc51c47557c54134d2149ed8
BLAKE2b-256 checksum
How to use checksums
f385ba4449fce9b06eba0ee3e64ee08c9808b9e783fae846e50c380faa74e12d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page