graviti.file.base#

Graviti basic file class.

Module Contents#

Classes#

FileBase

This class represents the file in a DataFrame.

File

This class represents local files.

RemoteFile

This class represents the file on Graviti platform.

class graviti.file.base.FileBase[source]#

Bases: graviti.utility.ReprMixin

This class represents the file in a DataFrame.

property key(self)[source]#

Get the key of the file.

Returns

The key of the file.

Return type

str

property extension(self)[source]#

Get the extension of the file.

Returns

The extension of the file.

Return type

str

property size(self)[source]#

Get the size of the file.

Returns

The size of the file.

Return type

int

abstract open(self)[source]#

Return the binary file pointer of this file.

Raises

NotImplementedError – The method of the base class should not be called.

Return type

Union[graviti.utility.UserResponse, _io.BufferedReader]

class graviti.file.base.File(path)[source]#

Bases: FileBase

This class represents local files.

Parameters

path (graviti.utility.PathLike) – The local path of the file.

property path(self)[source]#

Get the path of the file.

Returns

The path of the file.

Return type

pathlib.Path

property key(self)[source]#

Get the key of the file.

Returns

The key of the file.

Return type

str

property extension(self)[source]#

Get the extension of the file.

Returns

The extension of the file.

Return type

str

property size(self)[source]#

Get the size of the file.

Returns

The size of the file.

Return type

int

get_checksum(self)[source]#

Get the sha1 checksum of the local file.

Returns

The sha1 checksum of the local file.

Return type

str

open(self)[source]#

Return the binary file pointer of this file.

Returns

The local file pointer.

Return type

_io.BufferedReader

class graviti.file.base.RemoteFile(key, extension, size, object_permission_manager)[source]#

Bases: FileBase

This class represents the file on Graviti platform.

Parameters
  • key (str) – The key of the file.

  • extension (str) – The extension of the file.

  • size (int) – The size of the file.

  • object_permission_manager (graviti.manager.ObjectPermissionManager) – The permission to access the file.

open(self)[source]#

Return the binary file pointer of this file.

Returns

The remote file pointer.

Return type

graviti.utility.UserResponse