Skip to content

module decoding_attempts_table

Methods to build the rich.table used to display decoding attempts of a given bytes array.

Final output should be a rich.table of decoding attempts that are sorted like this:

  1. String representation of undecoded bytes is always the first row

  2. Encodings which chardet.detect() ranked as > 0% likelihood are sorted based on that confidence

  3. Then the unchardetectable:

  4. Decodings that were successful, unforced, and new

  5. Decodings that were "successful" but forced

  6. Decodings that were the same as other decodings

  7. Failed decodings

Global Variables

  • CENTER
  • FOLD
  • MIDDLE
  • RIGHT

function new_decoding_attempts_table

new_decoding_attempts_table(bytes_match: BytesMatch) → Table

Build a new rich Table with two rows, the raw and hex views of the bytes_match data.


function decoding_table_row

decoding_table_row(
    assessment: EncodingAssessment,
    is_forced: Text,
    txt: Text,
    score: float
) → DecodingTableRow

Build a table row for a decoding attempt.

Args:

  • assessment (EncodingAssessment): The chardet assessment for the encoding used.
  • is_forced (Text): Text indicating if the decode was forced.
  • txt (Text): The decoded string as a rich Text object (with highlighting).
  • score (float): The score to use for sorting this row in the table.

Returns:

  • DecodingTableRow: The constructed table row named tuple.

function assessment_only_row

assessment_only_row(
    assessment: EncodingAssessment,
    score: float
) → DecodingTableRow

Build a DecodingTableRow with just chardet assessment confidence data and no actual decoding attempt string.

Args:

  • assessment (EncodingAssessment): The chardet assessment for the encoding used.
  • score (float): The score to use for sorting this row within the table.

Returns:

  • DecodingTableRow: The constructed table row named tuple with no decoding attempt string.

class DecodingTableRow

DecodingTableRow(encoding_label, confidence_text, errors_while_decoded, decoded_string, confidence, encoding, sort_score, encoding_label_plain)


This file was automatically generated via lazydocs.