Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BioFlow-Insight
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shareFAIR
BioFlow-Insight
Commits
d51bc038
Commit
d51bc038
authored
5 months ago
by
George Marchment
Browse files
Options
Downloads
Patches
Plain Diff
update the extraction of conditions
parent
5e182635
No related branches found
No related tags found
No related merge requests found
Pipeline
#14463
failed with stage
in 2 minutes and 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/outils.py
+21
-16
21 additions, 16 deletions
src/outils.py
with
21 additions
and
16 deletions
src/outils.py
+
21
−
16
View file @
d51bc038
...
@@ -990,6 +990,7 @@ def extract_conditions(code, only_get_inside = True):
...
@@ -990,6 +990,7 @@ def extract_conditions(code, only_get_inside = True):
return
conditions_dico
return
conditions_dico
#Just because there is an 'if' doesn't necessarily mean there is an if bloc
#Just because there is an 'if' doesn't necessarily mean there is an if bloc
found_if_bloc
=
False
found_if_bloc
=
False
searching_for_else
=
False
conditions
=
[]
conditions
=
[]
if
(
code
[
start
:
start
+
2
]
==
"
if
"
and
[
quote_single
,
quote_double
,
triple_single
,
triple_double
]
==
[
False
,
False
,
False
,
False
]):
if
(
code
[
start
:
start
+
2
]
==
"
if
"
and
[
quote_single
,
quote_double
,
triple_single
,
triple_double
]
==
[
False
,
False
,
False
,
False
]):
...
@@ -1005,31 +1006,35 @@ def extract_conditions(code, only_get_inside = True):
...
@@ -1005,31 +1006,35 @@ def extract_conditions(code, only_get_inside = True):
else
:
else
:
conditions_dico
[
f
"
{
condition
}
$$__$$
{
index_condition
}
"
]
=
(
start
,
end
)
conditions_dico
[
f
"
{
condition
}
$$__$$
{
index_condition
}
"
]
=
(
start
,
end
)
index_condition
+=
1
index_condition
+=
1
searching_for_else
=
True
#conditions_dico = adding_inside(conditions_dico, code, start_inside, end_inside)
#conditions_dico = adding_inside(conditions_dico, code, start_inside, end_inside)
break
break
searching_for_else
=
True
while
(
searching_for_else
):
while
(
searching_for_else
):
searching_for_else
=
False
searching_for_else
=
False
#Try to find an else corresponding
#Try to find an else corresponding
if
(
found_if_bloc
and
code
[
end
:].
strip
()[:
4
]
==
"
else
"
):
if
(
found_if_bloc
and
code
[
end
:].
strip
()[:
4
]
==
"
else
"
):
found_else_if
=
False
found_else_if
=
False
#CASE of "else if"
#CASE of "else if"
for
match
in
re
.
finditer
(
r
"
else *if *\((.+)\)\s*\{
"
,
code
[
end
:]):
rest_of_code
=
code
[
end
:]
found_else_if
=
True
for
match
in
re
.
finditer
(
r
"
\s*else *if *\((.+)\)\s*\{
"
,
rest_of_code
):
searching_for_else
=
True
condition
=
match
.
group
(
1
)
conditions
.
append
(
condition
)
start_else
,
end_else
=
match
.
span
(
0
)
start_else
,
end_else
=
match
.
span
(
0
)
start_else
+=
end
if
(
start_else
==
0
):
end_else
=
extract_curly
(
code
,
end_else
+
end
)
found_else_if
=
True
start_inside
,
end_inside
=
match
.
span
(
0
)[
1
]
+
end
,
end_else
-
1
searching_for_else
=
True
if
(
only_get_inside
):
condition
=
match
.
group
(
1
)
conditions_dico
[
f
"
{
condition
}
$$__$$
{
index_condition
}
"
]
=
(
start_inside
,
end_inside
)
printed_condition
=
'
&&
'
.
join
([
"
!({})
"
.
format
(
v
)
for
v
in
conditions
])
else
:
printed_condition
+=
"
&&
"
+
condition
conditions_dico
[
f
"
{
condition
}
$$__$$
{
index_condition
}
"
]
=
(
start_else
,
end_else
)
conditions
.
append
(
condition
)
index_condition
+=
1
start_else
+=
end
#conditions_dico = adding_inside(conditions_dico, code, start_inside, end_inside)
end_else
=
extract_curly
(
code
,
end_else
+
end
)
break
start_inside
,
end_inside
=
match
.
span
(
0
)[
1
]
+
end
,
end_else
-
1
if
(
only_get_inside
):
conditions_dico
[
f
"
{
printed_condition
}
$$__$$
{
index_condition
}
"
]
=
(
start_inside
,
end_inside
)
else
:
conditions_dico
[
f
"
{
printed_condition
}
$$__$$
{
index_condition
}
"
]
=
(
start_else
,
end_else
)
index_condition
+=
1
#conditions_dico = adding_inside(conditions_dico, code, start_inside, end_inside)
break
#CASE of "else"
#CASE of "else"
if
(
not
found_else_if
):
if
(
not
found_else_if
):
for
match
in
re
.
finditer
(
r
"
else\s*{
"
,
code
[
end
:]):
for
match
in
re
.
finditer
(
r
"
else\s*{
"
,
code
[
end
:]):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment