How to use the pyglossary.plugins.sdict.FormatElement function in pyglossary

To help you get started, we’ve selected a few pyglossary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ilius / pyglossary / pyglossary / plugins / sdict.py View on Github external
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
github ilius / pyglossary / pyglossary / plugins / sdict.py View on Github external
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
github ilius / pyglossary / pyglossary / plugins / sdict.py View on Github external
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)
github ilius / pyglossary / pyglossary / plugins / sdict.py View on Github external
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)
github ilius / pyglossary / pyglossary / plugins / sdict.py View on Github external
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)
		)
github ilius / pyglossary / pyglossary / plugins / sdict.py View on Github external
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)