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
3e4fe101
Commit
3e4fe101
authored
2 months ago
by
George Marchment
Browse files
Options
Downloads
Patches
Plain Diff
Update function which turns a single line condition into a multiline condition
parent
a0abc48e
Loading
Loading
No related merge requests found
Pipeline
#14459
failed with stage
in 2 minutes and 7 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/code_.py
+15
-5
15 additions, 5 deletions
src/code_.py
with
15 additions
and
5 deletions
src/code_.py
+
15
−
5
View file @
3e4fe101
from
.outils
import
remove_comments
,
get_parenthese_count
,
get_curly_count
from
.outils
import
remove_comments
,
get_parenthese_count
,
get_curly_count
,
get_code_until_parenthese_count
from
.bioflowinsighterror
import
BioFlowInsightError
import
re
from
.
import
constant
...
...
@@ -32,12 +32,22 @@ class Code:
raise
BioFlowInsightError
(
f
"
The presence of
'
{
bit_of_code
}
'
is detected
{
self
.
get_string_line
(
bit_of_code
)
}
.
"
,
num
=
1
,
origin
=
self
)
#This methods turns a single line condition into a muli line conditions
def
turn_single_condition_into_multiline
(
self
,
code
):
pattern
=
r
"
(if *\()(.+)\n
"
to_replace
=
[]
for
match
in
re
.
finditer
(
r
"
if *\((.+)\) *([^{\n]+)\n
"
,
code
):
old
=
match
.
group
(
0
)
new
=
f
"
if (
{
match
.
group
(
1
)
}
) {{
\n
{
match
.
group
(
2
)
}
\n
}}
\n
"
to_replace
.
append
((
old
,
new
))
for
match
in
re
.
finditer
(
pattern
,
code
):
all
=
match
.
group
(
0
)
extarcted
=
match
.
group
(
2
).
strip
()
if
(
extarcted
!=
""
and
extarcted
[
-
1
]
not
in
[
"
{
"
,
"
}
"
]):
start
,
end
=
match
.
span
(
1
)
extracted_condition
=
get_code_until_parenthese_count
(
code
=
code
[
end
:],
val
=-
1
)
condition
=
extracted_condition
[:
-
1
]
body
=
extarcted
.
replace
(
extracted_condition
,
""
)
new
=
f
"
if (
{
condition
}
) {{
\n
{
body
}
\n
}}
\n
"
to_replace
.
append
((
all
,
new
))
for
r
in
to_replace
:
old
,
new
=
r
code
=
code
.
replace
(
old
,
new
)
...
...
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