dsfp — Darsksouls Save File Parser

Note

Please note that this library not supported write routines and maybe won’t in further releases. Only data get procedures

Core module

class dsfp.dsfp.DSSaveFileParser(filename)[source]

Dark Souls save file parser original gist: https://gist.github.com/infuasto/8382836

Parameters:filename – bz2.BZ2File or StringIO instances
close()[source]

close all instances

get_active_slots_amount()[source]

get active slots count, could be 0 up to 9

Returns:active characters’ slots amount
Return type:int
>>> instance = DSSaveFileParser('saves/DRAKS0005.sl2')
>>> instance.get_active_slots_amount()
2 # means that only 2 active characters stored in save file
get_blocks_metadata(update=False)[source]

Get save file blocks metadata

Parameters:update (bool) – runs re-read blocks metadata process, if False returns back cached list
Returns:SlotHeaderStructure instances
Return type:list
get_items(slot=0)[source]

get character’s item list, don’t work proper for now

Parameters:slot – character save slot (0 up to 9)
Returns:list of dicts
get_stats()[source]

get character stats data

Returns:dicts
Return type:list
>>> ds = DSSaveFileParser('saves/DRAKS0005.sl2')
>>> ds.get_stats()[0]
{'attunement': 11, 'body': 0, 'class': 2, 'color': 7,
 'deaths': 155, 'dexterity': 21, 'earned': 4037210,
 'endurance': 54, 'face': 1, 'faith': 9, 'gift': 1, 'hairs': 5,
 'hp': 1100, 'hp2': 1100, 'hp_current': 1100, 'humanity': 2,
 'intelligence': 11, 'level': 115, 'male': True,
 'name': u'\u041a\u0430\u0440\u043b', 'resistance': 12,
 'souls': 39848, 'stamina': 160, 'stamina2': 160, 'stamina3': 160,
 'strength': 50, 'time': 218834, 'vitality': 30}]
read_slot_data(slot=0)[source]

read raw data of given slot

Parameters:slot (int) – character slot
Returns:character block bytes
Return type:str
class dsfp.dsfp.ItemStructure[source]

Character item storage structure

class dsfp.dsfp.MPlayerAccountStructure[source]

Multi player account structure data store

class dsfp.dsfp.SlotDataHeaderStructure[source]

Character Slot Data possible container

class dsfp.dsfp.SlotHeaderStructure[source]

Characters containers slots header structure

Utils module

DSFP utils for some routines

dsfp.utils.get_structure_fmt(structure_class)[source]

get structure format for further struct extraction

Parameters:structure_classctypes Structure instances
Returns:tuple of (format_string, block_size)
>>> class SomeStructure(Structure):
    _fields_ = [
        ('data', c_ulong), # 8 bytes
        ('amount', c_uint32) # 4 bytes
    ]
>>> get_structure_fmt(SomeStructure)
('QI', 12)

Exceptions

DSFP utils for some routines

exception dsfp.exceptions.FileTypeException(*args)[source]

not a DarkSouls save file exception

exception dsfp.exceptions.ImproperlyConfigured(*args)[source]

Improperly configured exception