hohav / py-slippi

Python library for parsing SSBM replay files
MIT License
56 stars 25 forks source link

Support construction of Game objects from PathLike objects in addition to str and streams. #25

Closed Kered13 closed 3 years ago

Kered13 commented 3 years ago

The ability to construct a Game object from a PathLike object was broken when event driven parsing was introduced.

The new parsing logic checks if the input is a str in the parse() function, and if so treats it as a path and opens it. Otherwise, the input is treated as a stream. This breaks the ability to support any representation of a path other than a str. This is a problem because paths are frequently manipulated using the built-in PathLib library.

A simple solution would be to add a check for isinstance(input, os.PathLike) in addition to str in the parse() function. A more sophisticated solution might try to check the attributes of input to determine if it is path-like or stream-like.

hohav commented 3 years ago

Thanks for the report. Should be fixed by c642857, but please re-open if the fix doesn't work for you.