readabs.print_abs_catalogue
Print the ABS Catalogue of time-series data.
1"""Print the ABS Catalogue of time-series data.""" 2 3from readabs.abs_catalogue import CatalogueError, abs_catalogue 4from readabs.download_cache import CacheError, HttpError 5 6# Constants for display formatting 7DISPLAY_COLUMNS = ["Theme", "Parent Topic", "Topic", "Status"] 8 9 10def print_abs_catalogue(*, cache_only: bool = False, verbose: bool = False) -> None: 11 """Print a table of ABS Catalogue Numbers with their metadata. 12 13 Displays catalogue numbers that contain time-series data along with 14 their theme, parent topic, topic, and status information. The URL 15 column is excluded from the display for readability. 16 17 This is primarily a convenience function to help users identify the 18 correct catalogue number for data retrieval functions. 19 20 Parameters 21 ---------- 22 cache_only : bool, default False 23 If True, only use cached catalogue data. 24 verbose : bool, default False 25 If True, print progress messages during catalogue retrieval. 26 27 Raises 28 ------ 29 CatalogueError 30 If the catalogue data cannot be retrieved or processed. 31 HttpError 32 If there's a network error downloading the catalogue. 33 CacheError 34 If cache_only=True but no cached data is available. 35 36 Example 37 ------- 38 >>> import readabs as ra 39 >>> ra.print_abs_catalogue() 40 41 """ 42 try: 43 # Retrieve the catalogue data 44 catalogue = abs_catalogue(cache_only=cache_only, verbose=verbose) 45 46 # Validate catalogue is not empty 47 if catalogue.empty: 48 print("No catalogue data available.") 49 return 50 51 # Select columns for display (exclude URL for readability) 52 available_columns = [col for col in DISPLAY_COLUMNS if col in catalogue.columns] 53 if not available_columns: 54 print("Catalogue data does not contain expected columns.") 55 return 56 57 display_data = catalogue[available_columns] 58 59 # Generate and print markdown table 60 try: 61 markdown_output = display_data.to_markdown() 62 print(markdown_output) 63 except Exception: # noqa: BLE001 64 print(display_data.to_string()) 65 66 except (CatalogueError, HttpError, CacheError) as e: 67 print(f"Error retrieving catalogue: {e}") 68 69 70if __name__ == "__main__": 71 print_abs_catalogue()
11def print_abs_catalogue(*, cache_only: bool = False, verbose: bool = False) -> None: 12 """Print a table of ABS Catalogue Numbers with their metadata. 13 14 Displays catalogue numbers that contain time-series data along with 15 their theme, parent topic, topic, and status information. The URL 16 column is excluded from the display for readability. 17 18 This is primarily a convenience function to help users identify the 19 correct catalogue number for data retrieval functions. 20 21 Parameters 22 ---------- 23 cache_only : bool, default False 24 If True, only use cached catalogue data. 25 verbose : bool, default False 26 If True, print progress messages during catalogue retrieval. 27 28 Raises 29 ------ 30 CatalogueError 31 If the catalogue data cannot be retrieved or processed. 32 HttpError 33 If there's a network error downloading the catalogue. 34 CacheError 35 If cache_only=True but no cached data is available. 36 37 Example 38 ------- 39 >>> import readabs as ra 40 >>> ra.print_abs_catalogue() 41 42 """ 43 try: 44 # Retrieve the catalogue data 45 catalogue = abs_catalogue(cache_only=cache_only, verbose=verbose) 46 47 # Validate catalogue is not empty 48 if catalogue.empty: 49 print("No catalogue data available.") 50 return 51 52 # Select columns for display (exclude URL for readability) 53 available_columns = [col for col in DISPLAY_COLUMNS if col in catalogue.columns] 54 if not available_columns: 55 print("Catalogue data does not contain expected columns.") 56 return 57 58 display_data = catalogue[available_columns] 59 60 # Generate and print markdown table 61 try: 62 markdown_output = display_data.to_markdown() 63 print(markdown_output) 64 except Exception: # noqa: BLE001 65 print(display_data.to_string()) 66 67 except (CatalogueError, HttpError, CacheError) as e: 68 print(f"Error retrieving catalogue: {e}")
Print a table of ABS Catalogue Numbers with their metadata.
Displays catalogue numbers that contain time-series data along with their theme, parent topic, topic, and status information. The URL column is excluded from the display for readability.
This is primarily a convenience function to help users identify the correct catalogue number for data retrieval functions.
Parameters
cache_only : bool, default False If True, only use cached catalogue data. verbose : bool, default False If True, print progress messages during catalogue retrieval.
Raises
CatalogueError If the catalogue data cannot be retrieved or processed. HttpError If there's a network error downloading the catalogue. CacheError If cache_only=True but no cached data is available.
Example
>>> import readabs as ra
>>> ra.print_abs_catalogue()