Base๏ƒ

Inheritance diagram of musify.file.base

Generic base classes and functions for file operations.

Classes:

File()

Generic class for representing a file on a system.

class musify.file.base.File๏ƒ

Bases: Hashable

Generic class for representing a file on a system.

Attributes:

valid_extensions

Extensions of files that can be loaded by this class.

path

The path to the file.

folder

The parent folder of the file.

filename

The filename without extension.

ext

The file extension in lowercase.

size

The size of the file in bytes

date_created

datetime object representing when the file was created

date_modified

datetime object representing when the file was last modified

Methods:

get_filepaths(folder)

Get all files in a given folder that match this File object's valid filetypes recursively.

load(*args,ย **kwargs)

Load the file to this object

save([dry_run])

Save this object to file.

valid_extensions: frozenset[str]๏ƒ

Extensions of files that can be loaded by this class.

abstract property path: str๏ƒ

The path to the file.

property folder: str๏ƒ

The parent folder of the file.

property filename: str๏ƒ

The filename without extension.

property ext: str๏ƒ

The file extension in lowercase.

property size: int | None๏ƒ

The size of the file in bytes

property date_created: datetime | None๏ƒ

datetime object representing when the file was created

property date_modified: datetime | None๏ƒ

datetime object representing when the file was last modified

classmethod get_filepaths(folder)๏ƒ

Get all files in a given folder that match this File objectโ€™s valid filetypes recursively.

Return type:

set[str]

abstract load(*args, **kwargs)๏ƒ

Load the file to this object

Return type:

Any

abstract save(dry_run=True, *args, **kwargs)๏ƒ

Save this object to file.

Parameters:

dry_run (bool (default: True)) โ€“ Run function, but do not modify the file on the disk.

Return type:

Any