Skip to main content

Python library to parse Catalog Asset Archives (CAR) of iOS Apps.

Project description

libCAR

Python library to parse Catalog Asset Archives (CAR) of iOS Apps.

this is a work in progress

Installation

Currently, this project does not have a PyPi installation candidate, so you have to clone the repository and run:

pip install .

Basic Usage

Info: All structures defined in python scripts are easy to understand as there are only field definitions (all classes are dataclasses).

BOM (Build of Materials)

As Catalog Asset Archvies are special BOM (Build Of Materials) files, this project also provides a parser for that file format. You can use the BOM class for almost all operations:

import io
from libcar import BOM

# Either load all bytes and use an in-memory buffer or
# operate in a 'with' statement.
with open("Assets.car", "rb") as fp:
    data = fp.read()

# Create the BOM instance (loads some details automatically)
bom = BOM(io.BytesIO(data))

header = bom.header # get bom-header
variables = bom.variables # get all variables
indexes = bom.indexes # list all indexes (warning: commonly a huge list)

index = bom.index_of("VARIABLE_NAME") # Get index by name
tree = bom.get_tree(index) or bom.tree_of("VARIABLE_NAME")

# Iterate over all tree elements (key, value)
for key, value in bom.iter_tree(tree):
    # key and value will be raw bytes
    ...

CAR (Catalog Asset Archive)

The creation of CAR objects may be handled easier compared to BOM objects as the class defines special parsing methods:

from libcar import CAR

# PArse CAR directly from file stream
car = CAR.parse_file("Assets.car")

header = car.header # get CAR header information
meta = car.metadata # get CAR extended metadata information
key_format = car.key_format # get key format of renditions

for name, facet in car.facets:
    # name will be string and facet CARFacetValue
    ...

# list all appearance keys (if present)
appearance_keys = dict(car.appearance_keys)

# get and parse all stored renditions:
for attributes, rendition in car.iter_renditions(key_format):
    # NOTE: it is recommended to NOT use print(randition) here as the object
    # will store all of its raw data as a blob, which then would be printed
    ...

CAR Scripts

CAR-Extract

Use the script car_extract.py to extract all raw data structures (some images will be ignored). Note that themes and colors won't be extracted.

CAR-Dump

The script car_dump.py offers a convienient way to inspect *.car files using the CLI. An example of a dumped rendition:

python3 car_dump.py Assets.car -T RENDITIONS:4,5

> RENDITIONS:
    - Key: '<00000000 00000001 00000000 00009703 00000055 0000002A>'
        - magic: ISTC
        - version: 1
        - flags: 4
        - width: 0
        - height: 0
        - scale_factor: 0
        - pixel_format: PDF
        - color_space_id: 0
        - reserved_1: '\x00\x00\x00'
        - modification_date: 0
        - layout: <Layout.vector: 9>
        - reserved_2: 0
        - name: 'Arrow Clockwise.pdf'
        - info_len: 28
        - bitmap_count: 1
        - reserved_3: 0
        - payload_size: 3882
        - data:
            - headers:
                [0] => <class 'libcar.rendition.CARRenditionInfoHeader'>
                    - magic: <Magic.composition: 1004>
                    - length: 8
                    - content:
                        - blend_mode: 0
                        - opacity: 1.0
                [1] => <class 'libcar.rendition.CARRenditionInfoHeader'>
                    - magic: <Magic.bitmap_info: 1006>
                    - length: 4
                    - content:
                        - exif_orientation: 1
            - value:
                - magic: DWAR
                - compressed: 0
                - length: 3870
                - data: b"..."

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

libCAR-1.0.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

libCAR-1.0.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file libCAR-1.0.0.tar.gz.

File metadata

  • Download URL: libCAR-1.0.0.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for libCAR-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3fe442b557a4e742cfd722f102a166abc12eac76e7fcd14ff32167e12a73d1db
MD5 5652dd53f49d3635a498d215624e63e7
BLAKE2b-256 b461ad3771e8236d64baacd561bd33655ca8e65cc390672c3f5e24b2738b4ff8

See more details on using hashes here.

File details

Details for the file libCAR-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: libCAR-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for libCAR-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce4a55f954b438cc364c74633d1d123ce7d4eda6dd23bf4bbb2661230494e85d
MD5 ec0ee413b378ac251334c18165bec053
BLAKE2b-256 8a96dcaa6ce002144a7752512201b6ee39770d7c172bcdb63e2b2543a573c545

See more details on using hashes here.

Supported by

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