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
fe513c02
Commit
fe513c02
authored
2 years ago
by
FC (Fay) Stegerman
Committed by
Chris Lamb
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
add specialize_as(), use it to speed up .smali comparison in APKs
parent
bf334e1d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
diffoscope/comparators/apk.py
+11
-1
11 additions, 1 deletion
diffoscope/comparators/apk.py
diffoscope/comparators/utils/specialize.py
+11
-5
11 additions, 5 deletions
diffoscope/comparators/utils/specialize.py
with
22 additions
and
6 deletions
diffoscope/comparators/apk.py
+
11
−
1
View file @
fe513c02
...
...
@@ -35,9 +35,11 @@ from diffoscope.tools import (
)
from
diffoscope.tempfiles
import
get_temporary_directory
from
.utils.archive
import
Archive
from
.text
import
TextFile
from
.utils.archive
import
Archive
,
ArchiveMember
from
.utils.command
import
Command
from
.utils.compare
import
compare_files
from
.utils.specialize
import
specialize_as
from
.zip
import
ZipContainer
,
zipinfo_differences
,
ZipFileBase
from
.missing_file
import
MissingFile
...
...
@@ -157,6 +159,14 @@ class ApkContainer(Archive):
def
get_member_names
(
self
):
return
self
.
_members
def
get_member
(
self
,
member_name
):
member
=
ArchiveMember
(
self
,
member_name
)
if
member_name
.
endswith
(
"
.smali
"
)
and
member_name
.
startswith
(
"
smali
"
):
# smali{,_classesN}/**/*.smali files from apktool are always text,
# and using libmagic on thousands of these files takes minutes
return
specialize_as
(
TextFile
,
member
)
return
member
def
extract
(
self
,
member_name
,
dest_dir
):
return
os
.
path
.
join
(
self
.
_tmpdir
.
name
,
member_name
)
...
...
This diff is collapsed.
Click to expand it.
diffoscope/comparators/utils/specialize.py
+
11
−
5
View file @
fe513c02
...
...
@@ -28,9 +28,6 @@ logger = logging.getLogger(__name__)
def
try_recognize
(
file
,
cls
,
recognizes
):
if
isinstance
(
file
,
cls
):
return
True
# Does this file class match?
with
profile
(
"
recognizes
"
,
file
):
# logger.debug("trying %s on %s", cls, file)
...
...
@@ -43,13 +40,22 @@ def try_recognize(file, cls, recognizes):
format_class
(
cls
,
strip
=
"
diffoscope.comparators.
"
),
file
.
name
,
)
new_cls
=
type
(
cls
.
__name__
,
(
cls
,
type
(
file
)),
{})
file
.
__class__
=
new_cls
specialize_as
(
cls
,
file
)
return
True
def
specialize_as
(
cls
,
file
):
new_cls
=
type
(
cls
.
__name__
,
(
cls
,
type
(
file
)),
{})
file
.
__class__
=
new_cls
return
file
def
specialize
(
file
):
for
cls
in
ComparatorManager
().
classes
:
if
isinstance
(
file
,
cls
):
return
file
for
cls
in
ComparatorManager
().
classes
:
if
try_recognize
(
file
,
cls
,
cls
.
recognizes
):
return
file
...
...
This diff is collapsed.
Click to expand it.
Chris Lamb
@lamby
mentioned in merge request
!108 (closed)
·
1 year ago
mentioned in merge request
!108 (closed)
mentioned in merge request !108
Toggle commit list
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