Skip to content

Models

Data models and types used throughout Naminter.

API Reference

naminter.core.models

Data models for WMN dataset structures, enumeration results, and responses.

WMN_REQUIRED_KEYS module-attribute

WMN_REQUIRED_KEYS = frozenset({'name', 'uri_check', 'e_code', 'e_string', 'm_string', 'm_code', 'known', 'cat'})

WMNMode

Bases: StrEnum

Enumeration mode for username enumeration.

ALL uses AND logic, ANY uses OR logic.

ALL class-attribute instance-attribute

ALL = auto()

ANY class-attribute instance-attribute

ANY = auto()

WMNStatus

Bases: StrEnum

Status of username search results.

EXISTS class-attribute instance-attribute

EXISTS = auto()

MISSING class-attribute instance-attribute

MISSING = auto()

PARTIAL_EXISTS class-attribute instance-attribute

PARTIAL_EXISTS = auto()

PARTIAL_MISSING class-attribute instance-attribute

PARTIAL_MISSING = auto()

CONFLICTING class-attribute instance-attribute

CONFLICTING = auto()

UNKNOWN class-attribute instance-attribute

UNKNOWN = auto()

NOT_VALID class-attribute instance-attribute

NOT_VALID = auto()

ERROR class-attribute instance-attribute

ERROR = auto()

WMNSite

Bases: TypedDict

Type definition for a single site in the WMN dataset structure.

Required: name, uri_check, e_code, e_string, m_string, m_code, known, cat.

Optional with conditions

post_body: Must contain {account}. When present, headers is required and {account} is not required in uri_check. headers: Required when post_body is present. Must be dict[str, str]. uri_check: Must contain {account} when post_body is absent. strip_bad_char: Characters to strip from username before substitution. uri_pretty: Display URL template (not validated). valid: Site validity flag (not validated). protection: Protection mechanisms (not validated).

name instance-attribute

name

uri_check instance-attribute

uri_check

uri_pretty instance-attribute

uri_pretty

post_body instance-attribute

post_body

headers instance-attribute

headers

strip_bad_char instance-attribute

strip_bad_char

e_code instance-attribute

e_code

e_string instance-attribute

e_string

m_string instance-attribute

m_string

m_code instance-attribute

m_code

known instance-attribute

known

cat instance-attribute

cat

valid instance-attribute

valid

protection instance-attribute

protection

WMNDataset

Bases: TypedDict

Type definition for WMN dataset structure.

All fields are required per JSON schema.

license instance-attribute

license

authors instance-attribute

authors

categories instance-attribute

categories

sites instance-attribute

sites

WMNSummary dataclass

WMNSummary(*, license, authors, site_names, sites_count, categories, categories_count, known_count)

Summary of the loaded WhatsMyName dataset and filters applied.

ATTRIBUTE DESCRIPTION
license

License information from the dataset.

TYPE: tuple[str, ...]

authors

Authors of the dataset.

TYPE: tuple[str, ...]

site_names

Names of all sites included.

TYPE: tuple[str, ...]

sites_count

Total number of sites.

TYPE: int

categories

Categories of the included sites.

TYPE: tuple[str, ...]

categories_count

Number of unique categories.

TYPE: int

known_count

Total number of known usernames across all sites.

TYPE: int

license instance-attribute

license

authors instance-attribute

authors

site_names instance-attribute

site_names

sites_count instance-attribute

sites_count

categories instance-attribute

categories

categories_count instance-attribute

categories_count

known_count instance-attribute

known_count

to_dict

to_dict()

Convert the summary to a plain dictionary.

RETURNS DESCRIPTION
dict[str, Any]

dict[str, Any]: Dictionary representation with lists instead of tuples.

WMNResult dataclass

WMNResult(*, name, category, username, status, uri_check=None, uri_pretty=None, status_code=None, headers=None, text=None, elapsed=None, error=None, created_at=(lambda: now(UTC))())

Result of testing a username on a site.

ATTRIBUTE DESCRIPTION
name

Site name from the WMN dataset.

TYPE: str

category

Site category from the WMN dataset.

TYPE: str

username

Username that was tested.

TYPE: str

status

Detection status of the username on the site.

TYPE: WMNStatus

uri_check

URL used for the check (request URL).

TYPE: str | None

uri_pretty

Optional "pretty" URL for display/reporting.

TYPE: str | None

status_code

HTTP status code of the response.

TYPE: int | None

headers

HTTP response headers.

TYPE: dict[str, str] | None

text

Response body text.

TYPE: str | None

elapsed

Time elapsed for the HTTP request.

TYPE: timedelta | None

error

Error message if the check failed.

TYPE: str | None

created_at

Timestamp when the result was created.

TYPE: datetime

name instance-attribute

name

category instance-attribute

category

username instance-attribute

username

status instance-attribute

status

uri_check class-attribute instance-attribute

uri_check = None

uri_pretty class-attribute instance-attribute

uri_pretty = None

status_code class-attribute instance-attribute

status_code = None

headers class-attribute instance-attribute

headers = None

text class-attribute instance-attribute

text = None

elapsed class-attribute instance-attribute

elapsed = None

error class-attribute instance-attribute

error = None

created_at class-attribute instance-attribute

created_at = field(default_factory=lambda: now(UTC))

from_error classmethod

from_error(*, username, message, site, uri_check=None, uri_pretty=None)

Create error result.

PARAMETER DESCRIPTION
username

Username being checked.

TYPE: str

message

Error message.

TYPE: str

site

Site configuration.

TYPE: WMNSite

uri_check

Optional URL used for the check.

TYPE: str | None DEFAULT: None

uri_pretty

Optional pretty URL for display.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
WMNResult

Result with ERROR status.

TYPE: WMNResult

from_not_valid classmethod

from_not_valid(*, username, site)

Create a NOT_VALID result for sites marked as invalid.

PARAMETER DESCRIPTION
username

Username being checked.

TYPE: str

site

Site configuration.

TYPE: WMNSite

RETURNS DESCRIPTION
WMNResult

Result with NOT_VALID status.

TYPE: WMNResult

from_response classmethod

from_response(*, username, uri_check, uri_pretty, response, site, mode, exclude_text=False)

Create WMNResult from HTTP response by evaluating detection criteria.

PARAMETER DESCRIPTION
username

Username being checked.

TYPE: str

uri_check

URL that was checked (request URL).

TYPE: str

uri_pretty

Pretty URL for display, or None to use uri_check.

TYPE: str | None

response

HTTP response object.

TYPE: WMNResponse

site

Site configuration dictionary with detection criteria.

TYPE: WMNSite

mode

Detection mode (ANY or ALL).

TYPE: WMNMode

exclude_text

When True, omit response text from the result.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
WMNResult

Result with determined status.

TYPE: WMNResult

to_dict

to_dict(*, exclude_text=False, exclude_none=True)

Convert the result to a plain dictionary.

PARAMETER DESCRIPTION
exclude_text

When True, omit the response text field.

TYPE: bool DEFAULT: False

exclude_none

When True, omit fields with None values.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
dict[str, Any]

dict[str, Any]: Dictionary representation of this result.

WMNTestResult dataclass

WMNTestResult(*, name, category, results=None, error=None, created_at=(lambda: now(UTC))())

Result of validation testing for a site's detection methods.

ATTRIBUTE DESCRIPTION
name

Site name from the WMN dataset.

TYPE: str

category

Site category from the WMN dataset.

TYPE: str

results

List of individual WMNResult objects, or None.

TYPE: list[WMNResult] | None

error

Error message if testing failed.

TYPE: str | None

created_at

Timestamp when the test result was created.

TYPE: datetime

status

Aggregate status computed from individual results.

TYPE: WMNStatus

name instance-attribute

name

category instance-attribute

category

results class-attribute instance-attribute

results = None

error class-attribute instance-attribute

error = None

created_at class-attribute instance-attribute

created_at = field(default_factory=lambda: now(UTC))

status class-attribute instance-attribute

status = field(init=False)

from_site classmethod

from_site(site, *, results=None, error=None)

Create WMNTestResult from a site configuration.

PARAMETER DESCRIPTION
site

Site configuration dictionary.

TYPE: WMNSite

results

Optional list of WMNResult objects.

TYPE: list[WMNResult] | None DEFAULT: None

error

Optional error message.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
WMNTestResult

Result with name and category from site.

TYPE: WMNTestResult

to_dict

to_dict(*, exclude_text=False, exclude_none=True)

Convert the test result to a plain dictionary.

PARAMETER DESCRIPTION
exclude_text

When True, omit response text from nested results.

TYPE: bool DEFAULT: False

exclude_none

When True, omit fields with None values.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
dict[str, Any]

dict[str, Any]: Dictionary representation of this test result.

WMNResponse dataclass

WMNResponse(*, status_code, text, elapsed, headers=None)

HTTP response abstraction used by session adapters.

ATTRIBUTE DESCRIPTION
status_code

HTTP status code of the response.

TYPE: int

text

Response body text.

TYPE: str

elapsed

Time elapsed for the HTTP request.

TYPE: timedelta

headers

HTTP response headers, or None if unavailable.

TYPE: dict[str, str] | None

status_code instance-attribute

status_code

text instance-attribute

text

elapsed instance-attribute

elapsed

headers class-attribute instance-attribute

headers = None

json

json()

Parse the response body as JSON and return the resulting object.

RETURNS DESCRIPTION
dict[str, Any] | list[Any] | str | int | float | bool | None

dict[str, Any] | list[Any] | str | int | float | bool | None: The parsed JSON value.

RAISES DESCRIPTION
JSONDecodeError

If the response text is not valid JSON.

WMNError dataclass

WMNError(*, path, data, message)

Structured representation of a validation error.

ATTRIBUTE DESCRIPTION
path

JSON path where the error occurred.

TYPE: str

data

Preview of the offending data, or None.

TYPE: str | None

message

Human-readable error description.

TYPE: str

path instance-attribute

path

data instance-attribute

data

message instance-attribute

message