Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Validata
validata-ui
Commits
756be367
Commit
756be367
authored
Oct 03, 2018
by
Christophe Benz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow internalization of BytesLoader into validata-validate
parent
4b147afb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
18 deletions
+7
-18
validata_ui_next/util.py
validata_ui_next/util.py
+2
-15
validata_ui_next/views.py
validata_ui_next/views.py
+5
-3
No files found.
validata_ui_next/util.py
View file @
756be367
...
...
@@ -41,7 +41,6 @@ class ValidataSource():
self
.
type
=
type
self
.
scheme
=
None
self
.
format
=
None
self
.
custom_loaders
=
{}
def
get_goodtables_source
(
self
):
""" Creates source ready to be ingested by tabulator """
...
...
@@ -59,18 +58,6 @@ class ValidataSource():
# Else use custom BytesLoader
else
:
self
.
scheme
=
'custom'
self
.
custom_loaders
=
{
'custom'
:
BytesLoader
}
self
.
scheme
=
'bytes'
return
{
'source'
:
self
.
data
,
'format'
:
self
.
format
,
'scheme'
:
self
.
scheme
,
"custom_loaders"
:
self
.
custom_loaders
}
class
BytesLoader
(
Loader
):
""" Custom loader for bytes string """
options
=
[]
def
__init__
(
self
,
bytes_sample_size
,
**
options
):
pass
def
load
(
self
,
source
,
mode
=
't'
,
encoding
=
None
):
return
BytesIO
(
source
)
return
{
'source'
:
self
.
data
,
'format'
:
self
.
format
,
'scheme'
:
self
.
scheme
}
validata_ui_next/views.py
View file @
756be367
...
...
@@ -9,6 +9,7 @@ from collections import OrderedDict
from
pathlib
import
Path
from
validata_validate
import
csv_helpers
from
validata_validate.loaders
import
custom_loaders
from
validata_ui_next
import
app
from
validata_ui_next.util
import
flash_error
,
flash_info
,
flash_success
,
flash_warning
,
ValidataSource
from
validata_ui_next.validate_helper
import
ValidatorHelper
...
...
@@ -35,9 +36,10 @@ def extract_source_data(source: ValidataSource, preview_rows_nb=5):
delimiter
=
None
if
source
.
format
==
"csv"
:
delimiter
=
csv_helpers
.
detect_dialect
(
source
.
data
,
format
=
source
.
format
,
scheme
=
source
.
scheme
,
custom_loaders
=
source
.
custom_loaders
).
delimiter
with
tabulator
.
Stream
(
source
.
data
,
format
=
source
.
format
,
scheme
=
source
.
scheme
,
custom_loaders
=
source
.
custom_loaders
,
delimiter
=
delimiter
)
as
stream
:
delimiter
=
csv_helpers
.
detect_dialect
(
source
.
data
,
format
=
source
.
format
,
scheme
=
source
.
scheme
,
custom_loaders
=
custom_loaders
).
delimiter
with
tabulator
.
Stream
(
source
.
data
,
format
=
source
.
format
,
scheme
=
source
.
scheme
,
custom_loaders
=
custom_loaders
,
delimiter
=
delimiter
)
as
stream
:
for
row
in
stream
:
if
header
is
None
:
header
=
row
...
...
Write
Preview
Markdown
is supported
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