Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
diffoscope
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Reproducible Builds
diffoscope
Commits
62ae0bbb
Commit
62ae0bbb
authored
4 years ago
by
Chris Lamb
Browse files
Options
Downloads
Patches
Plain Diff
comparators.utils.fuzzy: Tidy module.
parent
42ebb627
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
diffoscope/comparators/utils/fuzzy.py
+12
-9
12 additions, 9 deletions
diffoscope/comparators/utils/fuzzy.py
with
12 additions
and
9 deletions
diffoscope/comparators/utils/fuzzy.py
+
12
−
9
View file @
62ae0bbb
...
...
@@ -31,26 +31,28 @@ logger = logging.getLogger(__name__)
def
perform_fuzzy_matching
(
members1
,
members2
):
if
tlsh
is
None
or
Config
().
fuzzy_threshold
==
0
:
threshold
=
Config
().
fuzzy_threshold
if
tlsh
is
None
or
threshold
==
0
:
return
already_compared
=
set
()
# Create local copies because they will be modified by consumer
members1
=
dict
(
members1
)
members2
=
dict
(
members2
)
seen
=
set
()
for
name1
,
(
file1
,
_
)
in
members1
.
items
():
if
file1
.
is_directory
()
or
not
file1
.
fuzzy_hash
:
continue
comparisons
=
[]
for
name2
,
(
file2
,
_
)
in
members2
.
items
():
if
(
name2
in
already_compared
or
file2
.
is_directory
()
or
not
file2
.
fuzzy_hash
):
if
name2
in
seen
or
file2
.
is_directory
()
or
not
file2
.
fuzzy_hash
:
continue
comparisons
.
append
(
(
tlsh
.
diff
(
file1
.
fuzzy_hash
,
file2
.
fuzzy_hash
),
name2
)
)
if
comparisons
:
comparisons
.
sort
(
key
=
operator
.
itemgetter
(
0
))
score
,
name2
=
comparisons
[
0
]
...
...
@@ -60,6 +62,7 @@ def perform_fuzzy_matching(members1, members2):
name2
,
score
,
)
if
score
<
Config
().
fuzzy_
threshold
:
if
score
<
threshold
:
yield
name1
,
name2
,
score
already_compared
.
add
(
name2
)
seen
.
add
(
name2
)
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