sdwis_drink_water.utils
Module Contents
Functions
|
Processes a condition string for a table column. |
|
Extracts a description from an HTML page. |
Extracts a table description from an official site HTML page. |
|
Extracts a column description from an official site HTML page. |
|
|
Retrieves the description of a table from the Envirofacts database. |
|
Retrieves the description of a column from the Envirofacts database. |
|
Prints a tabulated result with dividers for better readability. |
|
Checks if a table includes an EPA region column. |
|
Validates the EPA region parameter. |
Attributes
- sdwis_drink_water.utils.CHECK_API_SITE_REMINDER = 'Please check official site for more information: https://www.epa.gov/enviro/sdwis-model#table_names'
- sdwis_drink_water.utils.TABLE_COLUMN_INCLUDE_EPA_REGION = ['GEOGRAPHIC_AREA', 'LCR_SAMPLE_RESULT', 'LCR_SAMPLE', 'WATER_SYSTEM', 'WATER_SYSTEM_FACILITY',...
- sdwis_drink_water.utils.BASE_TABLE_PAGE_URL = 'https://enviro.epa.gov/enviro/ef_metadata_html.ef_metadata_table?p_table_name={}&p_topic=SDWIS'
- sdwis_drink_water.utils.CHECK_TABLE_PAGE_REMINDER = 'Please check table structure for more information: '
- sdwis_drink_water.utils.process_table_column_condition(condition_handle)
Processes a condition string for a table column.
- Parameters:
condition_handle (str) – A condition string in the format ‘column>value’.
- Returns:
A processed string in the format ‘column/operator/value’.
- Return type:
str
- Raises:
ValueError – If the condition string is not in the expected format.
- sdwis_drink_water.utils.extract_description_from_description_page(html_content, desc_string='Description:')
Extracts a description from an HTML page.
- Parameters:
html_content (str) – HTML content of the page.
desc_string (str) – The description tag to search for.
- Returns:
The extracted description text or an error message.
- Return type:
str
- sdwis_drink_water.utils.extract_description_from_table_description_page(html_content)
Extracts a table description from an official site HTML page.
- Parameters:
html_content (str) – HTML content of the page.
- Returns:
Extracted table description.
- Return type:
str
- sdwis_drink_water.utils.extract_description_from_column_description_page(html_content)
Extracts a column description from an official site HTML page.
- Parameters:
html_content (str) – HTML content of the page.
- Returns:
Extracted column description.
- Return type:
str
- sdwis_drink_water.utils.get_table_description(table_name, session)
Retrieves the description of a table from the Envirofacts database.
- Parameters:
table_name (str) – Name of the table.
session (requests.Session) – The session used to make the request.
- Returns:
Table description or an error message.
- Return type:
str
- sdwis_drink_water.utils.get_column_description(column_name, session)
Retrieves the description of a column from the Envirofacts database.
- Parameters:
column_name (str) – Name of the column.
session (requests.Session) – The session used to make the request.
- Returns:
Column description or an error message.
- Return type:
str
- sdwis_drink_water.utils.print_tabulate_result_with_divider(tabulate_result)
Prints a tabulated result with dividers for better readability.
- Parameters:
tabulate_result (str) – The tabulated result to be printed.
- sdwis_drink_water.utils._is_table_has_epa_region(table_name)
Checks if a table includes an EPA region column.
- Parameters:
table_name (str) – Name of the table.
- Raises:
SdwisQueryParamsException – If the table does not include an EPA region column.
- sdwis_drink_water.utils._is_epa_region_param_valid(epa_region)
Validates the EPA region parameter.
- Parameters:
epa_region (int) – EPA region value to validate.
- Raises:
SdwisQueryParamsException – If the epa_region is not an integer or not in the range 1-10.