Fix some flake8 and deprecation warnings

Gbp-Dch: Ignore
Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent 190a572a
Pipeline #24522 passed with stage
in 12 minutes and 8 seconds
......@@ -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):
......
......@@ -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:
......
......@@ -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>"""
......@@ -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 {{}} \\;'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment