Option Module
- class hivemind.option.HivemindOption(cid: str | None = None)[source]
Bases:
IPFSDict
A class representing a voting option in the Hivemind protocol.
This class handles the creation and validation of voting options, supporting various types of answers including strings, booleans, integers, floats, and complex types.
- Variables:
value (str | bool | int | float | Dict[str, Any] | None) – The value of the option
text (str) – Additional text description of the option
_hivemind_issue (HivemindIssue | None) – The associated hivemind issue
_answer_type (str) – Type of the answer (‘String’, ‘Bool’, ‘Integer’, etc.)
hivemind_id (str | None) – The IPFS hash of the associated hivemind issue
- __init__(cid: str | None = None) None [source]
Initialize a new HivemindOption.
- Parameters:
cid (str | None) – The IPFS multihash of the Option
- Returns:
None
- cid() str | None [source]
Get the IPFS CID of this option.
- Returns:
The IPFS CID
- Return type:
str | None
- get_answer_type() str [source]
Get the answer type of the option.
- Returns:
The answer type
- Return type:
- info() str [source]
Get information about the option.
- Returns:
A string containing formatted information about the option
- Return type:
- is_valid_address_option() bool [source]
Check if the option is a valid address option.
- Returns:
True if valid, False otherwise
- Return type:
- is_valid_bool_option() bool [source]
Check if the option is a valid boolean option.
- Returns:
True if valid, False otherwise
- Return type:
- is_valid_complex_option() bool [source]
Check if the option is a valid complex option according to the specifications in the constraints.
- Returns:
True if valid, False otherwise
- Return type:
- is_valid_file_option() bool [source]
Check if the option is a valid file option.
- Returns:
True if valid, False otherwise
- Return type:
- is_valid_float_option() bool [source]
Check if the option is a valid float option.
- Returns:
True if valid, False otherwise
- Return type:
- is_valid_hivemind_option() bool [source]
Check if the option is a valid hivemind option.
- Returns:
True if valid, False otherwise
- Return type:
- is_valid_integer_option() bool [source]
Check if the option is a valid integer option.
- Returns:
True if valid, False otherwise
- Return type:
- is_valid_string_option() bool [source]
Check if the option is a valid string option.
- Returns:
True if valid, False otherwise
- Return type:
- load(cid: str) None [source]
Load the option from IPFS.
- Parameters:
cid (str) – The IPFS multihash to load
- Returns:
None