-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix dig import 2021 #66
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b18d1f9
Importer doesn't use ckan logic and therefore uses exceptions not cov…
f3b00da
Added better DIG error messages for undefined excel cell range
3d6db15
Instead of erroring on missing DIG fields let the schema check the in…
a19c459
Clean up Exception handling and removing cruft per review
7ad85a5
Added comment on changing error processing from DIG import code to CK…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,15 @@ | |
import re | ||
|
||
from openpyxl import load_workbook | ||
try: | ||
from ckan.plugins.toolkit import Invalid | ||
except ImportError: # pragma: no cover | ||
# If the custom exception can't be imported, use a more generic exception | ||
# This happens when ckan is not installed locally, like when running unit tests on travis. | ||
Invalid = Exception | ||
#try: | ||
# from ckan.plugins.toolkit import Invalid | ||
#except ImportError: # pragma: no cover | ||
# # If the custom exception can't be imported, use a more generic exception | ||
# # This happens when ckan is not installed locally, like when running unit tests on travis. | ||
# Invalid = Exception | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can problem just remove this rather than comment it out, no? |
||
|
||
Invalid = Exception | ||
NotFound = StopIteration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we just use the actual Exceptions at this point, rather than alias them? |
||
|
||
from ckanext.cfpb_extrafields import validators as v | ||
|
||
|
@@ -194,9 +197,12 @@ def make_rec_from_sheet(ws, fields): | |
for field in fields: | ||
try: | ||
result[field] = get_field(ws, field, fields) | ||
except NotFound as err: | ||
errors.append(field + ": Unable to extract field from workbook - Check for duplicate or undefined cell ranges") | ||
except Invalid as err: | ||
errors.append(field + ": " + getattr(err, "error", getattr(err, "message", "UKNOWN_ERROR"))) | ||
return result, errors | ||
|
||
def make_rec(excel_file): | ||
wb = load_workbook(excel_file, read_only=True) | ||
version = get_schema_version(wb) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment explaining why we're skipping this, for now?