module filehelper.transfer_api

Inheritance diagram of pyquickhelper.filehelper.transfer_api

Short summary

module pyquickhelper.filehelper.transfer_api

API to move files

source on GitHub

Classes

class

truncated documentation

MockTransferAPI

Class used for unit test purposes, simple key, value storage.

TransferAPI

Defines an API to transfer files over a remote location.

TransferAPI_FileInfo

Keeps tracks of transferred files.

Static Methods

staticmethod

truncated documentation

bytes2mapping

Deserializes a mapping.

bytes2mapping

Deserializes a mapping.

checksum_md5

Computes MD5 for a file.

checksum_md5

Computes MD5 for a file.

mapping2bytes

Serializes a mapping.

mapping2bytes

Serializes a mapping.

read_json

Retrieves information from a json string.

Methods

method

truncated documentation

__init__

__init__

__init__

Information about a transferred file.

__str__

usual

add_piece

Adds a piece.

get_remote_path

Produces a remote path.

get_remote_path

Produces a remote path.

retrieve

Retrieves data from path.

retrieve

Retrieves data from path.

retrieve_mapping

Returns the mapping.

retrieve_mapping

Returns the mapping.

to_json

Serializes this class info JSON.

transfer

It assumes a data holds in memory, tansfer data to path.

transfer

It assumes a data holds in memory, tansfer data to path.

transfer_mapping

Transfers the mapping.

transfer_mapping

Transfers the mapping.

Documentation

API to move files

source on GitHub

class pyquickhelper.filehelper.transfer_api.MockTransferAPI(fLOG=<function noLOG>)[source]

Bases: TransferAPI

Class used for unit test purposes, simple key, value storage.

source on GitHub

Parameters:

fLOG – logging function

source on GitHub

__init__(fLOG=<function noLOG>)[source]
Parameters:

fLOG – logging function

source on GitHub

retrieve(path, exc=True)[source]

Retrieves data from path.

Parameters:
  • path – remove location

  • exc – keep exception

Returns:

data

source on GitHub

transfer(path, data)[source]

It assumes a data holds in memory, tansfer data to path.

Parameters:
  • data – bytes

  • path – path to remove location

Returns:

boolean

source on GitHub

class pyquickhelper.filehelper.transfer_api.TransferAPI(fLOG=<function noLOG>)[source]

Bases: object

Defines an API to transfer files over a remote location.

source on GitHub

Parameters:

fLOG – logging function

source on GitHub

__init__(fLOG=<function noLOG>)[source]
Parameters:

fLOG – logging function

source on GitHub

static bytes2mapping(byt)[source]

Deserializes a mapping.

Parameters:

byt – bytes

Returns:

dictionary { str, TransferAPI_FileInfo }

source on GitHub

static checksum_md5(data)[source]

Computes MD5 for a file.

Parameters:

data – some data

Returns:

string

source on GitHub

get_remote_path(data, name, piece=0)[source]

Produces a remote path.

Parameters:
  • data – binary data to transfer (to be hashed)

  • name – local name

  • piece – pieces

Returns:

remote path

~ hash of everything

source on GitHub

static mapping2bytes(mapping)[source]

Serializes a mapping.

Parameters:

mapping – dictionary { str, TransferAPI_FileInfo }

Returns:

bytes

source on GitHub

retrieve(path, exc=True)[source]

Retrieves data from path.

Parameters:
  • path – remove location

  • exc – keep exception

Returns:

data

source on GitHub

retrieve_mapping(decrypt)[source]

Returns the mapping.

Parameters:

decrypt – decrypt function

Returns:

list of key,value pair

source on GitHub

transfer(path, data)[source]

It assumes a data holds in memory, tansfer data to path.

Parameters:
  • data – bytes

  • path – path to remove location

Returns:

boolean

source on GitHub

transfer_mapping(mapping, encrypt, filename=None)[source]

Transfers the mapping.

Parameters:
  • mapping – mapping

  • encrypt – encryption function

  • filename – local filename

Returns:

boolean

source on GitHub

class pyquickhelper.filehelper.transfer_api.TransferAPI_FileInfo(name, pieces, last_update)[source]

Bases: object

Keeps tracks of transferred files.

source on GitHub

Information about a transferred file.

Parameters:
  • name – name of the file

  • pieces – list of pieces contributing to the file

  • last_update – last_update

source on GitHub

__init__(name, pieces, last_update)[source]

Information about a transferred file.

Parameters:
  • name – name of the file

  • pieces – list of pieces contributing to the file

  • last_update – last_update

source on GitHub

__str__()[source]

usual

source on GitHub

add_piece(piece)[source]

Adds a piece.

Parameters:

piece – add piece

source on GitHub

static read_json(s)[source]

Retrieves information from a json string.

source on GitHub

to_json()[source]

Serializes this class info JSON.

source on GitHub