-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aligntment: convert badges to css, use webassets only, user iUploader…
… interface
- Loading branch information
Showing
25 changed files
with
227 additions
and
105 deletions.
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
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
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,65 @@ | ||
# encoding: utf-8 | ||
import json | ||
|
||
import ckantoolkit as tk | ||
|
||
from ckantoolkit import config | ||
|
||
# TODO: configurable | ||
|
||
try: | ||
from tabulator.config import PARSERS | ||
except NameError: | ||
# Point in time list of parsers from v1.53.5 if library Tabulator not loaded | ||
PARSERS = { | ||
'csv': 'tabulator.parsers.csv.CSVParser', | ||
'datapackage': 'tabulator.parsers.datapackage.DataPackageParser', | ||
'gsheet': 'tabulator.parsers.gsheet.GsheetParser', | ||
'html': 'tabulator.parsers.html.HTMLTableParser', | ||
'inline': 'tabulator.parsers.inline.InlineParser', | ||
'json': 'tabulator.parsers.json.JSONParser', | ||
'jsonl': 'tabulator.parsers.ndjson.NDJSONParser', | ||
'ndjson': 'tabulator.parsers.ndjson.NDJSONParser', | ||
'ods': 'tabulator.parsers.ods.ODSParser', | ||
'sql': 'tabulator.parsers.sql.SQLParser', | ||
'tsv': 'tabulator.parsers.tsv.TSVParser', | ||
'xls': 'tabulator.parsers.xls.XLSParser', | ||
'xlsx': 'tabulator.parsers.xlsx.XLSXParser', | ||
} | ||
|
||
SUPPORTED_FORMATS_KEY = u"ckanext.validation.formats" | ||
DEFAULT_SUPPORTED_FORMATS = [u'csv', u'xls', u'xlsx'] | ||
DEFAULT_VALIDATION_OPTIONS_KEY = "ckanext.validation.default_validation_options" | ||
|
||
PASS_AUTH_HEADER = u"ckanext.validation.pass_auth_header" | ||
PASS_AUTH_HEADER_DEFAULT = True | ||
|
||
PASS_AUTH_HEADER_VALUE = u"ckanext.validation.pass_auth_header_value" | ||
|
||
|
||
def get_default_validation_options(): | ||
"""Return a default validation options | ||
Returns: | ||
dict[str, Any]: validation options dictionary | ||
""" | ||
default_options = tk.config.get(DEFAULT_VALIDATION_OPTIONS_KEY) | ||
return json.loads(default_options) if default_options else {} | ||
|
||
|
||
def get_supported_formats(): | ||
"""Returns a list of supported formats to validate. | ||
We use a tabulator to parse the file contents, so only those formats for | ||
which a parser exists are supported | ||
Returns: | ||
list[str]: supported format list | ||
""" | ||
supported_formats = [ | ||
_format.lower() | ||
for _format in tk.aslist(tk.config.get(SUPPORTED_FORMATS_KEY)) | ||
] | ||
|
||
for _format in supported_formats: | ||
assert _format in PARSERS, "Format {} is not supported".format(_format) | ||
|
||
SUPPORTED_FORMATS = config.get( | ||
u'ckanext.validation.formats', DEFAULT_SUPPORTED_FORMATS) | ||
return supported_formats or DEFAULT_SUPPORTED_FORMATS |
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
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
1 change: 0 additions & 1 deletion
1
ckanext/validation/templates/validation/snippets/validation_asset.html
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
ckanext/validation/templates/validation/snippets/validation_report_asset.html
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{% asset 'ckanext-validation/report-css' %} | ||
{% asset 'ckanext-validation/report-js' %} |
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
Oops, something went wrong.