Example #1
0
def all_values_3rd_level(nbt_format):
    """Utility method to produce all possible containers of containers
    """
    i = 0

    for kind, value in all_dicts(nbt_format):
        for i_kind, i_value in all_values_2nd_level(nbt_format):
            name = nbt.str_type(i)
            i += 1
            value[name] = i_value
            if nbt_format:
                value.set_kind(name, i_kind)
        yield (kind, value)

    for kind, value in all_lists(nbt_format):
        for i_kind, i_value in all_values_2nd_level(nbt_format):
            # Empty list with set kind
            if nbt_format:
                value.set_kind(i_kind)
                yield (kind, value)

            # Non-empty list
            value.append(i_value)
            yield (kind, value)
            del value[:]
Example #2
0
def all_values_2nd_level(nbt_format):
    """Utility method to produce all possible non recursive containers
    """
    for kind, value in all_dicts(nbt_format):
        # Empty dict
        yield (kind, value)

        # Filled dict
        for i_kind, i_value in all_values_1st_level(nbt_format):
            name = nbt.str_type(i_kind)
            value[name] = i_value
            if nbt_format:
                value.set_kind(name, i_kind)
        yield (kind, value)

    for kind, value in all_lists(nbt_format):
        # Empty list with no kind
        yield (kind, value)

        for i_kind, i_value in all_values_1st_level(nbt_format):
            # Empty list with set kind
            if nbt_format:
                value.set_kind(i_kind)
                yield (kind, value)

            # Non-empty list
            value.append(i_value)
            yield (kind, value)
            del value[:]