spacepaste

  1.  
  2. async def check_for_mojibake(row, found_mojibake, database, table, has_pri_key=False):
  3. for column, data in row.items():
  4. if data is None or not column.startswith("HEX"):
  5. continue
  6. for hex_char in data[::2]:
  7. if hex_char > '7':
  8. break
  9. else:
  10. continue
  11. field_bytes = binascii.unhexlify(data)
  12. try:
  13. field_bytes.decode("utf-8")
  14. if not has_pri_key:
  15. log_keyless_table(database, table)
  16. raise ValueError
  17. found_mojibake[database][table][rm_hex_wrap(column)]["rows_found"] += 1
  18. except UnicodeDecodeError:
  19. pass
  20.