Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
diffoscope
Manage
Activity
Members
Labels
Plan
Issues
174
Issue boards
Milestones
Wiki
Code
Merge requests
14
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
d16faf7c
Commit
d16faf7c
authored
5 months ago
by
Chris Lamb
👀
Browse files
Options
Downloads
Patches
Plain Diff
Factor out a method for stripping ANSI escapes.
parent
a38cdad5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
diffoscope/comparators/image.py
+2
-5
2 additions, 5 deletions
diffoscope/comparators/image.py
diffoscope/comparators/utils/command.py
+7
-0
7 additions, 0 deletions
diffoscope/comparators/utils/command.py
with
9 additions
and
5 deletions
diffoscope/comparators/image.py
+
2
−
5
View file @
d16faf7c
...
...
@@ -27,9 +27,7 @@ from diffoscope.tempfiles import get_named_temporary_file
from
diffoscope.difference
import
Difference
,
VisualDifference
from
.utils.file
import
File
from
.utils.command
import
Command
,
our_check_output
re_ansi_escapes
=
re
.
compile
(
r
"
\x1b[^m]*m
"
)
from
.utils.command
import
Command
,
our_check_output
,
strip_ansi_escapes
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -40,8 +38,7 @@ class Img2Txt(Command):
return
[
"
img2txt
"
,
"
--width
"
,
"
60
"
,
"
--format
"
,
"
utf8
"
,
self
.
path
]
def
filter
(
self
,
line
):
# Strip ANSI escapes
return
re_ansi_escapes
.
sub
(
""
,
line
.
decode
(
"
utf-8
"
)).
encode
(
"
utf-8
"
)
return
strip_ansi_escapes
(
line
)
class
Identify
(
Command
):
...
...
This diff is collapsed.
Click to expand it.
diffoscope/comparators/utils/command.py
+
7
−
0
View file @
d16faf7c
...
...
@@ -19,11 +19,14 @@
import
abc
import
signal
import
logging
import
re
import
subprocess
from
.operation
import
Operation
from
...utils
import
format_cmdline
re_ansi_escapes
=
re
.
compile
(
rb
"
\x1b[^m]*m
"
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -115,3 +118,7 @@ def our_check_output(cmd, *args, **kwargs):
logger
.
debug
(
"
Calling external command: %s
"
,
"
"
.
join
(
cmd
))
return
subprocess
.
check_output
(
cmd
,
*
args
,
**
kwargs
)
def
strip_ansi_escapes
(
val
):
return
re_ansi_escapes
.
sub
(
b
""
,
val
)
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