OreSat File Cache

class olaf.OreSatFileCache(dir_path: str)[source]

File cache for OreSat files (by use of OresatFile). Thread safe.

Parameters:

dir_path (str) – Directory to use as a OreSat file cache. Directory will be made if it does not exist.

add(file_path: str, consume: bool = False)[source]

Add file to cache

Parameters:
  • file_path (str) – Path to the file to add to the cache

  • consume (bool) – Flag to consume the file when added to the cache

Raises:

FileNotFoundErrorfile_path was not a valid file path

remove(file_name: str)[source]

Remove a file from cache

Parameters:

file_name (str) – Name of the file to remove from the cache

peek() str[source]

Get the oldest file name

Returns:

Name of the oldest file or an empty string if the cache is empty.

Return type:

str

pop(dir_path: str, copy: bool = False) str[source]

Pop the oldest file from the cache

Parameters:
  • dir_path (str) – Name of the directory to move the file to.

  • copy (bool) – When True the file is copied from the cache, when False the file is moved out of the cache.

Returns:

File path of the file now in dir_path or an empty string if the cache is empty.

Return type:

str

get(file_name: str, dir_path: str, copy: bool = False) str[source]

Get the file from the cache and move it a specific directory.

Parameters:
  • file_name (str) – Name of the file to get from the cache

  • dir_path (str) – Name of the directory to move the file to.

  • copy (bool) – When True the file is copied from the cache, when False the file is moved out of the cache.

Raises:

FileNotFoundErrorfile_name was not in cache

Returns:

File path of the file now in dir_path or an empty string if the cache is empty.

Return type:

str

files(keyword: str = '') list[OreSatFile][source]

Return a list of files in the cache.

Parameters:

keyword (str) – A keyword to filter by

Returns:

list of OreSatFile that are in the cache.

Return type:

list

clear()[source]

Clear all file in the cache

property dir: str

Gets the directory path the cache using.

Type:

str