def make_valid_avro(items,          <EOL>alltypes,       <EOL>found,          <EOL>union=False     <EOL>):<EOL>
<EOL>if isinstance(items, MutableMapping):<EOL><INDENT>items = copy.copy(items)<EOL>if items.get("<STR_LIT:name>") and items.get("<STR_LIT>", True):<EOL><INDENT>items["<STR_LIT:name>"] = avro_name(items["<STR_LIT:name>"])<EOL><DEDENT>if "<STR_LIT:type>" in items and items["<STR_LIT:type>"] in (<EOL>"<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>if (hasattr(items, "<STR_LIT>") and items.get("<STR_LIT>")) or ("<STR_LIT>"<EOL>in items):<EOL><INDENT>return items<EOL><DEDENT>if items["<STR_LIT:name>"] in found:<EOL><INDENT>return cast(Text, items["<STR_LIT:name>"])<EOL><DEDENT>found.add(items["<STR_LIT:name>"])<EOL><DEDENT>for field in ("<STR_LIT:type>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>if field in items:<EOL><INDENT>items[field] = make_valid_avro(<EOL>items[field], alltypes, found, union=True)<EOL><DEDENT><DEDENT>if "<STR_LIT>" in items:<EOL><INDENT>items["<STR_LIT>"] = [avro_name(sym) for sym in items["<STR_LIT>"]]<EOL><DEDENT>return items<EOL><DEDENT>if isinstance(items, MutableSequence):<EOL><INDENT>ret = []<EOL>for i in items:<EOL><INDENT>ret.append(make_valid_avro(i, alltypes, found, union=union))  <EOL><DEDENT>return ret<EOL><DEDENT>if union and isinstance(items, string_types):<EOL><INDENT>if items in alltypes and avro_name(items) not in found:<EOL><INDENT>return cast(Dict, make_valid_avro(alltypes[items], alltypes, found,<EOL>union=union))<EOL><DEDENT>items = avro_name(items)<EOL><DEDENT>return items<EOL>
Convert our schema to be more avro like.