Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class FormatElement(object):
def __init__(self, offset, length):
self.offset = offset
self.length = length
class Header(object):
f_signature = FormatElement(0x0, 4)
f_input_lang = FormatElement(0x4, 3)
f_output_lang = FormatElement(0x7, 3)
f_compression = FormatElement(0xa, 1)
f_num_of_words = FormatElement(0xb, 4)
f_length_of_short_index = FormatElement(0xf, 4)
f_title = FormatElement(0x13, 4)
f_copyright = FormatElement(0x17, 4)
f_version = FormatElement(0x1b, 4)
f_short_index = FormatElement(0x1f, 4)
f_full_index = FormatElement(0x23, 4)
f_articles = FormatElement(0x27, 4)
def parse(self, st):
self.signature = read_str(st, self.f_signature)
if self.signature != b"sdct":
raise ValueError("Not a valid sdict dictionary")
self.word_lang = read_str(st, self.f_input_lang)
self.article_lang = read_str(st, self.f_output_lang)
self.short_index_length = read_int(st, self.f_length_of_short_index)
comp_and_index_levels_byte = read_byte(
read_raw(st, self.f_compression)
)
self.compressionType = comp_and_index_levels_byte & 0b1111
class FormatElement(object):
def __init__(self, offset, length):
self.offset = offset
self.length = length
class Header(object):
f_signature = FormatElement(0x0, 4)
f_input_lang = FormatElement(0x4, 3)
f_output_lang = FormatElement(0x7, 3)
f_compression = FormatElement(0xa, 1)
f_num_of_words = FormatElement(0xb, 4)
f_length_of_short_index = FormatElement(0xf, 4)
f_title = FormatElement(0x13, 4)
f_copyright = FormatElement(0x17, 4)
f_version = FormatElement(0x1b, 4)
f_short_index = FormatElement(0x1f, 4)
f_full_index = FormatElement(0x23, 4)
f_articles = FormatElement(0x27, 4)
def parse(self, st):
self.signature = read_str(st, self.f_signature)
if self.signature != b"sdct":
raise ValueError("Not a valid sdict dictionary")
self.word_lang = read_str(st, self.f_input_lang)
self.article_lang = read_str(st, self.f_output_lang)
self.short_index_length = read_int(st, self.f_length_of_short_index)
comp_and_index_levels_byte = read_byte(
read_raw(st, self.f_compression)
)
self.compressionType = comp_and_index_levels_byte & 0b1111
self.short_index_depth = comp_and_index_levels_byte >> 4
self.length = length
class Header(object):
f_signature = FormatElement(0x0, 4)
f_input_lang = FormatElement(0x4, 3)
f_output_lang = FormatElement(0x7, 3)
f_compression = FormatElement(0xa, 1)
f_num_of_words = FormatElement(0xb, 4)
f_length_of_short_index = FormatElement(0xf, 4)
f_title = FormatElement(0x13, 4)
f_copyright = FormatElement(0x17, 4)
f_version = FormatElement(0x1b, 4)
f_short_index = FormatElement(0x1f, 4)
f_full_index = FormatElement(0x23, 4)
f_articles = FormatElement(0x27, 4)
def parse(self, st):
self.signature = read_str(st, self.f_signature)
if self.signature != b"sdct":
raise ValueError("Not a valid sdict dictionary")
self.word_lang = read_str(st, self.f_input_lang)
self.article_lang = read_str(st, self.f_output_lang)
self.short_index_length = read_int(st, self.f_length_of_short_index)
comp_and_index_levels_byte = read_byte(
read_raw(st, self.f_compression)
)
self.compressionType = comp_and_index_levels_byte & 0b1111
self.short_index_depth = comp_and_index_levels_byte >> 4
self.num_of_words = read_int(st, self.f_num_of_words)
self.title_offset = read_int(st, self.f_title)
self.copyright_offset = read_int(st, self.f_copyright)
def __init__(self, offset, length):
self.offset = offset
self.length = length
class Header(object):
f_signature = FormatElement(0x0, 4)
f_input_lang = FormatElement(0x4, 3)
f_output_lang = FormatElement(0x7, 3)
f_compression = FormatElement(0xa, 1)
f_num_of_words = FormatElement(0xb, 4)
f_length_of_short_index = FormatElement(0xf, 4)
f_title = FormatElement(0x13, 4)
f_copyright = FormatElement(0x17, 4)
f_version = FormatElement(0x1b, 4)
f_short_index = FormatElement(0x1f, 4)
f_full_index = FormatElement(0x23, 4)
f_articles = FormatElement(0x27, 4)
def parse(self, st):
self.signature = read_str(st, self.f_signature)
if self.signature != b"sdct":
raise ValueError("Not a valid sdict dictionary")
self.word_lang = read_str(st, self.f_input_lang)
self.article_lang = read_str(st, self.f_output_lang)
self.short_index_length = read_int(st, self.f_length_of_short_index)
comp_and_index_levels_byte = read_byte(
read_raw(st, self.f_compression)
)
self.compressionType = comp_and_index_levels_byte & 0b1111
self.short_index_depth = comp_and_index_levels_byte >> 4
self.num_of_words = read_int(st, self.f_num_of_words)
def read_byte(raw):
return unpack("
def read_short(raw):
return unpack("
class FormatElement(object):
def __init__(self, offset, length):
self.offset = offset
self.length = length
class Header(object):
f_signature = FormatElement(0x0, 4)
f_input_lang = FormatElement(0x4, 3)
f_output_lang = FormatElement(0x7, 3)
f_compression = FormatElement(0xa, 1)
f_num_of_words = FormatElement(0xb, 4)
f_length_of_short_index = FormatElement(0xf, 4)
f_title = FormatElement(0x13, 4)
f_copyright = FormatElement(0x17, 4)
f_version = FormatElement(0x1b, 4)
f_short_index = FormatElement(0x1f, 4)
f_full_index = FormatElement(0x23, 4)
f_articles = FormatElement(0x27, 4)
def parse(self, st):
self.signature = read_str(st, self.f_signature)
if self.signature != b"sdct":
raise ValueError("Not a valid sdict dictionary")
self.word_lang = read_str(st, self.f_input_lang)
self.article_lang = read_str(st, self.f_output_lang)
self.short_index_length = read_int(st, self.f_length_of_short_index)
comp_and_index_levels_byte = read_byte(
read_raw(st, self.f_compression)
)
self.offset = offset
self.length = length
class Header(object):
f_signature = FormatElement(0x0, 4)
f_input_lang = FormatElement(0x4, 3)
f_output_lang = FormatElement(0x7, 3)
f_compression = FormatElement(0xa, 1)
f_num_of_words = FormatElement(0xb, 4)
f_length_of_short_index = FormatElement(0xf, 4)
f_title = FormatElement(0x13, 4)
f_copyright = FormatElement(0x17, 4)
f_version = FormatElement(0x1b, 4)
f_short_index = FormatElement(0x1f, 4)
f_full_index = FormatElement(0x23, 4)
f_articles = FormatElement(0x27, 4)
def parse(self, st):
self.signature = read_str(st, self.f_signature)
if self.signature != b"sdct":
raise ValueError("Not a valid sdict dictionary")
self.word_lang = read_str(st, self.f_input_lang)
self.article_lang = read_str(st, self.f_output_lang)
self.short_index_length = read_int(st, self.f_length_of_short_index)
comp_and_index_levels_byte = read_byte(
read_raw(st, self.f_compression)
)
self.compressionType = comp_and_index_levels_byte & 0b1111
self.short_index_depth = comp_and_index_levels_byte >> 4
self.num_of_words = read_int(st, self.f_num_of_words)
self.title_offset = read_int(st, self.f_title)
def read_byte(raw):
return unpack("