Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alexandre Bulté
Validata Core
Commits
57ace8c3
Commit
57ace8c3
authored
Nov 20, 2018
by
Christophe Benz
Browse files
Add build_tabulator_params
parent
d8db93c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
validata_core/source_helpers.py
0 → 100644
View file @
57ace8c3
from
tabulator
import
helpers
def
build_tabulator_params
(
type
,
name
,
source
):
"""Return tabulator params auto-detected from `name` and `source`, handling `type=file` for Validata UI and API.
Also decode `source`.
"""
scheme
,
format
=
helpers
.
detect_scheme_and_format
(
name
)
# In case of uploaded file (we work with bytes string)
if
type
==
'file'
:
# CSV: converts to string
if
format
==
'csv'
:
scheme
=
'text'
encoding
=
helpers
.
detect_encoding
(
source
)
source
=
source
.
decode
(
encoding
)
# Else use custom BytesLoader
else
:
scheme
=
'bytes'
return
{
'source'
:
source
,
'format'
:
format
,
'scheme'
:
scheme
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment