Files Reference

For dealing with files in general.

File

class pykemo.files.files.File(name, path, content_type=None, url_source=UrlType.DATA, server=3)

A normal file. It may very well be text or a binary type.

Parameters:
  • name (PathLike)

  • path (PathLike)

  • content_type (str | None)

  • url_source (UrlType)

  • server (int)

property content_type: str | None
Returns:

The MIME type of the file content. Might be None if not downloaded yet.

Return type:

Optional[str]

property name: PathLike
Returns:

The name of the file (with extension).

Return type:

PathLike

async save(path='', *, force=True, verbose=False, show_order=1, chunk_size=4096)

Tries to save the file to a given path.

Parameters:
  • path (PathLike | Path) – The path in which to save the file.

  • force (bool) – If another file is found, overwrite it.

  • verbose (bool) – Wether to track progress.

  • show_order (int) – If verbose==True, then this defines in which order the progress bar is showed., defaults to 1.

  • chunk_size (int) – The size (in bytes) of the chunks to download at a time (usually a power of 2).

Returns:

Wether or not the download was successful.

Return type:

bool

property url: UrlLike
Returns:

The full URL of the file, where it’s downloaded from.

Return type:

UrlLike

with_session(ks)

Quietly sets the session which the post uses for its requests.

Parameters:

ks (KemoSession) – The session instance.

Returns:

The same instance of the file, for convenience.

Return type:

File