Skip to main content

Library for working with Electron's ASAR archive files

Project description

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
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asar-0.1.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asar-0.1.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file asar-0.1.2.tar.gz.

File metadata

  • Download URL: asar-0.1.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for asar-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d30f39605ad8b81819c4cd38f22cc8cbdbf90a55fcd656b3dd42fe3605c1bfd4
MD5 80710b4abd59359d455cdc2e9524b780
BLAKE2b-256 b30c96ac68808a4a9a670c830aafc933b19c07c556d389a357a7e34ffb340353

See more details on using hashes here.

File details

Details for the file asar-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: asar-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for asar-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 614db63b5bc1fb39b16fe2dca4dd08ac023a32d7516453fbcdc901a31f7b9d9e
MD5 817e77c5d888bd4171c769aa2a3990fb
BLAKE2b-256 e0810448bea943764286643f29f2f37acc7ee9c4c8f3dfea3c8f8b2785697d28

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page