Moved filessearch parameters from main to files.search
authorEugene Gagarin <mosfet07@ya.ru>
Wed, 20 May 2009 13:21:11 +0000 (17:21 +0400)
committerEugene Gagarin <mosfet07@ya.ru>
Wed, 20 May 2009 13:21:11 +0000 (17:21 +0400)
src/files/search.py
src/main.py

index 6a85191..fc6feab 100755 (executable)
@@ -21,8 +21,8 @@ OUTTYPES = [
 
 class Control(object):
 
-    def __init__(self, ui, params):
-        self.present = eval(ui + '_Presentation(self.start_search, params)')
+    def __init__(self, ui, outtype, params):
+        self.present = eval(ui + '_Presentation(self.start_search, outtype, params)')
         self.abstrac = Abstraction(self.present)
 
         self.toplevel = self.present.toplevel
@@ -89,13 +89,17 @@ class Abstraction(object):
 #==============================================================================
 
 class Cli_Presentation(object):
-    def __init__(self, start_func, params):
+    def __init__(self, start_func, outtype, params):
         self.start_func = start_func
 
-        self.outtype = params['outtype']
-        self.start_path = params['start_path']
-        self.count = params['count']
-        self.file_filter = params['file_filter'].split(';')
+        self.outtype = outtype
+        self.start_path = params[0]
+        self.count = params[1]
+        try:
+            self.file_filter = params[2].split(';')
+        except IndexError:
+            self.file_filter = '*.*'
+
         self.stopit = False
 
         self.toplevel = None
@@ -128,7 +132,7 @@ class Cli_Presentation(object):
 
 class Gtk_Presentation(object):
 
-    def __init__(self, start_func, __):
+    def __init__(self, start_func, *unused):
         import gtk
         global gtk  # for show_current_status()
         from misc import NotebookWCloseBtns
index e118510..2f65db1 100755 (executable)
@@ -59,19 +59,9 @@ class Cli_Presentation(object):
         parser.add_option('--license', action='callback', callback=self._license)
         (options, args) = parser.parse_args()
 
-        self.search = options.search
-
-        self.options = {}
-        self.options['outtype'] = options.output
-        self.options['ignore_dirs'] = config['files']['ignore_dirs']
-
-        self.params = options.params.split()
-        self.options['start_path'] = self.params[0]
-        self.options['count'] = self.params[1]
-        try:
-            self.options['file_filter'] = self.params[2]
-        except IndexError:
-            self.options['file_filter'] = '*.*'
+        self.search  = options.search
+        self.outtype = options.output
+        self.params  = options.params.split()
 
     def _about(self, *a):
         print self.abstrac.comments
@@ -83,7 +73,7 @@ class Cli_Presentation(object):
 
     def show_search_toplevel(self):
         search_module = __import__(self.search + '.search')
-        search_toplevel = search_module.search.Control('Cli', self.options).run()
+        search_toplevel = search_module.search.Control('Cli', self.outtype, self.params).run()
 
     def run(self):
         self.show_search_toplevel()