Entity Data Format (EDF) parser and serializer
Project description
EDF Parser
Entity Data Format (EDF) parser and serializer.
Installation
pip install entity_data_format
Usage
Loading
Load from file
import entity_data_format as edf
with open('path/to/file.edf', 'r', encoding='utf-8') as fp:
data = edf.load(fp)
Load from string
import entity_data_format as edf
data_str = '''
[entity = player]
speed = 10.0
inventory = sword shield
'''
data = edf.loads(data_str)
# Incremental loading into existing dictionary
extra_str = '[entity = enemy]\nspeed = 5'
edf.loads(extra_str, data=data)
Load all entities (merging)
import entity_data_format as edf
# Recursively load all .edf files and merge them
# Files are processed in alphabetical order
data = edf.load_all_entities('assets/**/*.edf')
Serialization
Dump to file
import entity_data_format as edf
data = {
'car': {
'car1': {'speed': 100, 'acceleration': 1.0}
}
}
with open('output.edf', 'w', encoding='utf-8') as fp:
edf.dump(data, fp)
Dump to string
import entity_data_format as edf
data = {
'weapon': {
'sword': {'damage': 15, 'weight': 2.5}
}
}
s = edf.dumps(data)
Data Types
EDF is primarily string-based, but serialize_value handles several Python types:
- bool:
True->1,False->0 - float: Formatted using
%f - list / tuple: Space-separated values. Spaces within elements are replaced by
_. - other: Converted to
str()
Note: All values are returned as strings when loading.
Modding support (merging entities)
cars.edf:
[car = car1]
speed = 100
acceleration = 1.0
[car = car2]
speed = 80
acceleration = 1.2
cars_mod.edf:
[car = car1]
speed = 120
import entity_data_format as edf
# Files are loaded in alphabetical order, so cars_mod.edf will overwrite values from cars.edf
data = edf.load_all_entities('*.edf')
# data['car']['car1']['speed'] == '120'
# data['car']['car1']['acceleration'] == '1.0'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file entity_data_format-1.0.0.tar.gz.
File metadata
- Download URL: entity_data_format-1.0.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae3e20a18aebba527f8d4a391803b1e3f951a0b7c36752798c52aba2c8d42469
|
|
| MD5 |
efaddbb6f8669f7953f008a080b88732
|
|
| BLAKE2b-256 |
981ce874ec003309419f28bf0e6970c4f418f366cdb24ccd3e8c739f87121c2d
|
File details
Details for the file entity_data_format-1.0.0-py3-none-any.whl.
File metadata
- Download URL: entity_data_format-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42dc09e93276ed0a839363f567cf3a3917842a96444335acbe4a80aa165f95ec
|
|
| MD5 |
737b049cf8d872e3bb4473a94eb82299
|
|
| BLAKE2b-256 |
c6b596587dcf43b4f2dcf3f8f76cef218213c2ab2bf8bf1ff1a9864e18baea01
|