Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dylanljones/asarlib
Electron ASAR archive lib for Python
https://github.com/dylanljones/asarlib
Last synced: 16 days ago
JSON representation
Electron ASAR archive lib for Python
- Host: GitHub
- URL: https://github.com/dylanljones/asarlib
- Owner: dylanljones
- License: mit
- Created: 2022-10-28T14:48:45.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-05T21:15:34.000Z (3 months ago)
- Last Synced: 2024-10-07T10:08:16.386Z (about 1 month ago)
- Language: Python
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python ASAR
Python Electron Asar archive parser
See [electron/asar](https://github.com/electron/asar) for more information about the ASAR file format
## Installation
````commandline
pip install git+https://github.com/dylanljones/asarlib.git@VERSION
````
where ``VERSION`` is a release, tag or branch name.## Usage
So far only reading Asar archives is supported. An archive can be opened like
any other file in Python:
````python
from asarlib import AsarFileasar = AsarFile("path/to/file.asar")
...
asar.close()
````The file can also be opened using a context manager:
````python
with AsarFile("path/to/file.asar") as asar:
...
````The structure of the Asar archive can be printed as a tree:
````python
>>> asar.treestr()
AsarFile
├─ file1.txt
├─ file2.txt
├─ folder
│ ├─ file.txt
...
````The data of a file in the Asar archive can be read via
````python
data = asar.read_file("folder/file.txt")
````Any file in the archive can be extracted to a specified directory:
````python
asar.extract_file("folder/file.txt", dst="asar_contents")
````Additionally, the whole archive or a directory in it can be extracted:
````python
asar.extract(dst="asar_contents")
asar.extract("folder", dst="asar_contents")
````