Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcove.lib.converters: Add hook to change warning messages in a cove #91

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions libcove/lib/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@
logger = logging.getLogger(__name__)


def filter_conversion_warnings(conversion_warnings):
out = []
for w in conversion_warnings:
if w.category is flattentool.exceptions.DataErrorWarning:
out.append(str(w.message))
else:
logger.warning(w)
return out


@cove_spreadsheet_conversion_error
def convert_spreadsheet(
upload_dir,
Expand All @@ -36,7 +26,18 @@ def convert_spreadsheet(
xml=False,
xml_schemas=None,
cache=True,
conversion_warning_hook=lambda w: str(w.message),
):

def filter_conversion_warnings(conversion_warnings):
out = []
for w in conversion_warnings:
if w.category is flattentool.exceptions.DataErrorWarning:
out.append(conversion_warning_hook(w))
else:
logger.warning(w)
return out

context = {}
if xml:
output_file = "unflattened.xml"
Expand Down