Shortcuts

Source code for mmeval.fileio.handlers.base

# Copyright (c) OpenMMLab. All rights reserved.
from abc import ABCMeta, abstractmethod


[docs]class BaseFileHandler(metaclass=ABCMeta): """A base class for file handler.""" # `str_like` is a flag to indicate whether the type of file object is # str-like object or bytes-like object. Pickle only processes bytes-like # objects but json only processes str-like object. If it is str-like # object, `StringIO` will be used to process the buffer. str_like = True @abstractmethod def load_from_fileobj(self, file, **kwargs): pass def load_from_path(self, filepath, mode='r', **kwargs): with open(filepath, mode) as f: return self.load_from_fileobj(f, **kwargs)
Read the Docs v: latest
Versions
latest
stable
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.