philippkosarev/acd

acd#

A Python library and CLI for reading and writing Assetto Corsa Data (.acd) files.

Installation#

To install the in-development version you can run the following:

pip install git+https://github.com/philippkosarev/acd.git

Note

A stable version should be coming soon.

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_for_string(string: str) str#

Generates the encryption key using the given string.

To get the right encryption key for a given file, use its basename as as the string, unless it starts with “data” (case-insensitive).

If the file’s basename does start with “data”, then the basename of the directory that the file is in should be used.

acd.get_encryption_key_for_file(file) str#

Generates the encryption key for the given file (a str or path-like object).

acd.read(fp, encryption_key: str) dict#

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

The encryption_key can be obtained using either get_encryption_key_for_string or get_encryption_key_for_file.

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

Serialises data (a dictionary where all the keys and values are strings) to fp (a .write()-supporting file-like object).

The encryption_key can be obtained using either get_encryption_key_for_string or get_encryption_key_for_file.

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

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

The encryption_key can be obtained using either get_encryption_key_for_string or get_encryption_key_for_file.

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

Serialises data (a dictionary where all the keys and values are strings) to bytes.

The encryption_key can be obtained using either get_encryption_key_for_string or get_encryption_key_for_file.

acd.read_file(file) dict#

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

acd.write_file(data: dict, file)#

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