File systems#

class gordo_core.file_systems.base.FileInfo(file_type: FileType, size: int, access_time: datetime | None = None, modify_time: datetime | None = None, create_time: datetime | None = None)[source]#

Bases: object

File/directory information.

access_time: datetime | None = None#

Time of last access.

create_time: datetime | None = None#

Time of creation.

file_type: FileType#
isdir() bool[source]#
isfile() bool[source]#
modify_time: datetime | None = None#

Time of last modification.

size: int#

Size of the file.

class gordo_core.file_systems.base.FileSystem[source]#

Bases: object

An interface for file system implementations.

abstract exists(path: str) bool[source]#

Tests whether a path exists.

abstract info(path: str) FileInfo[source]#

Retrieves FileInfo of a path.

abstract isdir(path: str) bool[source]#

Returns true if path refers to an existing directory.

abstract isfile(path: str) bool[source]#

Tests whether a path is a regular file.

join(*p) str[source]#

Join two or more pathname components, specific for this file system.

Parameters:

p – Path components list.

abstract ls(path: str, with_info: bool = True) Iterable[Tuple[str, FileInfo | None]][source]#

Returns a list containing the names of the files in the directory.

Parameters:
  • path – Directory path.

  • with_info – Retrieves FileInfo for each item. Otherwise, will be None for all items.

abstract property name: str#

S3://mybucket/home

Type:

Unique name for this file system. Example

abstract open(path: str, mode: str = 'r') IO[source]#

Open a file. open() analog for this file system.

Parameters:
  • path – Path to the file

  • mode – Required support at least of r,`b` modes

split(p: str) Tuple[str, str][source]#

Split a pathname.

abstract walk(base_path: str, with_info: bool = True) Iterable[Tuple[str, FileInfo | None]][source]#

Directory tree recursive iterator.

Parameters:
  • base_path – Directory path.

  • with_infols with_info argument analog.

Return type:

The first item of tuple is a path directory tree item, the second is FileInfo if with_info=True

class gordo_core.file_systems.base.FileType(value)[source]#

Bases: Enum

Type of file system item.

DIRECTORY = 1#
FILE = 2#
gordo_core.file_systems.base.default_join(*p) str[source]#