Commit 791c196e authored by sim's avatar sim

[FEAT] Add some parameters validation

parent 47365fdc
......@@ -70,6 +70,20 @@ def myProject_fromUrl(url):
def newCorpus(project, resource=11, name="Machine learning", query="LSTM"):
error = False
if not isinstance(project, ProjectNode):
error = "a valid project"
if not isinstance(resource, int) and not isinstance(resource, str):
error = "a valid resource identifier: id or name"
elif not isinstance(name, str):
error = "a valid name"
elif not isinstance(query, str):
error = "a valid query"
if error:
raise NotebookError("Please provide %s." % error)
source = get_resource(resource) if isinstance(resource, int) else \
get_resource_by_name(resource)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment