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 arebytes.The
encryption_keycan be generated by theget_encryption_keyfunction.
- acd.write(data: dict, fp, encryption_key: bytes)#
Serialises
data(a dictionary where the keys are strings and values arebytesorbytearray``s) to ``fp(a.write()-supporting file-like object).The
encryption_keycan be generated by theget_encryption_keyfunction.
- acd.read_bytes(data: bytes, encryption_key: bytes) dict#
Deserialises
data(abytesorbytearrayinstance) to a dictionary where the keys are strings and values arebytes.The
encryption_keycan be generated by theget_encryption_keyfunction.
- acd.write_bytes(data: dict, encryption_key: bytes) bytes#
Serialises
data(a dictionary where the keys are strings and values arebytesorbytearray``s) to ``bytes.The
encryption_keycan be generated by theget_encryption_keyfunction.
- acd.read_file(file) dict#
Deserialises the contents of the
file(astror path-like object) to a dictionary where the keys are strings and values arebytes.
- acd.write_file(data: dict, file)#
Serialises
data(a dictionary where the keys are strings and values arebytesorbytearray``s) and writes the result to the ``file(astror path-like object).