[Git][reproducible-builds/diffoscope][master] Fix some flake8 and deprecation warnings
Mattia Rizzolo
gitlab at salsa.debian.org
Thu Nov 8 12:39:02 CET 2018
Mattia Rizzolo pushed to branch master at Reproducible Builds / diffoscope
Commits:
becf992a by Mattia Rizzolo at 2018-11-08T11:38:42Z
Fix some flake8 and deprecation warnings
Gbp-Dch: Ignore
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
- - - - -
4 changed files:
- diffoscope/comparators/rpm_fallback.py
- diffoscope/presenters/html/html.py
- diffoscope/presenters/html/templates.py
- tests/test_presenters.py
Changes:
=====================================
diffoscope/comparators/rpm_fallback.py
=====================================
@@ -23,7 +23,7 @@ from .utils.file import File
class AbstractRpmFile(File):
- FILE_TYPE_RE = re.compile('^RPM\s')
+ FILE_TYPE_RE = re.compile(r'^RPM\s')
class RpmFile(AbstractRpmFile):
=====================================
diffoscope/presenters/html/html.py
=====================================
@@ -133,7 +133,7 @@ def convert(s, ponct=0, tag=''):
elif c == " " and ponct == 1:
t.write('<span class="diffponct">\xb7</span>')
elif c == "\n" and ponct == 1:
- t.write('<br/><span class="diffponct">\</span>')
+ t.write('<br/><span class="diffponct">\\</span>')
elif ord(c) < 32:
conv = u"\\x%x" % ord(c)
t.write('<em>%s</em>' % conv)
@@ -243,7 +243,7 @@ def output_node(ctx, difference, path, indentstr, indentnum):
# Add holes for child nodes
for d in difference.details:
child = output_node_frame(
- d, path + [d], indentstr, indentnum +1, PartialString.of(d))
+ d, path + [d], indentstr, indentnum + 1, PartialString.of(d))
child = PartialString.numl(u"""{0[1]}<div class="difference">
{1}{0[1]}</div>
{-1}""", 2, cont).pformatl(indent, child)
@@ -515,7 +515,7 @@ class HTMLSideBySidePresenter(object):
it.close()
self.spl_print_exit(None, None, None)
return
- except:
+ except Exception:
import traceback
traceback.print_exc()
if self.spl_print_exit(*sys.exc_info()) is False:
=====================================
diffoscope/presenters/html/templates.py
=====================================
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
-HEADER = u"""<!DOCTYPE html>
+HEADER = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
@@ -30,12 +30,16 @@ HEADER = u"""<!DOCTYPE html>
<body class="diffoscope">
"""
-FOOTER = u"""<div class="footer">Generated by <a href="https://diffoscope.org" rel="noopener noreferrer" target="_blank">diffoscope</a> %(version)s</div>
+FOOTER = """<div class="footer">
+Generated by
+<a href="https://diffoscope.org" rel="noopener noreferrer" target="_blank">
+diffoscope</a> %(version)s
+</div>
</body>
</html>
"""
-STYLES = u"""body.diffoscope {
+STYLES = """body.diffoscope {
background: white;
color: black;
}
@@ -135,7 +139,7 @@ STYLES = u"""body.diffoscope {
}
"""
-SCRIPTS = u"""<script src="%(jquery_url)s"></script>
+SCRIPTS = r"""<script src="%(jquery_url)s"></script>
<script type="text/javascript">
$(function() {
// activate "loading" controls
@@ -213,24 +217,24 @@ $(function() {
</style>
"""
-DIFFNODE_LAZY_LOAD = u"""<div class="ondemand-details" title="the size refers to the raw diff and includes all children;
+DIFFNODE_LAZY_LOAD = """<div class="ondemand-details" title="the size refers to the raw diff and includes all children;
only the top %(pagesize)s of the HTML are loaded at a time">... <a
href="%(pagename)s.html">load details (total %(size)s)</a> ...</div>
"""
-DIFFNODE_LIMIT = u"""<div class="error">Max report size reached</div>
+DIFFNODE_LIMIT = """<div class="error">Max report size reached</div>
"""
-UD_TABLE_HEADER = u"""<table class="diff">
+UD_TABLE_HEADER = """<table class="diff">
<colgroup><col class="colines"/><col class="coldiff"/>
<col class="colines"/><col class="coldiff"/></colgroup>
"""
-UD_TABLE_FOOTER = u"""<tr class="ondemand"><td colspan="4">
+UD_TABLE_FOOTER = """<tr class="ondemand"><td colspan="4">
... <a href="%(filename)s">%(text)s</a> ...
</td></tr>
"""
-UD_TABLE_LIMIT_FOOTER = u"""<tr class="error"><td colspan="4">
+UD_TABLE_LIMIT_FOOTER = """<tr class="error"><td colspan="4">
Max %(limit_type)s reached; %(bytes_left)s/%(bytes_total)s bytes (%(percent).2f%%) of diff not shown.
</td></tr>"""
=====================================
tests/test_presenters.py
=====================================
@@ -230,13 +230,13 @@ def test_partial_string_numl():
def test_partial_string_escape():
tmpl = PartialString.numl("find {0} -name {1} " +
- PartialString.escape("-exec ls -la {} \;"), 2)
+ PartialString.escape(r"-exec ls -la {} \;"), 2)
assert tmpl == PartialString(
'find {0} -name {1} -exec ls -la {{}} \\;', *tmpl.holes)
assert tmpl.size() == 33
assert tmpl.size(4) == 39
assert tmpl == PartialString.numl(
- "find {0} -name {1} -exec ls -la {2} \;", 3).pformat({2: "{}"})
+ r"find {0} -name {1} -exec ls -la {2} \;", 3).pformat({2: "{}"})
assert (tmpl.pformatl("my{}path", "my{}file") ==
PartialString('find my{{}}path -name my{{}}file -exec ls -la {{}} \\;'))
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/becf992aac0c710fe4d2d69cdb7c8763776043d5
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/becf992aac0c710fe4d2d69cdb7c8763776043d5
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20181108/e611b8d4/attachment.html>
More information about the rb-commits
mailing list