Allow some warnings to be suppressed for Catapult inventory export

This commit is contained in:
Lance Edgar 2020-04-08 14:15:51 -05:00
parent 28f17ca31a
commit 74deef63ab

View file

@ -132,6 +132,10 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
'corepos', 'exporting.catapult_inventory.warn_truncated_receipt_alias',
default=True)
self.warn_size_null_byte = self.config.getbool(
'corepos', 'exporting.catapult_inventory.warn_size_null_byte',
default=True)
self.warn_multiple_vendor_items = self.config.getbool(
'corepos', 'exporting.catapult_inventory.warn_multiple_vendor_items',
default=True)
@ -144,6 +148,10 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
'corepos', 'exporting.catapult_inventory.warn_truncated_memo',
default=True)
self.warn_scale_ingredients_newline = self.config.getbool(
'corepos', 'exporting.catapult_inventory.warn_scale_ingredients_newline',
default=True)
self.floor_sections_exist = table_exists(self.host_session,
corepos.FloorSection)
self.tax_components_exist = table_exists(self.host_session,
@ -221,7 +229,8 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
# find some of these chars in a client DB and needed to avoid them, b/c
# the openpyxl lib said IllegalCharacterError
if size is not None and '\x00' in size:
log.warning("product %s has null byte in size field: %s",
logger = log.warning if self.warn_size_null_byte else log.debug
logger("product %s has null byte in size field: %s",
product.upc, product)
size = size.replace('\x00', '')
@ -372,7 +381,8 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
if scale_item:
scale_ingredient_text = scale_item.text
if "\n" in scale_ingredient_text:
log.warning("must remove carriage returns for scale ingredients: %s",
logger = log.warning if self.warn_scale_ingredients_newline else log.debug
logger("must remove carriage returns for scale ingredients: %s",
scale_ingredient_text)
scale_ingredient_text = scale_ingredient_text.replace("\n", " ")