Ejemplo n.º 1
0
def _newsortgroups_to_dgroups(g):
    '''
    While we transition to C++ sorting, we still need to make DGroups
    to keep the rest of Digsby happy.
    '''
    protocol_ids = g._protocol_ids

    if protocol_ids is not None:
        protos, ids = g._protocol_ids
    else:
        protos, ids = [], []

    children = []
    for elem in g:
        if isinstance(elem, blist.Group):
            elem = _newsortgroups_to_dgroups(elem)
        children.append(elem)

    groupkey = g.groupkey()
    if groupkey == FAKE_ROOT_GROUP_KEY:
        group = SpecialGroup(g.name, [None] + protos, ['__fakerootgroup__'] + ids, children)
        group.__class__ = FakeRootGroup
        assert group.groupkey() == groupkey
    else:
        group = SortGroup(g.name, protos, ids, groupkey, children)
    group._new_display_string = g.display_string
    return group