Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions PyOphidia/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
import ast
import sys
import os
import json
Expand Down Expand Up @@ -901,16 +902,15 @@ def wisvalid(self, workflow):
return False
w = None

# Remove comment blocks
checked_workflow = re.sub(re.compile(r"/\*.*?\*/|//.*?\n", re.DOTALL), "\n", workflow)

if isinstance(checked_workflow, str):
if isinstance(workflow, str):
try:
w = json.loads(checked_workflow)
# Remove comment blocks in strings
checked_workflow = re.sub(r"(?m)^ *#.*\n?", "", workflow)
w = ast.literal_eval(checked_workflow)
except ValueError:
return False, "Workflow is not a valid JSON"
elif isinstance(checked_workflow, dict):
w = checked_workflow
elif isinstance(workflow, dict):
w = workflow
else:
return False, "Workflow is not a valid dictionary"
if "name" not in w or not w["name"]:
Expand Down