Commit b79be15c by Alexander Kryklia

directives now without starting space

parent 96fd48f4
...@@ -72,7 +72,7 @@ class GraphicalSliderToolModule(XModule): ...@@ -72,7 +72,7 @@ class GraphicalSliderToolModule(XModule):
plot_div = '<div class="{element_class}_plot" id="{element_id}_plot" \ plot_div = '<div class="{element_class}_plot" id="{element_id}_plot" \
style="{style}"></div>' style="{style}"></div>'
# extract css style from plot # extract css style from plot
plot_def = re.search(r'\$\s*plot[^\$]*\$', html_string).group() plot_def = re.search(r'\$plot[^\$]*\$', html_string).group()
style = re.search(r'(?=.*style\=[\"\'](.*)[\"\'])', plot_def) style = re.search(r'(?=.*style\=[\"\'](.*)[\"\'])', plot_def)
if style: if style:
style = style.groups()[0] style = style.groups()[0]
...@@ -81,8 +81,8 @@ class GraphicalSliderToolModule(XModule): ...@@ -81,8 +81,8 @@ class GraphicalSliderToolModule(XModule):
replacement = plot_div.format(element_class=self.html_class, replacement = plot_div.format(element_class=self.html_class,
element_id=self.html_id, element_id=self.html_id,
style=style) style=style)
html_string = re.sub(r'\$\s*plot[^\$]*\$', replacement, html_string, html_string = re.sub(r'\$plot[^\$]*\$', replacement, html_string,
flags=re.IGNORECASE | re.UNICODE) flags=re.UNICODE)
# get variables # get variables
if json.loads(self.configuration_json)['root'].get('parameters'): if json.loads(self.configuration_json)['root'].get('parameters'):
...@@ -92,7 +92,8 @@ class GraphicalSliderToolModule(XModule): ...@@ -92,7 +92,8 @@ class GraphicalSliderToolModule(XModule):
variables = [x['@var'] for x in variables] variables = [x['@var'] for x in variables]
else: else:
return html_string return html_string
# if variables[0] == 'v':
# import ipdb; ipdb.set_trace()
#substitute sliders #substitute sliders
slider_div = '<div class="{element_class}_slider" \ slider_div = '<div class="{element_class}_slider" \
id="{element_id}_slider_{var}" \ id="{element_id}_slider_{var}" \
...@@ -100,7 +101,7 @@ class GraphicalSliderToolModule(XModule): ...@@ -100,7 +101,7 @@ class GraphicalSliderToolModule(XModule):
</div>' </div>'
for var in variables: for var in variables:
# find $slider var='var' ... $ # find $slider var='var' ... $
instances = re.findall(r'\$\s*slider\s+(?=.*var\=[\"\']' + var + '[\"\'])' \ instances = re.findall(r'\$slider\s+(?=.*var\=[\"\']' + var + '[\"\'])' \
+ r'[^\$]*\$', html_string) + r'[^\$]*\$', html_string)
if instances: # if presented, only one slider per var if instances: # if presented, only one slider per var
slider_def = instances[0] # get $slider var='var' ... $ string slider_def = instances[0] # get $slider var='var' ... $ string
...@@ -120,9 +121,9 @@ class GraphicalSliderToolModule(XModule): ...@@ -120,9 +121,9 @@ class GraphicalSliderToolModule(XModule):
var=var, style=style) var=var, style=style)
# subsitute $slider var='var' ... $ in html_srting to proper # subsitute $slider var='var' ... $ in html_srting to proper
# html div element # html div element
html_string = re.sub(r'\$\s*slider\s+(?=.*var\=[\"\'](' + \ html_string = re.sub(r'\$slider\s+(?=.*var\=[\"\'](' + \
var + ')[\"\'])' + r'[^\$]*\$', var + ')[\"\'])' + r'[^\$]*\$',
replacement, html_string, flags=re.IGNORECASE | re.UNICODE) replacement, html_string, flags=re.UNICODE)
# substitute inputs if we have them # substitute inputs if we have them
input_el = '<input class="{element_class}_input" \ input_el = '<input class="{element_class}_input" \
...@@ -133,7 +134,7 @@ class GraphicalSliderToolModule(XModule): ...@@ -133,7 +134,7 @@ class GraphicalSliderToolModule(XModule):
for var in variables: for var in variables:
input_index = 0 # make multiple inputs for same variable have input_index = 0 # make multiple inputs for same variable have
# different id # different id
instances = re.findall(r'\$\s*input\s+(?=.*var\=[\"\']' + var + '[\"\'])' \ instances = re.findall(r'\$input\s+(?=.*var\=[\"\']' + var + '[\"\'])' \
+ r'[^\$]*\$', html_string) + r'[^\$]*\$', html_string)
# import ipdb; ipdb.set_trace() # import ipdb; ipdb.set_trace()
for input_def in instances: # for multiple inputs per var for input_def in instances: # for multiple inputs per var
...@@ -159,9 +160,9 @@ class GraphicalSliderToolModule(XModule): ...@@ -159,9 +160,9 @@ class GraphicalSliderToolModule(XModule):
var=var, readonly=readonly, style=style, var=var, readonly=readonly, style=style,
input_index=input_index) input_index=input_index)
# import ipdb; ipdb.set_trace() # import ipdb; ipdb.set_trace()
html_string = re.sub(r'\$\s*input\s+(?=.*var\=[\"\'](' + \ html_string = re.sub(r'\$input\s+(?=.*var\=[\"\'](' + \
var + ')[\"\'])' + r'[^\$]*\$', var + ')[\"\'])' + r'[^\$]*\$',
replacement, html_string, count=1, flags=re.IGNORECASE | re.UNICODE) replacement, html_string, count=1, flags=re.UNICODE)
return html_string return html_string
def get_configuration(self): def get_configuration(self):
......
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