moved size_convert function and about dialog outside MVC scope
[findit] / src / mvc / controllers / filesearch.py
index dbb2bee..17e1d8c 100755 (executable)
@@ -10,8 +10,8 @@ from os import walk
 from os.path import join, abspath, normcase, getsize
 from heapq import nlargest
 
-#from filesearch import FilesearchCtrl
 from views.filesearch import FilesearchView
+from misc.functions import *
 
 
 class FilesearchCtrl(Controller):
@@ -66,14 +66,6 @@ class FilesearchCtrl(Controller):
                 except OSError:
                     continue
 
-    def size_convert(self, size):
-        """Return string with file size in b or Kb or Mb or Gb or Tb."""
-
-        for i, unit in enumerate(['%d b', '%.1f Kb', '%.2f Mb', '%.3f Gb', '%.4f Tb']):
-            if size < 1024**(i+1):
-                return unit % (size/1024.**i)
-        return '>1024 Tb'
-
     # -----------------------------------------------------
     #                    gtk signals
     # -----------------------------------------------------
@@ -102,7 +94,7 @@ class FilesearchCtrl(Controller):
         for fsize, fpath in nlargest(self.model.quantity, self.filegetter(start_path)):
             # Заполняем treemodel: путь, размер в Мб строкой, размер в байтах
 #             try:
-                self.view['liststore'].append([fpath, self.size_convert(fsize), fsize])
+                self.view['liststore'].append([fpath, size_convert(fsize), fsize])
 #             except:
 #                 print type(fpath), type(self.size_convert(fsize)), type(fsize)