From a4191c846e29a203f0f8512dada72a3d64b603e6 Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Thu, 26 May 2011 17:06:00 +0200
Subject: [PATCH] move md5sum into tools module

---
 installsystems/image.py | 10 ++--------
 installsystems/tools.py |  6 ++++++
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/installsystems/image.py b/installsystems/image.py
index 8c6eb04..03debe3 100644
--- a/installsystems/image.py
+++ b/installsystems/image.py
@@ -51,12 +51,6 @@ class Image(object):
                 return os.path.join(os.path.abspath(d), name)
         return None
 
-    def md5_checksum(self, path):
-        '''Compute md5 of a file'''
-        m = hashlib.md5()
-        m.update(open(path, "r").read())
-        return m.hexdigest()
-
 class SourceImage(Image):
     '''Image source manipulation class'''
 
@@ -239,7 +233,7 @@ class SourceImage(Image):
             arrow("Compute MD5 of %s" % dt, 2, self.verbose)
             path = os.path.join(self.base_path, dt)
             desc["data"][dt] = { "size": os.path.getsize(path),
-                                 "md5": self.md5_checksum(path) }
+                                 "md5": istools.md5sum(path) }
         # create file
         filedesc = StringIO.StringIO()
         # serialize
@@ -294,7 +288,7 @@ class PackageImage(Image):
         for databall in databalls:
             arrow(databall, 2, self.verbose)
             md5_meta = databalls[databall]["md5"]
-            md5_file = self.md5_checksum(os.path.join(self.base_path, databall))
+            md5_file = istools.md5sum(os.path.join(self.base_path, databall))
             if md5_meta != md5_file:
                 raise Exception("Invalid md5: %s" % databall)
 
diff --git a/installsystems/tools.py b/installsystems/tools.py
index 879a619..3e86de2 100644
--- a/installsystems/tools.py
+++ b/installsystems/tools.py
@@ -9,6 +9,12 @@ InstallSystems Generic Tools Library
 import os
 from installsystems.image import Image
 
+def md5sum(self, path):
+    '''Compute md5 of a file'''
+    m = hashlib.md5()
+    m.update(open(path, "r").read())
+    return m.hexdigest()
+
 def cp(self, source, destination):
     '''Copy a source to destination. Take care of path type'''
     stype = path_type(source)
-- 
GitLab