garcia / simfile

A modern simfile parsing & editing library for Python 3
MIT License
62 stars 7 forks source link

Abstractions for simfile & pack directories and assets #19

Closed garcia closed 2 years ago

garcia commented 2 years ago

This PR introduces several new features for navigating simfile content on filesystems:

simfile.dir

A new dir module offers SimfileDirectory and SimfilePack classes for working with simfile & pack directories.

Navigating these directory structures is simple in theory, but writing filesystem code is error-prone and easy to get subtly wrong. My own unit tests caught multiple errors in my initial implementation!

simfile.assets

A new assets module handles loading simfile assets in a fashion that reproduces StepMania's behavior.

In particular, when an asset property (e.g. BANNER) is left blank, StepMania scans the simfile directory for images matching a few patterns. Each asset type has its own hardcoded set of patterns that you would never guess without reading StepMania's source code. Now you don't have to!

PyFilesystem2

PyFS has been added as a dependency & integrated throughout the library's filesystem interactions. Non-OS filesystems can be specified as an optional filesystem parameter everywhere the filesystem is used, including the dir module's classes and existing top-level functions like simfile.open. When no filesystem is provided, the library operates on the OS filesystem as before.

This enables e.g. loading simfiles from an archive file without having to either:

simfile.opendir, simfile.openpack

New top-level methods that return or yield Simfile objects. These effectively tuck away the dir module's functionality into an API analogous to simfile.open.

TODO