ieml/dictionary/script/tools.py
def pack_factorisation(facto_list):
    """
    :param facto_list: list of parser or tuple of factorisation
    :return:
    """
    _sum = []
    for f in facto_list:
        if isinstance(f, Script):
            _sum.append(f)
        else:
            # tuple of factorisation
            _sum.append(MultiplicativeScript(children=(pack_factorisation(l_f) for l_f in f)))

    if len(_sum) == 1:
        return _sum[0]
    else:
        return AdditiveScript(children=_sum)
def pack_factorisation(facto_list):
    """
    :param facto_list: list of parser or tuple of factorisation
    :return:
    """
    _sum = []
    for f in facto_list:
        if isinstance(f, Script):
            _sum.append(f)
        else:
            # tuple of factorisation
            _sum.append(MultiplicativeScript(children=(pack_factorisation(l_f) for l_f in f)))

    if len(_sum) == 1:
        return _sum[0]
    else:
        return AdditiveScript(children=_sum)
:param facto_list: list of parser or tuple of factorisation
    :return: