pyiqa.utils.file_client ======================= .. py:module:: pyiqa.utils.file_client Module Contents --------------- .. py:class:: BaseStorageBackend Abstract class of storage backends. All backends need to implement two apis: ``get()`` and ``get_text()``. ``get()`` reads the file as a byte stream and ``get_text()`` reads the file as texts. .. py:method:: get(filepath) :abstractmethod: .. py:method:: get_text(filepath) :abstractmethod: .. py:class:: MemcachedBackend(server_list_cfg, client_cfg, sys_path=None) Bases: :py:obj:`BaseStorageBackend` Memcached storage backend. .. attribute:: server_list_cfg Config file for memcached server list. :type: str .. attribute:: client_cfg Config file for memcached client. :type: str .. attribute:: sys_path Additional path to be appended to `sys.path`. Default: None. :type: str | None .. py:method:: get(filepath) .. py:method:: get_text(filepath) :abstractmethod: .. py:class:: HardDiskBackend Bases: :py:obj:`BaseStorageBackend` Raw hard disks storage backend. .. py:method:: get(filepath) .. py:method:: get_text(filepath) .. py:class:: LmdbBackend(db_paths, client_keys='default', readonly=True, lock=False, readahead=False, **kwargs) Bases: :py:obj:`BaseStorageBackend` Lmdb storage backend. :param db_paths: Lmdb database paths. :type db_paths: str | list[str] :param client_keys: Lmdb client keys. Default: 'default'. :type client_keys: str | list[str] :param readonly: Lmdb environment parameter. If True, disallow any write operations. Default: True. :type readonly: bool, optional :param lock: Lmdb environment parameter. If False, when concurrent access occurs, do not lock the database. Default: False. :type lock: bool, optional :param readahead: Lmdb environment parameter. If False, disable the OS filesystem readahead mechanism, which may improve random read performance when a database is larger than RAM. Default: False. :type readahead: bool, optional .. attribute:: db_paths Lmdb database path. :type: list .. attribute:: _client A list of several lmdb envs. :type: list .. py:method:: get(filepath, client_key) Get values according to the filepath from one lmdb named client_key. :param filepath (str | obj: `Path`): Here, filepath is the lmdb key. :param client_key: Used for distinguishing different lmdb envs. :type client_key: str .. py:method:: get_text(filepath) :abstractmethod: .. py:class:: FileClient(backend='disk', **kwargs) Bases: :py:obj:`object` A general file client to access files in different backend. The client loads a file or text in a specified backend from its path and return it as a binary file. it can also register other backend accessor with a given name and backend class. .. attribute:: backend The storage backend type. Options are "disk", "memcached" and "lmdb". :type: str .. attribute:: client The backend object. :type: :obj:`BaseStorageBackend` .. py:method:: get(filepath, client_key='default') .. py:method:: get_text(filepath)