

def _reconstruct(keyvals, dialect, keep_order=False, sort_attribute_values=False):
    '\n    Reconstructs the original attributes string according to the dialect.\n\n    Parameters\n    ==========\n    keyvals : dict\n        Attributes from a GFF/GTF feature\n\n    dialect : dict\n        Dialect containing info on how to reconstruct a string version of the\n        attributes\n\n    keep_order : bool\n        If True, then perform sorting of attribute keys to ensure they are in\n        the same order as those provided in the original file.  Default is\n        False, which saves time especially on large data sets.\n\n    sort_attribute_values : bool\n        If True, then sort values to ensure they will always be in the same\n        order.  Mostly only useful for testing; default is False.\n    '
    if (not dialect):
        raise AttributeStringError()
    if (not keyvals):
        return ''
    parts = []
    if dialect['repeated keys']:
        items = []
        for (key, val) in keyvals.items():
            if (len(val) > 1):
                for v in val:
                    items.append((key, [v]))
            else:
                items.append((key, val))
    else:
        items = list(keyvals.items())

    def sort_key(x):
        try:
            return dialect['order'].index(x[0])
        except ValueError:
            return 1000000.0
    if keep_order:
        items.sort(key=sort_key)
    for (key, val) in items:
        if val:
            if sort_attribute_values:
                val = sorted(val)
            val_str = dialect['multival separator'].join(val)
            if val_str:
                if dialect['quoted GFF2 values']:
                    val_str = ('"%s"' % val_str)
                part = dialect['keyval separator'].join([key, val_str])
        else:
            part = key
        parts.append(part)
    parts_str = dialect['field separator'].join(val_str)
    if dialect['trailing semicolon']:
        parts_str += ';'
    return parts_str

dataset/ETHPy150Open daler/gffutils/gffutils/parser.py _reconstruct/VarMisuse@309/656 `parts`->`val_str`