Commit 27d9816d authored by Jerome Mariette's avatar Jerome Mariette
Browse files

better handle of component parameters parsing

parent 0a9db566
......@@ -17,6 +17,7 @@
import inspect
import os
import re
import sys
import uuid
import pkgutil
......@@ -98,15 +99,16 @@ class Workflow(threading.Thread):
self._serialize()
def init_component_nameids(self):
# TODO
# could be better with a better parsing of the add_component parameters
for line in inspect.getsourcelines(getattr(self, self.function))[0]:
if line.find("self.add_component(") != -1:
if line.find("self.add_component") != -1:
prefix = "default"
params = line.strip().split("self.add_component(")[1][:-1]
try: prefix = params.split("component_prefix=")[1][1:-1]
except: pass
component_name = params.split(",")[0][1:-1]
component_name = line.strip().split("self.add_component")[1][1:-1].split(",")[0][1:-1]
print component_name+"."+prefix
pre = re.search("self.add_component\s*\(\s*\"(\S+)\"\s*(,\s*(args\s*=\s*)?\[.*\]\s*)?((,\s*(kwargs\s*=\s*)?{.*}\s*)?(,\s*(component_prefix\s*=\s*)?\"(\S+)\"\s*\)?)?)", line)
if pre:
if pre.groups()[-1]: prefix = pre.groups()[-1]
if pre.groups()[0]: component_name = pre.groups()[0]
print component_name+"."+prefix
if self._component_is_duplicated(component_name+"."+prefix):
raise ValueError("Component " + component_name + " with prefix " +
prefix + " already exist in this pipeline!")
......
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