friendlypics.file_object module¶
-
class
friendlypics.file_object.
FileObj
(path)[source]¶ Bases:
object
Abstraction around an arbitrary disk-based file
This interface provides common functions used by our image processing scripts for interacting with files of various types, typically containing raster image data
- Args:
path (str): path to the file to manage
-
checksum
¶ str: sha checksum of the file
-
convert_progressive
()[source]¶ Helper method that converts a progressive encoded JPEG to a non- progressive format
-
copy_to
(target_dir)[source]¶ Copies this file to a secondary location
- NOTE:
This FileObj instance will still point to the original file as it existed before the copy.
- Args:
target_dir (str): path to the folder to copy the file to
- Returns:
FileObj: reference to a new file object describing the copied file
-
creation_date
¶ datetime.datetime: date the file was created
-
delete
()[source]¶ deletes this file from disk
- NOTE:
This FileObj instance will still point to the original file as it existed before the deletion, therefore calling this method effectively invalidates this instance of the class. No further operations should be made against this instance after calling this method.
-
filename
¶ str: the file name without preceding path characters
-
is_image
¶ bool: checks to see if this file is a known image file format
-
move_to
(target_dir)[source]¶ Moves this file to a secondary location
This can be faster for large files that are stored on the same disk or file system since the data can remain at rest and simply the file allocation table gets updated
- NOTE:
This FileObj instance will still point to the original file as it existed before the move, therefore calling this method effectively invalidates this instance of the class. No further operations should be made against this instance after calling this method.
- Args:
target_dir (str): path to the folder to move the file to
- Returns:
FileObj: reference to a new file object describing the moved file
-
path
¶ str: absolute path to the file managed by this object