[Reproducible-commits] [debbindiff] 03/03: Don't be quadratic when parsing .mo header
Jérémy Bobbio
lunar at moszumanska.debian.org
Wed Jun 24 13:29:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository debbindiff.
commit ccb3054a7f14998de58eca70eb10f8af4a994638
Author: Jérémy Bobbio <lunar at debian.org>
Date: Wed Jun 24 13:28:16 2015 +0000
Don't be quadratic when parsing .mo header
---
debbindiff/comparators/gettext.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/debbindiff/comparators/gettext.py b/debbindiff/comparators/gettext.py
index 8bba053..98304f8 100644
--- a/debbindiff/comparators/gettext.py
+++ b/debbindiff/comparators/gettext.py
@@ -19,6 +19,7 @@
import re
import subprocess
+from StringIO import StringIO
from debbindiff import tool_required
from debbindiff.comparators.utils import binary_fallback, Command
from debbindiff.difference import Difference
@@ -30,7 +31,7 @@ class Msgunfmt(Command):
def __init__(self, *args, **kwargs):
super(Msgunfmt, self).__init__(*args, **kwargs)
- self._header = ''
+ self._header = StringIO()
self._encoding = None
@tool_required('msgunfmt')
@@ -39,15 +40,15 @@ class Msgunfmt(Command):
def filter(self, line):
if not self._encoding:
- self._header += line
+ self._header.write(line)
if line == '\n':
logger.debug("unable to determine PO encoding, let's hope it's utf-8")
self._encoding = 'utf-8'
- return self._header
+ return self._header.getvalue()
found = Msgunfmt.CHARSET_RE.match(line)
if found:
self._encoding = found.group(1).lower()
- return self._header.decode(self._encoding).encode('utf-8')
+ return self._header.getvalue().decode(self._encoding).encode('utf-8')
return ''
if self._encoding != 'utf-8':
return line.decode(self._encoding).encode('utf-8')
--
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