Commit b6124590 authored by Penom Nom's avatar Penom Nom
Browse files

Skip lines commented.

parent 4b833af4
......@@ -104,44 +104,44 @@ class Workflow(threading.Thread):
workflow_command_lines = inspect.getsourcelines(getattr(self, self.function))[0]
for i in range(0, len(workflow_command_lines)):
line = workflow_command_lines[i]
if line.find("self.add_component") != -1:
if line.find("self.add_component") != -1 and not re.search('^\s*\#', line) :
while re.search('\\\s*$', line) : # While line ends with backslash
# Concatenate next line
i += 1
next_line = workflow_command_lines[i]
if re.search('^\s*\#', next_line) :
nex_line = "\\"
line = re.search('(.+)\\\s*$', line).groups()[0] + next_line
# The line is not commented.
if not re.search('^\s*\#', line) :
component_prefix = "default"
component_name = line.strip().split("self.add_component")[1][1:-1].split(",")[0][1:-1]
arguments = re.search("self.add_component\s*\((.+)\)", line).groups()[0]
named_prefix = re.search("component_prefix\s*=\s*([^,]+)", arguments)
# Component prefix is in named argument
if named_prefix:
component_prefix = named_prefix.groups()[0].strip().strip('"')
# Component prefix is missing or in unamed argument
else :
without_named_args = re.sub( ",?\s*\S+\s*=\s*\S+", "" , arguments) # Discard named arguments
fields = without_named_args.strip(",").split(",")
# Group brackets arguments
args_split_clean = []
current_idx = 0
current_arg = ""
while current_idx < len(fields) :
current_arg = current_arg + fields[current_idx] + ','
open_brackets = current_arg.count("[")
close_brackets = current_arg.count("]")
if open_brackets == close_brackets:
args_split_clean.append( current_arg[:-1] )
current_arg = ""
current_idx += 1
# Find component prefix
if len(args_split_clean) >= 4:
component_prefix = args_split_clean[3].strip().strip('"')
if self._component_is_duplicated(component_name+"."+component_prefix):
raise ValueError("Component " + component_name + " with prefix " +
component_prefix + " already exist in this pipeline!")
self.component_nameids[component_name+"."+component_prefix] = None
component_prefix = "default"
component_name = line.strip().split("self.add_component")[1][1:-1].split(",")[0][1:-1]
arguments = re.search("self.add_component\s*\((.+)\)", line).groups()[0]
named_prefix = re.search("component_prefix\s*=\s*([^,]+)", arguments)
# Component prefix is in named argument
if named_prefix:
component_prefix = named_prefix.groups()[0].strip().strip('"')
# Component prefix is missing or in unamed argument
else :
without_named_args = re.sub( ",?\s*\S+\s*=\s*\S+", "" , arguments) # Discard named arguments
fields = without_named_args.strip(",").split(",")
# Group brackets arguments
args_split_clean = []
current_idx = 0
current_arg = ""
while current_idx < len(fields) :
current_arg = current_arg + fields[current_idx] + ','
open_brackets = current_arg.count("[")
close_brackets = current_arg.count("]")
if open_brackets == close_brackets:
args_split_clean.append( current_arg[:-1] )
current_arg = ""
current_idx += 1
# Find component prefix
if len(args_split_clean) >= 4:
component_prefix = args_split_clean[3].strip().strip('"')
if self._component_is_duplicated(component_name+"."+component_prefix):
raise ValueError("Component " + component_name + " with prefix " +
component_prefix + " already exist in this pipeline!")
self.component_nameids[component_name+"."+component_prefix] = None
@staticmethod
def config_parser(arg_lines):
......
Supports Markdown
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