[Reproducible-commits] [debbindiff] 01/01: Decode msgunfmt output using actual PO charset
Jérémy Bobbio
lunar at moszumanska.debian.org
Sun Mar 29 12:47:00 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 112bd5e8a611d92bb5c2d8ee4ee8ae3412eb5051
Author: Jérémy Bobbio <lunar at debian.org>
Date: Sun Mar 29 14:46:53 2015 +0200
Decode msgunfmt output using actual PO charset
---
debbindiff/comparators/gettext.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/debbindiff/comparators/gettext.py b/debbindiff/comparators/gettext.py
index 26a20e5..5e803eb 100644
--- a/debbindiff/comparators/gettext.py
+++ b/debbindiff/comparators/gettext.py
@@ -17,15 +17,24 @@
# You should have received a copy of the GNU General Public License
# along with debbindiff. If not, see <http://www.gnu.org/licenses/>.
+import re
import subprocess
from debbindiff import tool_required
from debbindiff.comparators.utils import binary_fallback
from debbindiff.difference import Difference
+from debbindiff import logger
@tool_required('msgunfmt')
def msgunfmt(path):
- return subprocess.check_output(['msgunfmt', path], shell=False).decode('utf-8')
+ output = subprocess.check_output(['msgunfmt', path], shell=False)
+ found = re.search(r'^"Content-Type: [^;]+; charset=([^\\]+)\\n"$', output, re.MULTILINE)
+ if found:
+ encoding = found.group(1)
+ else:
+ logger.debug('unable to determine PO encoding, falling back to utf-8')
+ encoding = 'utf-8'
+ return output.decode(encoding)
@binary_fallback
--
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