changeset 38840:040712a0e597

gnulib-tool.py: follow gnulib-tool changes, part 14 Follow gnulib-tool change 2015-08-20 Daiki Ueno <ueno@gnu.org> gnulib-tool: don't transform binary files with sed
author Bruno Haible <bruno@clisp.org>
date Sat, 09 Sep 2017 14:40:10 +0200
parents 7a3e867d5bee
children b48d266a3649
files pygnulib/GLFileSystem.py
diffstat 1 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/pygnulib/GLFileSystem.py	Sat Sep 09 14:18:56 2017 +0200
+++ b/pygnulib/GLFileSystem.py	Sat Sep 09 14:40:10 2017 +0200
@@ -341,26 +341,28 @@
             shutil.copy(lookedup, tmpfile)
         except Exception as error:
             raise(GLError(15, lookedup))
-        transformer = string()
-        if original.startswith('lib/'):
-            if sed_transform_main_lib_file:
-                transformer = sed_transform_main_lib_file
-        elif original.startswith('build-aux/'):
-            if sed_transform_build_aux_file:
-                transformer = sed_transform_build_aux_file
-        elif original.startswith('tests=lib/'):
-            if sed_transform_testsrelated_lib_file:
-                transformer = sed_transform_testsrelated_lib_file
-        if transformer:
-            args = ['sed', '-e', transformer]
-            stdin = codecs.open(lookedup, 'rb', 'UTF-8')
-            try:  # Try to transform file
-                data = sp.check_output(args, stdin=stdin, shell=False)
-                data = data.decode("UTF-8")
-            except Exception as error:
-                raise(GLError(16, lookedup))
-            with codecs.open(tmpfile, 'wb', 'UTF-8') as file:
-                file.write(data)
+        # Don't process binary files with sed.
+        if not (original.endswith(".class") or original.endswith(".mo")):
+            transformer = string()
+            if original.startswith('lib/'):
+                if sed_transform_main_lib_file:
+                    transformer = sed_transform_main_lib_file
+            elif original.startswith('build-aux/'):
+                if sed_transform_build_aux_file:
+                    transformer = sed_transform_build_aux_file
+            elif original.startswith('tests=lib/'):
+                if sed_transform_testsrelated_lib_file:
+                    transformer = sed_transform_testsrelated_lib_file
+            if transformer:
+                args = ['sed', '-e', transformer]
+                stdin = codecs.open(lookedup, 'rb', 'UTF-8')
+                try:  # Try to transform file
+                    data = sp.check_output(args, stdin=stdin, shell=False)
+                    data = data.decode("UTF-8")
+                except Exception as error:
+                    raise(GLError(16, lookedup))
+                with codecs.open(tmpfile, 'wb', 'UTF-8') as file:
+                    file.write(data)
         path = joinpath(self.config['destdir'], rewritten)
         if isfile(path):
             self.update(lookedup, tmpflag, tmpfile, already_present)