Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Reproducible Builds
diffoscope
Compare revisions
1351fdd46f031e4886c4aa10a5423aef46c39a07...ff57b8607f9c33053928ef2a2bebbf05a1ba9b51
Commits (3)
Drop explicit inheriting from 'object' class; unnecessary in Python 3.
· 7c21ed37
Chris Lamb
authored
Sep 25, 2019
7c21ed37
Drop an unnecessary "pass" statement.
· e066e77c
Chris Lamb
authored
Sep 25, 2019
e066e77c
Drop some unnecessary control flow.
· ff57b860
Chris Lamb
authored
Sep 25, 2019
ff57b860
Hide whitespace changes
Inline
Side-by-side
diffoscope/changes.py
View file @
ff57b860
...
...
@@ -57,7 +57,7 @@ class ChangesFileException(Exception):
pass
class
Changes
(
object
)
:
class
Changes
:
"""
Changes object to help process and store information regarding Debian
.changes files, used in the upload process.
...
...
@@ -224,8 +224,8 @@ class Changes(object):
"""
if
'/'
in
section
:
return
section
.
split
(
'/'
)
else
:
return
[
'main'
,
section
]
return
[
'main'
,
section
]
def
set_directory
(
self
,
directory
):
if
directory
:
...
...
diffoscope/comparators/__init__.py
View file @
ff57b860
...
...
@@ -30,7 +30,7 @@ from ..logging import line_eraser
logger
=
logging
.
getLogger
(
__name__
)
class
ComparatorManager
(
object
)
:
class
ComparatorManager
:
COMPARATORS
=
(
(
'directory.Directory'
,),
(
'missing_file.MissingFile'
,),
...
...
diffoscope/comparators/directory.py
View file @
ff57b860
...
...
@@ -191,7 +191,7 @@ def compare_directories(path1, path2, source=None):
return
FilesystemDirectory
(
path1
).
compare
(
FilesystemDirectory
(
path2
))
class
Directory
(
object
)
:
class
Directory
:
DESCRIPTION
=
"directories"
@classmethod
...
...
diffoscope/comparators/ffprobe.py
View file @
ff57b860
...
...
@@ -48,7 +48,7 @@ class Ffprobe(Command):
def
filter
(
self
,
line
):
if
self
.
flag
:
return
line
el
if
line
==
b
' Metadata:
\n
'
:
if
line
==
b
' Metadata:
\n
'
:
self
.
flag
=
True
return
b
''
...
...
diffoscope/comparators/gettext.py
View file @
ff57b860
...
...
@@ -60,11 +60,12 @@ class Msgunfmt(Command):
.
encode
(
'utf-8'
)
)
return
b
''
if
self
.
_encoding
!=
'utf-8'
:
return
line
.
decode
(
self
.
_encoding
).
encode
(
'utf-8'
)
else
:
if
self
.
_encoding
==
'utf-8'
:
return
line
return
line
.
decode
(
self
.
_encoding
).
encode
(
'utf-8'
)
class
MoFile
(
File
):
DESCRIPTION
=
"Gettext message catalogues"
...
...
diffoscope/comparators/utils/archive.py
View file @
ff57b860
...
...
@@ -36,8 +36,7 @@ class Archive(Container, metaclass=abc.ABCMeta):
def
__new__
(
cls
,
source
,
*
args
,
**
kwargs
):
if
isinstance
(
source
,
MissingFile
):
return
super
(
Container
,
MissingArchive
).
__new__
(
MissingArchive
)
else
:
return
super
(
Container
,
cls
).
__new__
(
cls
)
return
super
(
Container
,
cls
).
__new__
(
cls
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -122,7 +121,7 @@ class ArchiveMember(File):
return
False
class
MissingArchiveLikeObject
(
object
)
:
class
MissingArchiveLikeObject
:
def
getnames
(
self
):
return
[]
...
...
diffoscope/comparators/utils/command.py
View file @
ff57b860
...
...
@@ -25,7 +25,7 @@ import subprocess
logger
=
logging
.
getLogger
(
__name__
)
class
Command
(
object
,
metaclass
=
abc
.
ABCMeta
):
class
Command
(
metaclass
=
abc
.
ABCMeta
):
MAX_STDERR_LINES
=
50
def
__init__
(
self
,
path
):
...
...
diffoscope/comparators/utils/container.py
View file @
ff57b860
...
...
@@ -39,7 +39,7 @@ NO_COMMENT = None
logger
=
logging
.
getLogger
(
__name__
)
class
Container
(
object
,
metaclass
=
abc
.
ABCMeta
):
class
Container
(
metaclass
=
abc
.
ABCMeta
):
auto_diff_metadata
=
True
def
__new__
(
cls
,
source
):
...
...
diffoscope/comparators/utils/file.py
View file @
ff57b860
...
...
@@ -64,7 +64,7 @@ def _run_tests(fold, tests):
return
fold
(
t
(
y
,
x
)
for
x
,
t
,
y
in
tests
)
class
File
(
object
,
metaclass
=
abc
.
ABCMeta
):
class
File
(
metaclass
=
abc
.
ABCMeta
):
if
hasattr
(
magic
,
'open'
):
# use Magic-file-extensions from file
@classmethod
...
...
diffoscope/comparators/utils/libarchive.py
View file @
ff57b860
...
...
@@ -278,9 +278,9 @@ class LibarchiveContainer(Archive):
def
get_subclass
(
self
,
entry
):
if
entry
.
isdir
:
return
LibarchiveDirectory
(
self
,
entry
)
el
if
entry
.
issym
:
if
entry
.
issym
:
return
LibarchiveSymlink
(
self
,
entry
)
el
if
entry
.
isblk
or
entry
.
ischr
:
if
entry
.
isblk
or
entry
.
ischr
:
return
LibarchiveDevice
(
self
,
entry
)
return
LibarchiveMember
(
self
,
entry
)
...
...
diffoscope/comparators/zip.py
View file @
ff57b860
...
...
@@ -191,7 +191,7 @@ class ZipFile(File):
return
differences
class
IgnoreReturncodeMixin
(
object
)
:
class
IgnoreReturncodeMixin
:
@property
def
returncode
(
self
):
returncode
=
super
().
returncode
...
...
diffoscope/config.py
View file @
ff57b860
...
...
@@ -31,7 +31,7 @@ class defaultint(int):
# Avoid setting values on this anywhere other than main.run_diffoscope(),
# otherwise tests may fail unpredictably depending on order-of-execution.
class
Config
(
object
)
:
class
Config
:
_singleton
=
{}
def
__init__
(
self
):
...
...
diffoscope/diff.py
View file @
ff57b860
...
...
@@ -40,7 +40,7 @@ logger = logging.getLogger(__name__)
re_diff_change
=
re
.
compile
(
r
'^([+-@]).*'
,
re
.
MULTILINE
)
class
DiffParser
(
object
)
:
class
DiffParser
:
RANGE_RE
=
re
.
compile
(
# example: '@@ -26814,9 +26814,8 @@'
rb
'''
...
...
@@ -265,8 +265,6 @@ class _Feeder:
(currently?) instances of any particular class.
"""
pass
def
empty_file_feeder
():
"""
...
...
@@ -507,7 +505,7 @@ def linediff_simplify(g):
yield
current
class
SideBySideDiff
(
object
)
:
class
SideBySideDiff
:
"""Calculates a side-by-side diff from a unified diff."""
def
__init__
(
self
,
unified_diff
,
diffon
=
DIFFON
,
diffoff
=
DIFFOFF
):
...
...
diffoscope/difference.py
View file @
ff57b860
...
...
@@ -29,7 +29,7 @@ from .excludes import command_excluded
logger
=
logging
.
getLogger
(
__name__
)
class
Difference
(
object
)
:
class
Difference
:
def
__init__
(
self
,
unified_diff
,
...
...
@@ -357,7 +357,7 @@ class Difference(object):
self
.
_size_cache
=
None
class
VisualDifference
(
object
)
:
class
VisualDifference
:
def
__init__
(
self
,
data_type
,
content
,
source
):
self
.
_data_type
=
data_type
self
.
_content
=
content
...
...
diffoscope/main.py
View file @
ff57b860
...
...
@@ -499,7 +499,7 @@ class HelpFormatter(argparse.HelpFormatter):
return
val
class
RangeCompleter
(
object
)
:
class
RangeCompleter
:
def
__init__
(
self
,
start
,
end
=
0
,
divisions
=
16
):
if
end
<
start
:
tmp
=
end
...
...
diffoscope/presenters/formats.py
View file @
ff57b860
...
...
@@ -30,7 +30,7 @@ from .restructuredtext import RestructuredTextPresenter
logger
=
logging
.
getLogger
(
__name__
)
class
PresenterManager
(
object
)
:
class
PresenterManager
:
_singleton
=
{}
def
__init__
(
self
):
...
...
diffoscope/presenters/html/html.py
View file @
ff57b860
...
...
@@ -369,7 +369,7 @@ class HTMLPrintContext(
return
None
if
self
.
single_page
else
self
.
target
class
HTMLSideBySidePresenter
(
object
)
:
class
HTMLSideBySidePresenter
:
supports_visual_diffs
=
True
def
__init__
(
self
):
...
...
@@ -467,34 +467,32 @@ class HTMLSideBySidePresenter(object):
if
self
.
spl_rows
>=
self
.
max_lines_parent
:
raise
DiffBlockLimitReached
()
return
False
else
:
# html-dir output, perhaps need to rotate
if
self
.
spl_rows
>=
self
.
max_lines
:
raise
DiffBlockLimitReached
()
if
self
.
spl_current_page
==
0
:
# on parent page
if
self
.
spl_rows
<
self
.
max_lines_parent
:
return
False
logger
.
debug
(
"new unified-diff subpage, parent page went over %s lines"
,
self
.
max_lines_parent
,
)
else
:
# on child page
if
(
self
.
bytes_max_total
and
self
.
bytes_written
>
self
.
bytes_max_total
):
raise
PrintLimitReached
()
if
(
self
.
spl_print_func
.
bytes_written
<
self
.
max_page_size_child
):
return
False
logger
.
debug
(
"new unified-diff subpage, previous subpage went over %s bytes"
,
self
.
max_page_size_child
,
)
return
True
# html-dir output, perhaps need to rotate
if
self
.
spl_rows
>=
self
.
max_lines
:
raise
DiffBlockLimitReached
()
if
self
.
spl_current_page
==
0
:
# on parent page
if
self
.
spl_rows
<
self
.
max_lines_parent
:
return
False
logger
.
debug
(
"new unified-diff subpage, parent page went over %s lines"
,
self
.
max_lines_parent
,
)
else
:
# on child page
if
(
self
.
bytes_max_total
and
self
.
bytes_written
>
self
.
bytes_max_total
):
raise
PrintLimitReached
()
if
self
.
spl_print_func
.
bytes_written
<
self
.
max_page_size_child
:
return
False
logger
.
debug
(
"new unified-diff subpage, previous subpage went over %s bytes"
,
self
.
max_page_size_child
,
)
return
True
def
new_child_page
(
self
):
_
,
rotation_params
=
self
.
spl_print_ctrl
...
...
@@ -689,15 +687,15 @@ class HTMLPresenter(Presenter):
del
continuations
[
node
]
def
output_node_placeholder
(
self
,
pagename
,
lazy_load
,
size
=
0
):
if
lazy_load
:
return
templates
.
DIFFNODE_LAZY_LOAD
%
{
"pagename"
:
pagename
,
"pagesize"
:
sizeof_fmt
(
Config
().
max_page_size_child
),
"size"
:
sizeof_fmt
(
size
),
}
else
:
if
not
lazy_load
:
return
templates
.
DIFFNODE_LIMIT
return
templates
.
DIFFNODE_LAZY_LOAD
%
{
"pagename"
:
pagename
,
"pagesize"
:
sizeof_fmt
(
Config
().
max_page_size_child
),
"size"
:
sizeof_fmt
(
size
),
}
def
output_difference
(
self
,
ctx
,
root_difference
):
outputs
=
{}
# nodes to their partial output
ancestors
=
{}
# child nodes to ancestor nodes
...
...
diffoscope/presenters/utils.py
View file @
ff57b860
...
...
@@ -44,7 +44,7 @@ def sizeof_fmt(num, suffix='B', sigfig=3):
return
"%s %s%s"
%
(
round_sigfig
(
num
,
sigfig
),
unit
,
suffix
)
class
Presenter
(
object
)
:
class
Presenter
:
supports_visual_diffs
=
False
def
__init__
(
self
):
...
...
@@ -146,7 +146,7 @@ class PartialFormatter(string.Formatter):
parse_no_escape
=
string
.
Formatter
.
parse
class
FormatPlaceholder
(
object
)
:
class
FormatPlaceholder
:
def
__init__
(
self
,
ident
):
self
.
ident
=
str
(
ident
)
...
...
@@ -166,7 +166,7 @@ class FormatPlaceholder(object):
return
FormatPlaceholder
(
self
.
ident
+
"."
+
str
(
attr
))
class
PartialString
(
object
)
:
class
PartialString
:
r
"""A format string where the "holes" are indexed by arbitrary python
objects instead of string names or integer indexes. This is useful when you
need to compose these objects together, but don't want users of the partial
...
...
@@ -404,8 +404,7 @@ class PartialString(object):
def
cont
(
t
,
fmtstr
,
*
holes
):
if
isinstance
(
fmtstr
,
cls
):
return
t
.
pformat
({
cont
:
fmtstr
})
else
:
return
t
.
pformat
({
cont
:
cls
(
fmtstr
,
*
(
holes
+
(
cont
,)))})
return
t
.
pformat
({
cont
:
cls
(
fmtstr
,
*
(
holes
+
(
cont
,)))})
return
cls
(
"{0}"
,
cont
),
cont
...
...
diffoscope/profiling.py
View file @
ff57b860
...
...
@@ -34,7 +34,7 @@ def profile(namespace, key):
ProfileManager
().
increment
(
start
,
namespace
,
key
)
class
ProfileManager
(
object
)
:
class
ProfileManager
:
_singleton
=
{}
def
__init__
(
self
):
...
...
diffoscope/progress.py
View file @
ff57b860
...
...
@@ -46,7 +46,7 @@ class ProgressLoggingHandler(logging.StreamHandler):
self
.
handleError
(
record
)
class
ProgressManager
(
object
)
:
class
ProgressManager
:
_singleton
=
{}
def
__init__
(
self
):
...
...
@@ -120,7 +120,7 @@ class ProgressManager(object):
x
.
finish
()
class
Progress
(
object
)
:
class
Progress
:
def
__init__
(
self
,
total
=
None
):
self
.
done
=
[]
self
.
current_steps
=
None
...
...
@@ -196,7 +196,7 @@ class Progress(object):
self
.
current_child_steps_done
+=
total
class
ProgressBar
(
object
)
:
class
ProgressBar
:
def
__init__
(
self
):
import
progressbar
...
...
@@ -269,7 +269,7 @@ class ProgressBar(object):
self
.
bar
.
finish
()
class
StatusFD
(
object
)
:
class
StatusFD
:
def
__init__
(
self
,
fileobj
):
self
.
fileobj
=
fileobj
...
...
Prev
1
2
Next