[jhbuild/wip/sam/python3] Further fixups



commit c41d6bb3bb7190a6f04f951ee29160add7119420
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Wed Jan 27 15:22:16 2016 +0100

    Further fixups

 jhbuild/modtypes/autotools.py |    2 +-
 jhbuild/utils/fileutils.py    |    4 ++--
 jhbuild/utils/packagedb.py    |   12 ++++++++----
 3 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index 743ec0b..be36d9c 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -179,7 +179,7 @@ class AutogenModule(MakeModule, DownloadableModule):
             configure_hash = db_entry.metadata.get('configure-hash')
             if configure_hash:
                 configure_cmd = self._get_configure_cmd(buildscript)
-                if hashlib.md5(configure_cmd).hexdigest() != configure_hash:
+                if hashlib.md5(configure_cmd.encode('unicode-escape')).hexdigest() != configure_hash:
                     return False
             else:
                 # force one-time reconfigure if no configure-hash
diff --git a/jhbuild/utils/fileutils.py b/jhbuild/utils/fileutils.py
index 46d1716..ae49d71 100644
--- a/jhbuild/utils/fileutils.py
+++ b/jhbuild/utils/fileutils.py
@@ -126,10 +126,10 @@ def mkdir_with_parents(filename):
             raise
 
 class SafeWriter(object):
-    def __init__(self, filename):
+    def __init__(self, filename, mode='w', encoding=None):
         self.filename = filename
         self.tmpname = filename + '.tmp'
-        self.fp = open(self.tmpname, 'w')
+        self.fp = open(self.tmpname, mode, encoding=encoding)
 
     def commit(self):
         self.fp.flush()
diff --git a/jhbuild/utils/packagedb.py b/jhbuild/utils/packagedb.py
index b7924f0..8bf1b11 100644
--- a/jhbuild/utils/packagedb.py
+++ b/jhbuild/utils/packagedb.py
@@ -78,14 +78,18 @@ class PackageEntry:
     def write(self):
         # write info file
         fileutils.mkdir_with_parents(os.path.join(self.dirname, 'info'))
-        writer = fileutils.SafeWriter(os.path.join(self.dirname, 'info', self.package))
-        ET.ElementTree(self.to_xml()).write(writer.fp)
-        writer.fp.write('\n')
+        writer = fileutils.SafeWriter(
+            os.path.join(self.dirname, 'info', self.package),
+            mode='wb')
+        ET.ElementTree(self.to_xml()).write(writer.fp, encoding='utf-8')
+        writer.fp.write('\n'.encode('utf-8'))
         writer.commit()
 
         # write manifest
         fileutils.mkdir_with_parents(os.path.join(self.dirname, 'manifests'))
-        writer = fileutils.SafeWriter(os.path.join(self.dirname, 'manifests', self.package))
+        writer = fileutils.SafeWriter(
+            os.path.join(self.dirname, 'manifests', self.package),
+            encoding='utf-8')
         writer.fp.write('\n'.join(self.manifest) + '\n')
         writer.commit()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]