import re


def GetBIOSStrAndIntAttributeHandles(attr_type, attr_val_table_data):

    """
    From pldmtool GetBIOSTable of type AttributeValueTable get the dict of
    attribute handle and its values based on the attribute type.

    Description of argument(s):
    attr_type               "BIOSInteger" or "BIOSString".
    attr_val_table_data     pldmtool output from GetBIOSTable table type AttributeValueTable.

    @return                 Dict of BIOS attribute and its value based on attribute type.

    """
    attr_val_int_dict = {}
    attr_val_str_dict = {}
    for item in attr_val_table_data:
        value_dict = {}
        attr_handle = re.findall(r'\(.*?\)', item["AttributeNameHandle"])
        # Example:
        # {'vmi_if0_ipv4_prefix_length': {'UpperBound': 32, 'LowerBound': 0}
        if (item["AttributeType"] == "BIOSInteger"):
            value_dict["LowerBound"] = item["LowerBound"]
            value_dict["UpperBound"] = item["UpperBound"]
            attr_val_int_dict[attr_handle[0][1:-1]] = value_dict
        # Example:
        # {'vmi_if1_ipv4_ipaddr': {'MaximumStringLength': 15, 'MinimumStringLength': 7}}
        elif (item["AttributeType"] == "BIOSString"):
            value_dict["MinimumStringLength"] = item["MinimumStringLength"]
            value_dict["MaximumStringLength"] = item["MaximumStringLength"]
            attr_val_str_dict[attr_handle[0][1:-1]] = value_dict

    if (attr_type == "BIOSInteger"):
        return attr_val_int_dict
    elif (attr_type == "BIOSString"):
        return attr_val_str_dict