Http¶
- class gdt.core.heasarc.Http(url='https://heasarc.gsfc.nasa.gov/FTP/', start_key='<a href="', end_key='">', table_key='Parent Directory</a>', progress: Progress = None, context: SSLContext = None, timeout: float = 90.0)[source]¶
Bases:
BaseProtocolA class for HTTP/HTTPS interactions with a remote archive.
- Parameters:
url (str, optional) – The url of the HTTP/HTTPS archive
start_key (str, optional) – Key used to indentify the start of file names
end_key (str, optional) – Key used to indentify the end of file names
table_key (str, optional) – Key used to indentify the start of the table with file names
progress (Progress, optional) – The progress bar object
context (SSLContext, optional) – The SSL certificates context
timeout (int, optional) – The timeout in seconds for the connection
Attributes Summary
The list of files in the current directory
True if the protocol has been initialized with a url
Number of files in the current directory
Methods Summary
cd(path)Change directory
download(file, dest_dir[, verbose])Download a file from the current directory of a HTTP(S) site.
download_url(url, dest_dir[, verbose])Download a file from a HTTP(S) site url.
get(download_dir, files[, verbose])Downloads a list of files from the current directory.
ls(path, *[, fullpath])List the contents of a directory associated with a data set.
urljoin(path)Join urls while fully preserving url root.
Attributes Documentation
- files¶
The list of files in the current directory
- Type:
(list of str)
- initialized¶
True if the protocol has been initialized with a url
- Type:
(bool)
- num_files¶
Number of files in the current directory
- Type:
(int)
Methods Documentation
- cd(path: str)¶
Change directory
- Parameters:
path (str) – The remote directory path
- download(file: str, dest_dir: Union[str, Path], verbose: bool = True)[source]¶
Download a file from the current directory of a HTTP(S) site.
- Parameters:
file (str) – The file name to download
dest_dir (Union[str, Path]) – The destination directory
verbose (bool, optional) – If True, will output the download status. Default is True.
- Returns:
(Path)
- download_url(url: str, dest_dir: Union[str, Path], verbose: bool = True)[source]¶
Download a file from a HTTP(S) site url.
- Parameters:
url (str) – The url of a file to download
dest_dir (str, Path) – The directory where the file will be written
verbose (bool, optional) – If True, will output the download status. Default is True.
- Returns:
(Path)
- get(download_dir: Union[str, Path], files: List[str], verbose: bool = True) List[Path]¶
Downloads a list of files from the current 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(path: str, *, fullpath: bool = False) List[str]¶
List the contents of a directory associated with a data set.
- Parameters:
path (str) – The remote directory path
fullpath (bool, optional) – If
True, the contents of the directory will be returned with their full path
- Returns:
(list of str)