def old_roles_manager(self):
wrapper = self._old_role_wrapper<EOL>chamber_getter = operator.methodcaller('<STR_LIT>', '<STR_LIT>')<EOL>for term, roles in self.get('<STR_LIT>', {}).items():<EOL><INDENT>chamber_roles = defaultdict(lambda: defaultdict(list))<EOL>for chamber, roles in itertools.groupby(roles, chamber_getter):<EOL><INDENT>for role in roles:<EOL><INDENT>role = wrapper(role)<EOL>typeslug = role['<STR_LIT:type>'].lower().replace('<STR_LIT:U+0020>', '<STR_LIT:_>')<EOL>chamber_roles[chamber][typeslug].append(role)<EOL><DEDENT><DEDENT>yield term, chamber_roles<EOL><DEDENT>
Return old roles, grouped first by term, then by chamber,
        then by type.