Base Models
core
¶
Assembly: Mappy Filename: core.py Author: Terry D. Eppler (adapted by Bro) Created: 05-31-2022 Last Modified By: Terry D. Eppler Last Modified On: 08-25-2025
Mappy is a GIS Toolkit written in python
Copyright © 2022 Terry Eppler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You can contact me at: terryeppler@gmail.com or eppler.terry@epa.gov
Classes¶
Result
¶
Represent an HTTP response as a lightweight Mappy result object.
Purpose
Captures the canonical URL, HTTP status code, response text, response
encoding, headers, and original requests.Response object produced by
fetcher and generator workflows. The container provides a stable shape for
serialization, diagnostics, UI display, and downstream extraction routines.
Attributes:
| Name | Type | Description |
|---|---|---|
url |
Optional[str]
|
Canonical response URL. |
status_code |
Optional[int]
|
HTTP response status code. |
text |
Optional[str]
|
Response body text. |
encoding |
Optional[str]
|
Response encoding reported by the HTTP client. |
headers |
Optional[str]
|
Response headers captured from the HTTP response. |
response |
Optional[Response]
|
Original |
Initialize the response result container.
Purpose
Copies response metadata and body content from a requests.Response
instance into stable instance attributes used by fetchers, crawlers,
generators, Streamlit display logic, and serialization helpers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
HTTP response object returned by |
required |
Source code in core.py
Attributes¶
has_html
property
¶
Indicate whether response text is available.
Purpose
Provides a simple Boolean indicator used by fetchers, crawlers, display logic, and diagnostics to determine whether the result carries text content that can be parsed, rendered, or serialized.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Methods:¶
to_dict
¶
Serialize the result container to a dictionary.
Purpose
Produces a plain dictionary representation of the captured HTTP response metadata and body text. The output supports Streamlit inspection, tests, cache serialization, diagnostics, and downstream JSON-friendly processing.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Dictionary containing URL, status code, text, encoding, and copied headers. |
Source code in core.py
Functions:¶
throw_if
¶
Validate that a required value is not None.
Purpose
Provides a lightweight guard for required arguments used by Mappy core objects and service wrappers. The function raises a clear validation error before downstream response, gateway, or result-container logic attempts to use a missing value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Human-readable argument name used in the raised message. |
required |
value
|
object
|
Runtime value to validate. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when |