Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
0b4fdcbd
Commit
0b4fdcbd
authored
9 months ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Report progress when running pycompare
parent
b8a997c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scripts/pycompare.py
+21
-4
21 additions, 4 deletions
src/scripts/pycompare.py
with
21 additions
and
4 deletions
src/scripts/pycompare.py
+
21
−
4
View file @
0b4fdcbd
...
...
@@ -139,6 +139,8 @@ def compare_files(config):
fortran_file
=
open
(
config
[
'
fortran_file_name
'
],
'
r
'
)
c_file
=
open
(
config
[
'
c_file_name
'
],
'
r
'
)
num_read_lines
=
0
num_filtered_lines
=
0
last_progress
=
0
;
# LOG FILE INITIALIZATION #
if
(
config
[
'
log_html
'
]):
l_file
=
open
(
config
[
'
html_output
'
],
'
w
'
)
...
...
@@ -161,7 +163,10 @@ def compare_files(config):
num_len
=
1
if
(
line_count
>
0
):
num_len
=
max
(
4
,
int
(
log10
(
line_count
))
+
1
)
print
(
"
INFO: checking file contents...
"
)
if
(
config
[
'
say_progress
'
]):
print
(
"
INFO: checking file contents... 0
"
,
end
=
'
%
'
,
flush
=
True
)
else
:
print
(
"
INFO: checking file contents...
"
)
while
(
line_loop
):
if
(
not
config
[
'
linewise
'
]):
line_loop
=
False
...
...
@@ -172,6 +177,7 @@ def compare_files(config):
c_lines
=
[
c_file
.
readline
()]
num_read_lines
+=
1
num_read_lines
+=
1
num_filtered_lines
+=
1
# Start here the comparison loop
if
(
len
(
f_lines
)
==
len
(
c_lines
)):
for
li
in
range
(
len
(
f_lines
)):
...
...
@@ -180,24 +186,31 @@ def compare_files(config):
mismatch_count
[
'
warnings
'
]
+=
line_result
[
1
]
mismatch_count
[
'
noisy
'
]
+=
line_result
[
2
]
if
(
mismatch_count
[
'
errors
'
]
>
0
and
not
config
[
'
check_all
'
]):
print
(
"
INFO: mismatch found at line %d
"
%
(
num_read_lines
))
print
(
"
\n
INFO: mismatch found at line %d
"
%
(
num_read_lines
))
line_loop
=
False
break
else
:
mismatch_count
[
'
errors
'
]
=
len
(
c_lines
)
print
(
"
ERROR: {0:s} and {1:s} have different numbers of lines!
"
.
format
(
print
(
"
\n
ERROR: {0:s} and {1:s} have different numbers of lines!
"
.
format
(
config
[
'
fortran_file_name
'
],
config
[
'
c_file_name
'
]
))
if
(
config
[
'
log_html
'
]):
print
(
"
Different file sizes. No log produced.
"
)
config
[
'
log_html
'
]
=
False
if
(
num_re
a
d_lines
>=
line_count
):
if
(
num_
filte
red_lines
>=
line_count
):
line_loop
=
False
if
(
config
[
'
say_progress
'
]):
progress
=
int
(
100
*
num_filtered_lines
/
line_count
)
if
(
progress
>
last_progress
):
print
(
"
\b\b\b\b
%3d
"
%
progress
,
end
=
"
%
"
,
flush
=
True
)
last_progress
=
progress
#End line loop
if
l_file
is
not
None
:
l_file
.
write
(
"
</body>
\n
"
)
l_file
.
write
(
"
</html>
\n
"
)
l_file
.
close
()
if
(
config
[
'
say_progress
'
]):
print
(
""
)
return
mismatch_count
## \brief Perform the comparison of two file lines.
...
...
@@ -438,6 +451,7 @@ def parse_arguments():
'
linewise
'
:
True
,
'
log_html
'
:
False
,
'
html_output
'
:
'
pycompare.html
'
,
'
say_progress
'
:
True
,
'
warning_threshold
'
:
0.005
,
'
help_mode
'
:
False
,
'
check_all
'
:
True
,
...
...
@@ -460,6 +474,8 @@ def parse_arguments():
config
[
'
help_mode
'
]
=
True
elif
(
arg
.
startswith
(
"
--linewise
"
)):
config
[
'
linewise
'
]
=
True
elif
(
arg
.
startswith
(
"
--no-progress
"
)):
config
[
'
say_progress
'
]
=
False
elif
(
arg
.
startswith
(
"
--quick
"
)):
config
[
'
check_all
'
]
=
False
else
:
...
...
@@ -482,6 +498,7 @@ def print_help():
print
(
"
--help Print this help and exit.
"
)
print
(
"
--html[=OPT_OUTPUT_NAME] Enable logging to HTML file (default logs to
\"
pycompare.html
\"
).
"
)
print
(
"
--linewise Load only one line at a time. Useful to compare big files (True by default).
"
)
print
(
"
--no-progress Disable progress logging.
"
)
print
(
"
--quick Stop on first mismatch (default is to perform a full check).
"
)
print
(
"
--warn Set a fractional threshold for numeric warning (default = 0.005).
"
)
print
(
"
"
)
...
...
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