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
10cfdd39
Commit
10cfdd39
authored
Nov 25, 2018
by
Christophe Benz
Browse files
Rename arguments
parent
a7d680be
Changes
1
Hide whitespace changes
Inline
Side-by-side
validata_core/__init__.py
View file @
10cfdd39
import
importlib.util
import
json
import
logging
from
pathlib
import
Path
from
datetime
import
datetime
from
pathlib
import
Path
import
importlib_resources
import
requests
...
...
@@ -102,8 +102,8 @@ def build_checks(goodtables_checks_json):
return
pre_checks_conf
,
checks
def
resolve_schema
(
valu
e
,
schema_config
=
None
):
"""Return a `tableschema.Schema` instance from `
valu
e` which can be either:
def
resolve_schema
(
sourc
e
,
schema_config
=
None
):
"""Return a `tableschema.Schema` instance from `
sourc
e` which can be either:
- a `pathlib.Path`
- a `str` containing either:
- a file path
...
...
@@ -112,21 +112,21 @@ def resolve_schema(value, schema_config=None):
- a `dict` representing the schema in JSON
- a `tableschema.Schema` instance
"""
if
isinstance
(
valu
e
,
Path
):
valu
e
=
str
(
valu
e
)
if
isinstance
(
valu
e
,
str
)
and
schema_config
is
not
None
:
# `
valu
e` is a SCDL tag (i.e. `scdl-prenoms`)
valu
e
=
schema_config
[
"schema_json_url"
]
schema
=
Schema
(
valu
e
)
if
isinstance
(
sourc
e
,
Path
):
sourc
e
=
str
(
sourc
e
)
if
isinstance
(
sourc
e
,
str
)
and
schema_config
is
not
None
:
# `
sourc
e` is a SCDL tag (i.e. `scdl-prenoms`)
sourc
e
=
schema_config
[
"schema_json_url"
]
schema
=
Schema
(
sourc
e
)
return
schema
def
validate
(
source
,
schema
,
checks
=
None
,
**
options
):
def
validate
(
source
,
schema
_source
,
checks
=
None
,
**
options
):
"""Validate a `source` applying pre-checks and checks.
`schema` is resolved using `resolve_schema`.
"""
schema
,
pre_checks_conf
,
checks
=
load_schema_and_checks
(
schema
,
checks
)
schema
,
pre_checks_conf
,
checks
=
load_schema_and_checks
(
schema
_source
,
checks
)
schema_descriptor
=
schema
.
descriptor
report
=
None
...
...
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