Skip to content

loader

FreeBodyEngine.core.files.loader #

load_file(path, file_type=None) #

Loads path (or, for loaders that accept multiple files at once - e.g. TEXTURE_STACK_FILE's layered images - a tuple of paths) through the registered loaders table in core/files/init.py, and returns whatever that loader produces.

If file_type is given (one of the *_FILE constants), only that loader is tried, and it must both accept every path's extension and (when multiple paths are given) support multiple files - otherwise this returns ''. If file_type is omitted, every registered loader is tried in loaders' insertion order and the first one whose supported extensions match every path's extension (and, again, supports multiple files if more than one path was given) wins - loader order matters when two loaders claim the same extension (see the comment on loaders).

Also returns '' for an empty path tuple, for any path with no extension (or whose last . falls before its last path separator, e.g. a dotted directory name with no extension on the filename itself), or if nothing matches.