def _clean_animation(desc, parent):
desc = load.load_if_filename(desc) or desc<EOL>if isinstance(desc, str):<EOL><INDENT>animation = {'<STR_LIT>': desc}<EOL><DEDENT>elif not isinstance(desc, dict):<EOL><INDENT>raise TypeError('<STR_LIT>' % type(desc))<EOL><DEDENT>elif '<STR_LIT>' in desc or '<STR_LIT>' not in desc:<EOL><INDENT>animation = desc<EOL><DEDENT>else:<EOL><INDENT>animation = desc.pop('<STR_LIT>', {})<EOL>if isinstance(animation, str):<EOL><INDENT>animation = {'<STR_LIT>': animation}<EOL><DEDENT>animation['<STR_LIT>'] = desc.pop('<STR_LIT>', {})<EOL>if desc:<EOL><INDENT>raise ValueError('<STR_LIT>' + '<STR_LIT:U+002CU+0020>'.join(desc))<EOL><DEDENT><DEDENT>animation.setdefault('<STR_LIT>', DEFAULT_ANIMATION)<EOL>animation = construct.to_type_constructor(animation, ANIMATION_PATH)<EOL>datatype = animation.setdefault('<STR_LIT>', failed.Failed)<EOL>animation.setdefault('<STR_LIT:name>', datatype.__name__)<EOL>run = animation.setdefault('<STR_LIT>', {})<EOL>run_parent = parent.setdefault('<STR_LIT>', {})<EOL>if not ('<STR_LIT>' in run or '<STR_LIT>' in run):<EOL><INDENT>if '<STR_LIT>' in run_parent:<EOL><INDENT>run.update(fps=run_parent['<STR_LIT>'])<EOL><DEDENT>elif '<STR_LIT>' in run_parent:<EOL><INDENT>run.update(sleep_time=run_parent['<STR_LIT>'])<EOL><DEDENT><DEDENT>return animation<EOL>
Cleans up all sorts of special cases that humans want when entering
an animation from a yaml file.

1. Loading it from a file
2. Using just a typename instead of a dict
3. A single dict representing an animation, with a run: section.
4. (Legacy) Having a dict with parallel elements run: and animation:
5. (Legacy) A tuple or list: (animation, run )