File ClassΒΆ

class data_classes.fileClass.File(file_dir)

Bases: object

Define a class that holds general file properties.

This class represents a file by storing its directory and provides basic functionality to manage file-related properties.

file_dir

The directory of the file.

Type:

str

file_name

The name of the file. Initialized to an empty string.

Type:

str

datetime

The date and time the file was last modified, initialized in get_file_datetime().

Type:

datetime.datetime

__init__(file_dir)

Initialize a File object with the provided file directory.

get_file_datetime()

Get the date and time the file was last modified (assumed to be the drop date).

get_file_name()

Extract and store the file name from the directory path.

new_file_name(new_name)

Update the file name and rename the physical file on the file system.

get_file_datetime()

Get the date and time the file was last modified (assumed to be the drop date).

This method updates the datetime attribute with the last modification time of the file.

get_file_name()

Extract and store the file name from the directory path.

This method updates the file_name attribute with the base name of the file.

new_file_name(new_name)

Update the file name and physically rename the file on the file system.

Parameters:

new_name (str) – The new name for the file.

Raises:
  • FileNotFoundError – If the original file does not exist.

  • OSError – If renaming the file fails.