elmadev / elma-python

Elma Python Library
https://elma-python-library.readthedocs.org
MIT License
13 stars 2 forks source link

More convenient API for saving and loading files #22

Closed tiinanen closed 3 years ago

tiinanen commented 4 years ago

The current way of saving/loading files is a bit cumbersome:

from elma.packing import unpack_level

with open('mylevel.lev', 'rb') as f:
    level = unpack_level(f.read())

I would rather like to use API such as

from elma import Level
level = Level('mylevel.lev')

or maybe

from elma import Level
level = Level.load('mylevel.lev')

Currently implementing this would require some refactoring, since packing.py imports models such as Level and Replay, so it would create a circular dependency, if you tried to import packing to be used in the models.

Perhaps it would make sense to just move the packing code to the Level and Replay classes instead?

sigvef commented 4 years ago

Something like Level.load(..) would be a nice addition!

tiinanen commented 3 years ago

This has been implemented in #30