Commit 54c0c36e by Alexander Kryklia

fix \n in regext

parent 4e368f7d
...@@ -76,7 +76,8 @@ class GraphicalSliderToolModule(XModule): ...@@ -76,7 +76,8 @@ class GraphicalSliderToolModule(XModule):
plot_def = re.search(r'\$plot[^\$]*\$', html_string) plot_def = re.search(r'\$plot[^\$]*\$', html_string)
if plot_def: if plot_def:
plot_def = plot_def.group() plot_def = plot_def.group()
style = re.search(r'(?=.*style\=[\"\'](.*)[\"\'])', plot_def) style = re.search(r'(?=.*style\=[\"\'](.*)[\"\'])', plot_def,
flags=re.UNICODE | re.DOTALL)
if style: if style:
style = style.groups()[0] style = style.groups()[0]
else: # no style parameter else: # no style parameter
...@@ -105,7 +106,7 @@ class GraphicalSliderToolModule(XModule): ...@@ -105,7 +106,7 @@ class GraphicalSliderToolModule(XModule):
for var in variables: for var in variables:
# find $slider var='var' ... $ # find $slider var='var' ... $
instances = re.findall(r'\$slider\s+(?=.*var\=[\"\']' + var + '[\"\'])' \ instances = re.findall(r'\$slider\s+(?=.*var\=[\"\']' + var + '[\"\'])' \
+ r'[^\$]*\$', html_string) + r'[^\$]*\$', html_string, flags=re.UNICODE | re.DOTALL)
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
# extract var for proper style extraction further # extract var for proper style extraction further
...@@ -113,7 +114,8 @@ class GraphicalSliderToolModule(XModule): ...@@ -113,7 +114,8 @@ class GraphicalSliderToolModule(XModule):
slider_def).group() slider_def).group()
slider_def = slider_def.replace(var_substring, '') slider_def = slider_def.replace(var_substring, '')
# get style # get style
style = re.search(r'(?=.*style\=[\"\'](.*)[\"\'])', slider_def) style = re.search(r'(?=.*style\=[\"\'](.*)[\"\'])', slider_def,
flags=re.UNICODE | re.DOTALL)
if style: if style:
style = style.groups()[0] style = style.groups()[0]
else: # no style parameter else: # no style parameter
...@@ -126,7 +128,7 @@ class GraphicalSliderToolModule(XModule): ...@@ -126,7 +128,7 @@ class GraphicalSliderToolModule(XModule):
# html div element # html div element
html_string = re.sub(r'\$slider\s+(?=.*var\=[\"\'](' + \ html_string = re.sub(r'\$slider\s+(?=.*var\=[\"\'](' + \
var + ')[\"\'])' + r'[^\$]*\$', var + ')[\"\'])' + r'[^\$]*\$',
replacement, html_string, flags=re.UNICODE) replacement, html_string, flags=re.UNICODE | re.DOTALL)
# 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" \
...@@ -138,7 +140,7 @@ class GraphicalSliderToolModule(XModule): ...@@ -138,7 +140,7 @@ class GraphicalSliderToolModule(XModule):
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'\$input\s+(?=.*var\=[\"\']' + var + '[\"\'])' \ instances = re.findall(r'\$input\s+(?=.*var\=[\"\']' + var + '[\"\'])' \
+ r'[^\$]*\$', html_string) + r'[^\$]*\$', html_string, flags=re.UNICODE | re.DOTALL)
# 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
input_index += 1 input_index += 1
...@@ -146,13 +148,15 @@ class GraphicalSliderToolModule(XModule): ...@@ -146,13 +148,15 @@ class GraphicalSliderToolModule(XModule):
var_substring = re.search(r'(var\=[\"\']' + var + r'[\"\'])', var_substring = re.search(r'(var\=[\"\']' + var + r'[\"\'])',
input_def).group() input_def).group()
input_def = input_def.replace(var_substring, '') input_def = input_def.replace(var_substring, '')
readonly = re.search(r'(?=.*(readonly\=[\"\'](\w+)[\"\']))', input_def) readonly = re.search(r'(?=.*(readonly\=[\"\'](\w+)[\"\']))',
input_def, flags=re.UNICODE | re.DOTALL)
if readonly: if readonly:
input_def = input_def.replace(readonly.groups()[0], '') input_def = input_def.replace(readonly.groups()[0], '')
readonly = readonly.groups()[1] readonly = readonly.groups()[1]
else: else:
readonly = '' readonly = ''
style = re.search(r'(?=.*style\=[\"\'](.*)[\"\'])', input_def) style = re.search(r'(?=.*style\=[\"\'](.*)[\"\'])', input_def,
flags=re.UNICODE | re.DOTALL)
if style: if style:
style = style.groups()[0] style = style.groups()[0]
else: else:
...@@ -165,7 +169,7 @@ class GraphicalSliderToolModule(XModule): ...@@ -165,7 +169,7 @@ class GraphicalSliderToolModule(XModule):
# import ipdb; ipdb.set_trace() # import ipdb; ipdb.set_trace()
html_string = re.sub(r'\$input\s+(?=.*var\=[\"\'](' + \ html_string = re.sub(r'\$input\s+(?=.*var\=[\"\'](' + \
var + ')[\"\'])' + r'[^\$]*\$', var + ')[\"\'])' + r'[^\$]*\$',
replacement, html_string, count=1, flags=re.UNICODE) replacement, html_string, count=1, flags=re.UNICODE | re.DOTALL)
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