From 74deef63abccca1d64f5d69d80712bbe210b2ade Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 8 Apr 2020 14:15:51 -0500 Subject: [PATCH] Allow some warnings to be suppressed for Catapult inventory export --- .../db/exporters/catapult_inventory.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py b/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py index f7a1fe5..bf3ed08 100644 --- a/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py +++ b/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py @@ -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,8 +229,9 @@ 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", - product.upc, product) + 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', '') price_divider = None @@ -372,8 +381,9 @@ 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", - scale_ingredient_text) + 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", " ") return {