def read_variant(variant):
result = <NUM_LIT:0><EOL>cnt = <NUM_LIT:0><EOL>for data in variant:<EOL><INDENT>result |= (data & <NUM_LIT>) << (<NUM_LIT:7> * cnt)<EOL>cnt += <NUM_LIT:1><EOL>if not data & <NUM_LIT>:<EOL><INDENT>return result, variant[cnt:]<EOL><DEDENT><DEDENT>raise Exception('<STR_LIT>')<EOL>
Read and parse a binary protobuf variant value.