Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
    

About

Python library for working with Electron's ASAR archive files

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages