def transform_hits(hits):
packages = OrderedDict()<EOL>for hit in hits:<EOL><INDENT>name = hit['<STR_LIT:name>']<EOL>summary = hit['<STR_LIT>']<EOL>version = hit['<STR_LIT:version>']<EOL>if name not in packages.keys():<EOL><INDENT>packages[name] = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': summary,<EOL>'<STR_LIT>': [version],<EOL>}<EOL><DEDENT>else:<EOL><INDENT>packages[name]['<STR_LIT>'].append(version)<EOL>if version == highest_version(packages[name]['<STR_LIT>']):<EOL><INDENT>packages[name]['<STR_LIT>'] = summary<EOL><DEDENT><DEDENT><DEDENT>return list(packages.values())<EOL>
The list from pypi is really a list of versions. We want a list of
packages with the list of versions stored inline. This converts the
list from pypi into one we can use.