# Path: hashmal_lib/gui_utils.py
# def floated_buttons(btns, left=False):
#     """Returns a HBoxLayout with buttons floated to the right or left."""
#     hbox = QHBoxLayout()
#     for b in btns:
#         hbox.addWidget(b)
#     if left:
#         hbox.addStretch(1)
#     else:
#         hbox.insertStretch(0, 1)
#     return hbox
# 
# def HBox(*widgets):
#     """Create an HBoxLayout with the widgets passed."""
#     hbox = QHBoxLayout()
#     for w in widgets:
#         hbox.addWidget(w)
#     return hbox
# 
# Path: hashmal_lib/core/utils.py
# def is_hex(x):
#     try:
#         i = int(x, 16)
#         return True
#     except ValueError:
#         pass
#     return False


from collections import OrderedDict, namedtuple
from PyQt4.QtGui import *
from PyQt4 import QtCore
from base import BaseDock, Plugin, augmenter
from item_types import ItemAction, item_types
from hashmal_lib.gui_utils import floated_buttons, HBox
from hashmal_lib.core.utils import is_hex



def make_plugin():
    return Plugin(Variables)

VariableType = namedtuple('VariableType', ('name', 'classify'))
"""Variable type.

Attributes:
    name (str): Human-readable name.
    classify (function): Function returning whether a value has this variable type.
"""

_var_types = [
    VariableType('None', lambda x: False),
    VariableType('Hex', is_hex),
    VariableType('Text', lambda x: x.startswith('"') and x.endswith('"')),

# Path: hashmal_lib/gui_utils.py
# def floated_buttons(btns, left=False):
#     """Returns a HBoxLayout with buttons floated to the right or left."""
#     hbox = QHBoxLayout()
#     for b in btns:
#         hbox.addWidget(b)
#     if left:
#         hbox.addStretch(1)
#     else:
#         hbox.insertStretch(0, 1)
#     return hbox
# 
# def HBox(*widgets):
#     """Create an HBoxLayout with the widgets passed."""
#     hbox = QHBoxLayout()
#     for w in widgets:
#         hbox.addWidget(w)
#     return hbox
# 
# Path: hashmal_lib/core/utils.py
# def is_hex(x):
#     try:
#         i = int(x, 16)
#         return True
#     except ValueError:
#         pass
#     return False


# Path: hashmal_lib/plugins/variables.py
from collections import OrderedDict, namedtuple
from PyQt4.QtGui import *
from PyQt4 import QtCore
from base import BaseDock, Plugin, augmenter
from item_types import ItemAction, item_types
from hashmal_lib.gui_utils import floated_buttons, HBox
from hashmal_lib.core.utils import is_hex




def make_plugin():
    return Plugin(Variables)

VariableType = namedtuple('VariableType', ('name', 'classify'))
"""Variable type.

Attributes:
    name (str): Human-readable name.
    classify (function): Function returning whether a value has this variable type.
"""

_var_types = [
    VariableType('None', lambda x: False),
    VariableType('Hex', is_hex),
    VariableType('Text', lambda x: x.startswith('"') and x.endswith('"')),

    VariableType('64 Hex Digits', lambda x: is_hex(x) and (len(x) == 66 if x.startswith('0x') else len(x) == 64)),