How to use the pyglossary.plugins.formats_common.log.warning 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 / babylon_bgl / bgl_info.py View on Github external
def languageInfoDecode(b_value):
	"""
		returns BabylonLanguage instance
	"""
	intValue = binStrToInt(b_value)
	try:
		return languageByCode[intValue]
	except IndexError:
		log.warning("read_type_3: unknown language code = %s", intValue)
		return
github ilius / pyglossary / pyglossary / plugins / babylon_bgl / bgl_info.py View on Github external
def utf16InfoDecode(b_value):
	"""
		b_value is byte array
		returns str, or None (on errors)

		block type = 3
		block format: <2 byte code1><2 byte code2>
		if code2 == 0: then the block ends
		if code2 == 1: then the block continues as follows:
		<4 byte len1> \x00 \x00 
		len1 - length of message in 2-byte chars
	"""
	if b_value[0] != 0:
		log.warning(
			"utf16InfoDecode: b_value=%s, null expected at 0",
			b_value,
		)
		return

	if b_value[1] == 0:
		if len(b_value) > 2:
			log.warning(
				"utf16InfoDecode: unexpected b_value size: %s",
				len(b_value),
			)
		return

	elif b_value[1] > 1:
		log.warning(
			"utf16InfoDecode: b_value=%s, unexpected byte at 1",
github ilius / pyglossary / pyglossary / plugins / babylon_bgl / bgl_info.py View on Github external
elif b_value[1] > 1:
		log.warning(
			"utf16InfoDecode: b_value=%s, unexpected byte at 1",
			list(b_value),
		)
		return

	# now b_value[1] == 1
	size = 2 * binStrToInt(b_value[2:6])
	if tuple(b_value[6:8]) != (0, 0):
		log.warning(
			"utf16InfoDecode: b_value=%s, null expected at 6:8",
			list(b_value),
		)
	if size != len(b_value)-8:
		log.warning(
			"utf16InfoDecode: b_value=%s, size does not match",
			list(b_value),
		)

	return b_value[8:].decode("utf16")  # str
github ilius / pyglossary / pyglossary / plugins / babylon_bgl / bgl_info.py View on Github external
def charsetInfoDecode(b_value):
	value = b_value[0]
	try:
		return charsetByCode[value]
	except KeyError:
		log.warning("read_type_3: unknown charset %s", value)
github ilius / pyglossary / pyglossary / plugins / babylon_bgl / bgl_info.py View on Github external
log.warning(
			"utf16InfoDecode: b_value=%s, null expected at 0",
			b_value,
		)
		return

	if b_value[1] == 0:
		if len(b_value) > 2:
			log.warning(
				"utf16InfoDecode: unexpected b_value size: %s",
				len(b_value),
			)
		return

	elif b_value[1] > 1:
		log.warning(
			"utf16InfoDecode: b_value=%s, unexpected byte at 1",
			list(b_value),
		)
		return

	# now b_value[1] == 1
	size = 2 * binStrToInt(b_value[2:6])
	if tuple(b_value[6:8]) != (0, 0):
		log.warning(
			"utf16InfoDecode: b_value=%s, null expected at 6:8",
			list(b_value),
		)
	if size != len(b_value)-8:
		log.warning(
			"utf16InfoDecode: b_value=%s, size does not match",
			list(b_value),
github ilius / pyglossary / pyglossary / plugins / babylon_bgl / bgl_info.py View on Github external
def aboutInfoDecode(b_value):
	if not b_value:
		return
	aboutExt, _, aboutContents = b_value.partition(b"\x00")
	if not aboutExt:
		log.warning("read_type_3: about: no file extension")
		return
	return {
		"about_extension": aboutExt,
		"about": aboutContents,
	}
github ilius / pyglossary / pyglossary / plugins / babylon_bgl / bgl_info.py View on Github external
"utf16InfoDecode: unexpected b_value size: %s",
				len(b_value),
			)
		return

	elif b_value[1] > 1:
		log.warning(
			"utf16InfoDecode: b_value=%s, unexpected byte at 1",
			list(b_value),
		)
		return

	# now b_value[1] == 1
	size = 2 * binStrToInt(b_value[2:6])
	if tuple(b_value[6:8]) != (0, 0):
		log.warning(
			"utf16InfoDecode: b_value=%s, null expected at 6:8",
			list(b_value),
		)
	if size != len(b_value)-8:
		log.warning(
			"utf16InfoDecode: b_value=%s, size does not match",
			list(b_value),
		)

	return b_value[8:].decode("utf16")  # str
github ilius / pyglossary / pyglossary / plugins / babylon_bgl / bgl_info.py View on Github external
block format: <2 byte code1><2 byte code2>
		if code2 == 0: then the block ends
		if code2 == 1: then the block continues as follows:
		<4 byte len1> \x00 \x00 
		len1 - length of message in 2-byte chars
	"""
	if b_value[0] != 0:
		log.warning(
			"utf16InfoDecode: b_value=%s, null expected at 0",
			b_value,
		)
		return

	if b_value[1] == 0:
		if len(b_value) > 2:
			log.warning(
				"utf16InfoDecode: unexpected b_value size: %s",
				len(b_value),
			)
		return

	elif b_value[1] > 1:
		log.warning(
			"utf16InfoDecode: b_value=%s, unexpected byte at 1",
			list(b_value),
		)
		return

	# now b_value[1] == 1
	size = 2 * binStrToInt(b_value[2:6])
	if tuple(b_value[6:8]) != (0, 0):
		log.warning(