philippkosarev/acd.py

acd.py#

Python module for reading and writing Assetto Corsa Data (.acd) files.

Installation#

The project is available on PyPI and can be installed using pip:

pip install acd.py

Examples#

Here is a simple example that reads a .acd file and prints the contents of the first file in it:

import acd
data = acd.read_file('./data.acd')
keys = list(data.keys())
first_key = keys[0]
print(data[first_key])

Here is another example that writes a pre-defined dictionary to a .acd file:

import acd
data = {
  'example-filename.txt': 'Hello from the example-filename.txt!',
}
acd.write_file(data, './data.acd')

API#

acd.get_encryption_key(file, /) → bytes#

Generates an encryption key from a string or path-like object.

acd.read(fp, encryption_key: bytes) → dict#

Deserialises fp (a .read()-supporting file-like object) to a dictionary where the keys are strings and values are bytes.

The encryption_key can be generated by the get_encryption_key function.

acd.write(data: dict, fp, encryption_key: bytes)#

Serialises data (a dictionary where the keys are strings and values are bytes or bytearray``s) to ``fp (a .write()-supporting file-like object).

The encryption_key can be generated by the get_encryption_key function.

acd.read_bytes(data: bytes, encryption_key: bytes) → dict#

Deserialises data (a bytes or bytearray instance) to a dictionary where the keys are strings and values are bytes.

The encryption_key can be generated by the get_encryption_key function.

acd.write_bytes(data: dict, encryption_key: bytes) → bytes#

Serialises data (a dictionary where the keys are strings and values are bytes or bytearray``s) to ``bytes.

The encryption_key can be generated by the get_encryption_key function.

acd.read_file(file) → dict#

Deserialises the contents of the file (a str or path-like object) to a dictionary where the keys are strings and values are bytes.

acd.write_file(data: dict, file)#

Serialises data (a dictionary where the keys are strings and values are bytes or bytearray``s) and writes the result to the ``file (a str or path-like object).