<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>



<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<h3>
Chris Lamb pushed to branch master
at <a href="https://salsa.debian.org/reproducible-builds/diffoscope">Reproducible Builds / diffoscope</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://salsa.debian.org/reproducible-builds/diffoscope/commit/4ba7e6c8657e6d82f8c3d2a97a3677245f1dfe7d">4ba7e6c8</a></strong>
<div>
<span>by Marek Marczykowski-Górecki</span>
<i>at 2018-09-19T09:29:31Z</i>
</div>
<pre class="commit-message" style="white-space: pre-wrap; margin: 0;">comparators/json: Try fuzzy matching for non-text files too. (Closes: #909122)

Non-text files have even less change being json files, so this fuzzy early
elimination is even more useful for them.  In particular, it avoids loading
large files (like ISO images) just to discover it isn't a JSON format.

Signed-off-by: Chris Lamb <lamby@debian.org>
</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class="file-stats">
<a href="#b4e4de1a98f099746e47588b8a2e29a0129e18dd">
diffoscope/comparators/json.py
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id="b4e4de1a98f099746e47588b8a2e29a0129e18dd">
<a href="https://salsa.debian.org/reproducible-builds/diffoscope/commit/4ba7e6c8657e6d82f8c3d2a97a3677245f1dfe7d#b4e4de1a98f099746e47588b8a2e29a0129e18dd"><strong>diffoscope/comparators/json.py</strong></a>
<hr>
<table class="code white" style="font-family: monospace; font-size: 90%;" bgcolor="#fff" width="100%" cellpadding="0" cellspacing="0">
<tr class="line_holder match" id="" style="line-height: 1.6;">
<td class="diff-line-num unfold js-unfold old_line" data-linenumber="37" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">...</td>
<td class="diff-line-num unfold js-unfold new_line" data-linenumber="37" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">...</td>
<td class="line_content match " style="padding-left: 0.5em; padding-right: 0.5em; color: rgba(0,0,0,0.3);" bgcolor="#fafafa">@@ -37,11 +37,7 @@ class JSONFile(File):</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="37" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
37
</td>
<td class="diff-line-num new_line" data-linenumber="37" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
37
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC37" class="line" lang="python">    <span class="k" style="font-weight: 600;">def</span> <span class="nf" style="color: #900; font-weight: 600;">recognizes</span><span class="p">(</span><span class="n" style="color: #333;">cls</span><span class="p">,</span> <span class="nb" style="color: #0086b3;">file</span><span class="p">):</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="38" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
38
</td>
<td class="diff-line-num new_line" data-linenumber="38" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
38
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC38" class="line" lang="python">        <span class="k" style="font-weight: 600;">with</span> <span class="nb" style="color: #0086b3;">open</span><span class="p">(</span><span class="nb" style="color: #0086b3;">file</span><span class="o" style="font-weight: 600;">.</span><span class="n" style="color: #333;">path</span><span class="p">,</span> <span class="s" style="color: #d14;">'rb'</span><span class="p">)</span> <span class="k" style="font-weight: 600;">as</span> <span class="n" style="color: #333;">f</span><span class="p">:</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="39" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
39
</td>
<td class="diff-line-num new_line" data-linenumber="39" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
39
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC39" class="line" lang="python">            <span class="c" style="color: #998; font-style: italic;"># Try fuzzy matching for JSON files</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="" style="line-height: 1.6;">
<td class="diff-line-num old old_line" data-linenumber="40" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
40
</td>
<td class="diff-line-num new_line old" data-linenumber="40" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content noteable_line old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC40" class="line" lang="python">            <span class="n" style="color: #333;">is_text</span> <span class="o" style="font-weight: 600;">=</span> <span class="nb" style="color: #0086b3;">any</span><span class="p">(</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="" style="line-height: 1.6;">
<td class="diff-line-num old old_line" data-linenumber="41" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
41
</td>
<td class="diff-line-num new_line old" data-linenumber="40" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content noteable_line old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC41" class="line" lang="python">                <span class="nb" style="color: #0086b3;">file</span><span class="o" style="font-weight: 600;">.</span><span class="n" style="color: #333;">magic_file_type</span><span class="o" style="font-weight: 600;">.</span><span class="n" style="color: #333;">startswith</span><span class="p">(</span><span class="n" style="color: #333;">x</span><span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="" style="line-height: 1.6;">
<td class="diff-line-num old old_line" data-linenumber="42" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
42
</td>
<td class="diff-line-num new_line old" data-linenumber="40" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content noteable_line old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC42" class="line" lang="python">                <span class="k" style="font-weight: 600;">for</span> <span class="n" style="color: #333;">x</span> <span class="ow" style="font-weight: 600;">in</span> <span class="p">(</span><span class="s" style="color: #d14;">'ASCII text'</span><span class="p">,</span> <span class="s" style="color: #d14;">'UTF-8 Unicode text'</span><span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="" style="line-height: 1.6;">
<td class="diff-line-num old old_line" data-linenumber="43" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
43
</td>
<td class="diff-line-num new_line old" data-linenumber="40" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content noteable_line old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC43" class="line" lang="python">            <span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="" style="line-height: 1.6;">
<td class="diff-line-num old old_line" data-linenumber="44" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
44
</td>
<td class="diff-line-num new_line old" data-linenumber="40" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content noteable_line old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC44" class="line" lang="python">            <span class="k" style="font-weight: 600;">if</span> <span class="n" style="color: #333;">is_text</span> <span class="ow" style="font-weight: 600;">and</span> <span class="ow" style="font-weight: 600;">not</span> <span class="nb" style="color: #0086b3;">file</span><span class="o" style="font-weight: 600;">.</span><span class="n" style="color: #333;">name</span><span class="o" style="font-weight: 600;">.</span><span class="n" style="color: #333;">endswith</span><span class="p">(</span><span class="s" style="color: #d14;">'.json'</span><span class="p">):</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="" style="line-height: 1.6;">
<td class="diff-line-num new old_line" data-linenumber="45" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="40" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
40
</td>
<td class="line_content new noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC40" class="line" lang="python">            <span class="k" style="font-weight: 600;">if</span> <span class="ow" style="font-weight: 600;">not</span> <span class="nb" style="color: #0086b3;">file</span><span class="o" style="font-weight: 600;">.</span><span class="n" style="color: #333;">name</span><span class="o" style="font-weight: 600;">.</span><span class="n" style="color: #333;">endswith</span><span class="p">(</span><span class="s" style="color: #d14;">'.json'</span><span class="p">):</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="45" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
45
</td>
<td class="diff-line-num new_line" data-linenumber="41" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
41
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC41" class="line" lang="python">                <span class="n" style="color: #333;">buf</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">f</span><span class="o" style="font-weight: 600;">.</span><span class="n" style="color: #333;">read</span><span class="p">(</span><span class="mi" style="color: #099;">10</span><span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="46" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
46
</td>
<td class="diff-line-num new_line" data-linenumber="42" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
42
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC42" class="line" lang="python">                <span class="k" style="font-weight: 600;">if</span> <span class="ow" style="font-weight: 600;">not</span> <span class="nb" style="color: #0086b3;">any</span><span class="p">(</span><span class="n" style="color: #333;">x</span> <span class="ow" style="font-weight: 600;">in</span> <span class="n" style="color: #333;">buf</span> <span class="k" style="font-weight: 600;">for</span> <span class="n" style="color: #333;">x</span> <span class="ow" style="font-weight: 600;">in</span> <span class="n" style="color: #333;">b</span><span class="s" style="color: #d14;">'{['</span><span class="p">):</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="47" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
47
</td>
<td class="diff-line-num new_line" data-linenumber="43" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
43
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC43" class="line" lang="python">                    <span class="k" style="font-weight: 600;">return</span> <span class="bp" style="color: #999;">False</span></span>
</pre>
</td>
</tr>

</table>
<br>
</li>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">

<br>
<a href="https://salsa.debian.org/reproducible-builds/diffoscope/commit/4ba7e6c8657e6d82f8c3d2a97a3677245f1dfe7d">View it on GitLab</a>.
<br>
You're receiving this email because of your account on salsa.debian.org.
If you'd like to receive fewer emails, you can
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://salsa.debian.org/reproducible-builds/diffoscope/commit/4ba7e6c8657e6d82f8c3d2a97a3677245f1dfe7d"}}</script>
</p>
</div>
</body>
</html>