def load(name, bare=False, options=None): name = str(name) node = None wantext = None if "." in name: a = name.split(".") if " " not in a[-1] and "/" not in a[-1]: wantext = a[-1] name = ".".join(a[:-1]) log.info("attempting to load beatmap %s", repr(name)) for ext, importer in muz.beatmap.formats.importersByInferExt.items(): if wantext is not None and ext != wantext: continue found = False paths = [] if name.startswith(vfs.VPATH_SEP) or name.startswith(os.path.sep): paths.append("%s.%s" % (name, ext)) else: for location in importer.locations: paths.append("%s/%s.%s" % (location, name, ext)) for path in paths: try: node = vfs.locate(path) except Exception: log.debug("couldn't load beatmap %s with the %s importer", repr(path), repr(importer.__name__), exc_info=True) else: log.info("loading beatmap %s (%s) with the %s importer", repr(name), repr(path), repr(importer.__name__)) found = True break if found: break if node is None: raise RuntimeError("No importer available for beatmap %s" % name) bm = importer.read(node.open(), node.name, bare=bare, options=options) if bm.vfsNode is None: bm.vfsNode = node if not bm.name: bm.name = name return bm
def musicVfsNode(self): if self._musicFile is not None: return vfs.Proxy(self._musicFile) root = vfs.root if self.vfsNode is not None: root = self.vfsNode.parent try: return muz.assets.music(self.music, root=root) except Exception: log.debug("musicVfsNode: locate failed", exc_info=True) if self.vfsNode is not None and self.vfsNode.realPathExists: return vfs.RealFile(os.path.join(os.path.dirname(self.vfsNode.realPath), self.music)).preferAlternative() raise RuntimeError("music file %s could not be located" % self.music)
def musicVfsNode(self): if self._musicFile is not None: return vfs.Proxy(self._musicFile) root = vfs.root if self.vfsNode is not None: root = self.vfsNode.parent try: return muz.assets.music(self.music, root=root) except Exception: log.debug("musicVfsNode: locate failed", exc_info=True) if self.vfsNode is not None and self.vfsNode.realPathExists: return vfs.RealFile( os.path.join(os.path.dirname(self.vfsNode.realPath), self.music)).preferAlternative() raise RuntimeError("music file %s could not be located" % self.music)