Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Poulpe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
octobus
Poulpe
Commits
d445ed02
Commit
d445ed02
authored
2 years ago
by
Pierre-Yves David
Browse files
Options
Downloads
Patches
Plain Diff
add a `full` variant for diff-result
That variant display difference for all items in the result
parent
163aba8e
No related branches found
No related tags found
No related merge requests found
Pipeline
#55368
passed
2 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/diff-result
+54
-2
54 additions, 2 deletions
bin/diff-result
with
54 additions
and
2 deletions
bin/diff-result
+
54
−
2
View file @
d445ed02
...
...
@@ -2,6 +2,7 @@
#
# Small tool to manipulaote
import
argparse
import
collections
import
os
import
sys
...
...
@@ -13,7 +14,7 @@
err
=
poulpe
.
err
def
compare
(
old_path
,
new_path
):
def
compare
(
old_path
,
new_path
,
full
=
False
):
old
=
poulpe
.
get_data
(
old_path
)
if
old
is
None
:
err
(
f
'
old file not found:
{
old_path
}
'
)
...
...
@@ -23,6 +24,15 @@
err
(
f
'
new file not found:
{
new_path
}
'
)
return
1
if
full
:
full_compare
(
old
,
new
)
else
:
simple_compare
(
old
,
new
)
return
0
def
simple_compare
(
old
,
new
):
old_median
=
old
[
'
result
'
][
'
time
'
][
'
median
'
]
new_median
=
new
[
'
result
'
][
'
time
'
][
'
median
'
]
...
...
@@ -34,6 +44,46 @@
return
0
def
_linear_data
(
data
,
prefix
=
""
):
"""
call to display data
"""
if
not
isinstance
(
data
,
dict
):
yield
(
prefix
,
data
)
return
for
k
,
v
in
sorted
(
data
.
items
()):
if
prefix
:
p
=
f
"
{
prefix
}
.
{
k
}
"
else
:
p
=
k
if
isinstance
(
v
,
dict
):
yield
from
_linear_data
(
v
,
p
)
elif
isinstance
(
v
,
list
):
for
idx
,
i
in
enumerate
(
v
):
yield
from
_linear_data
(
i
,
f
"
{
p
}
.
{
idx
}
"
)
else
:
yield
from
_linear_data
(
v
,
p
)
def
full_compare
(
old
,
new
):
all_values
=
collections
.
defaultdict
(
lambda
:
[
None
,
None
])
for
k
,
v
in
_linear_data
(
old
):
all_values
[
k
][
0
]
=
v
for
k
,
v
in
_linear_data
(
new
):
all_values
[
k
][
1
]
=
v
for
k
,
v
in
sorted
(
all_values
.
items
()):
if
v
[
0
]
!=
v
[
1
]:
if
v
[
0
]
is
None
:
o
=
"
ø
"
else
:
o
=
v
[
0
]
if
v
[
1
]
is
None
:
n
=
"
ø
"
else
:
n
=
v
[
1
]
print
(
f
"
{
k
}
:
{
o
}
->
{
n
}
"
)
return
0
def
_parsers
():
cmd_parser
=
argparse
.
ArgumentParser
(
prog
=
'
poulpe-bin-env-util
'
)
...
...
@@ -45,9 +95,11 @@
'
NEW_RESULT
'
,
help
=
"
the path to the data environment directory
"
,
)
cmd_parser
.
add_argument
(
'
--full
'
,
action
=
'
store_const
'
,
const
=
True
)
return
cmd_parser
def
main
(
args
):
parser
=
_parsers
()
param
=
parser
.
parse_args
(
args
)
...
...
@@ -48,10 +100,10 @@
return
cmd_parser
def
main
(
args
):
parser
=
_parsers
()
param
=
parser
.
parse_args
(
args
)
ret
=
compare
(
param
.
OLD_RESULT
,
param
.
NEW_RESULT
)
ret
=
compare
(
param
.
OLD_RESULT
,
param
.
NEW_RESULT
,
full
=
param
.
full
)
return
ret
...
...
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