|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- # Copyright 2019 Huawei Technologies Co., Ltd
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- # ============================================================================
- """Base file system."""
- from abc import ABC, abstractmethod
- from collections import namedtuple
- StatInfo = namedtuple("Info", ["size", "mtime"])
-
-
- class BaseFileSystem(ABC):
- """Base class for file systems."""
-
- @abstractmethod
- def list_dir(self, path):
- """
- Abstract method for listing directories by path.
-
- Args:
- path (str): Directory path or file path.
- """
-
- @abstractmethod
- def is_dir(self, path):
- """
- Abstract method for determining if it is a directory.
-
- Args:
- path (str): Directory path or file path.
- """
-
- @abstractmethod
- def exists(self, path):
- """
- Abstract method for determining if it exists.
-
- Args:
- path (str): Directory path or file path.
- """
-
- @abstractmethod
- def file_stat(self, file_path):
- """
- Abstract method for getting file stat information.
-
- Args:
- file_path (str): File path.
- """
-
- @abstractmethod
- def join(self, path, *paths):
- """
- Abstract method for combining paths.
-
- Args:
- path (str): Directory path.
- *paths (str): Path or paths.
- """
|