[Reproducible-commits] [debbindiff] 15/19: Convert sng to Command class
Jérémy Bobbio
lunar at moszumanska.debian.org
Tue Mar 31 14:59:29 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch pu/feed-diff
in repository debbindiff.
commit eee9fcb427db25f73fb7c0fd4bbfe1a6d43b5aec
Author: Jérémy Bobbio <lunar at debian.org>
Date: Mon Mar 30 17:32:41 2015 +0200
Convert sng to Command class
---
debbindiff/comparators/png.py | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/debbindiff/comparators/png.py b/debbindiff/comparators/png.py
index 3969b5a..482ff37 100644
--- a/debbindiff/comparators/png.py
+++ b/debbindiff/comparators/png.py
@@ -17,28 +17,30 @@
# You should have received a copy of the GNU General Public License
# along with debbindiff. If not, see <http://www.gnu.org/licenses/>.
+from functools import partial
import subprocess
from debbindiff import tool_required
-from debbindiff.comparators.utils import binary_fallback
+from debbindiff.comparators.utils import binary_fallback, Command
from debbindiff.difference import Difference
- at tool_required('sng')
-def sng(path):
- with open(path) as f:
- p = subprocess.Popen(['sng'], shell=False, close_fds=True,
- stdin=f, stdout=subprocess.PIPE)
- out, err = p.communicate()
- p.wait()
- if p.returncode != 0:
- return 'sng exited with error %d\n%s' % (p.returncode, err)
- return out.decode('utf-8')
+class Sng(Command):
+ @tool_required('sng')
+ def cmdline(self):
+ return ['sng']
+
+ def feed_stdin(self, stdin):
+ try:
+ with open(self.path) as f:
+ for buf in iter(partial(f.read, 32768), b''):
+ stdin.write(buf)
+ finally:
+ stdin.close()
+
@binary_fallback
def compare_png_files(path1, path2, source=None):
- sng1 = sng(path1)
- sng2 = sng(path2)
- difference = Difference.from_unicode(sng1, sng2, path1, path2, source='sng')
+ difference = Difference.from_command(Sng, path1, path2, source='sng')
if not difference:
return []
return [difference]
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git
More information about the Reproducible-commits
mailing list