BaseFinder

class gdt.core.heasarc.BaseFinder(*args, protocol='HTTPS', **kwargs)[source]

Bases: AbstractContextManager, ABC

A base class for the interface to the HEASARC archive.

Note

This class should not be directly instantiated, but rather inherited. The inherited class should define a method called _construct_path() that accepts *args, which are the user-defined parameters required to define the data path, and the method should return the data path as a string

Parameters:
  • args – The set of parameters needed to define the data path

  • protocol (str, optional) – The connection protocol. Default is HTTPS.

  • **kwargs – Options passed to Http class for HTTPS protocol and Ftp class for FTP protocol.

Attributes Summary

cwd

files

The list of files in the current directory

num_files

Number of files in the current directory

Methods Summary

cd(*args)

Change directory

filter(filetype, extension)

Filters the directory for the requested filetype and extension

get(download_dir, files[, verbose])

Downloads a list of files from the current FTP directory.

ls(*args[, fullpath])

List the contents of a directory

Attributes Documentation

cwd
files

The list of files in the current directory

Type:

(list of str)

num_files

Number of files in the current directory

Type:

(int)

Methods Documentation

cd(*args)[source]

Change directory

Parameters:

args (tuple) – The arguments needed to construct the remote path

filter(filetype, extension)[source]

Filters the directory for the requested filetype and extension

Parameters:
  • filetype (str) – The type of file, e.g. ‘cspec’

  • extension (str) – The file extension, e.g. ‘.pha’

Returns:

(list)

get(download_dir: Union[str, Path], files: List[str], verbose: bool = True) List[Path][source]

Downloads a list of files from the current FTP directory. This function also returns a list of the downloaded file paths.

Parameters:
  • download_dir (str, Path) – The download directory location

  • files (list of str) – The list of files to download

  • verbose (bool, optional) – If True, will output the download status. Default is True.

Returns:

(list)

ls(*args, fullpath: bool = False)[source]

List the contents of a directory

Parameters:
  • args (tuple) – The arguments needed to construct the remote path

  • fullpath (bool, optional) – If True, will list all files in the current with their full path.