Implemented draft of config globalization - by Wall
[findit] / src / main.py
index 66e787e..2a8e06b 100755 (executable)
@@ -1,11 +1,11 @@
 #!/usr/bin/env python
 # -*-coding: utf-8 -*-
 # vim: sw=4 ts=4 expandtab ai
-# main.py --search files -o outtable -p ". 3"
+# main.py --search files -o out_table -p ". 3"
 
-import sys
+import sys ###
 
-from config import Config
+from config import config
 from misc import _
 
 __progname__ = 'FindIT'
@@ -15,15 +15,13 @@ __version__ = '0.2.0'
 
 class Control(object):
     def __init__(self):
-        config = Config ###()
-
         self.abstrac = Abstraction()
 
         if(len(sys.argv) > 1):  ###
-            self.present = Cli_Presentation(self.abstrac)  ###
+            self.present = Cli_Presentation(self.abstrac)
         else:
             import gtk; global gtk
-            self.present = Gtk_Presentation(config, self.abstrac)  ###
+            self.present = Gtk_Presentation(self.abstrac)
 
     def run(self):
         self.present.run()
@@ -62,11 +60,12 @@ class Cli_Presentation(object):
         parser.add_option('--license', action='callback', callback=self._license)
         (options, args) = parser.parse_args()
 
-        self.config = {}
-        self.config['search'] = options.search
-        self.config['outtype'] = options.output
-        self.config['ignore_dirs'] = ['/dev', '/proc', '/sys', '/mnt']
-        self.config['start_path'], self.config['count'] = options.params.split()
+        self.search = options.search
+
+        self.params = {}
+        self.params['outtype'] = options.output
+        self.params['ignore_dirs'] = config['files']['ignore_dirs']  ###
+        self.params['start_path'], self.params['count'] = options.params.split()
 
     def _about(self, *a):
         print self.abstrac.comments
@@ -77,8 +76,8 @@ class Cli_Presentation(object):
         sys.exit()
 
     def show_search_toplevel(self):
-        search_module = __import__(self.config['search'] + '.search')
-        search_toplevel = search_module.search.Control('Cli', self.config).run()
+        search_module = __import__(self.search + '.search')
+        search_toplevel = search_module.search.Control('Cli', self.params).run()
 
     def run(self):
         self.show_search_toplevel()
@@ -88,8 +87,7 @@ class Cli_Presentation(object):
 class Gtk_Presentation(object):
     """Main window class."""
 
-    def __init__(self, config, abstrac):
-        self.config = config
+    def __init__(self, abstrac):
 
         def _create_menu():
             """Create main menu."""
@@ -125,7 +123,7 @@ class Gtk_Presentation(object):
 
             # Activate radio tool button
             for btn in search_tbtns:
-                if btn.get_name() == self.config['search']:
+                if btn.get_name() == config['search']:
                     btn.set_active(True)
 
             return toolbar
@@ -155,7 +153,7 @@ class Gtk_Presentation(object):
         self.vbox = gtk.VBox(False, 4)
         self.vbox.pack_start(menu, False, False, 0)
         self.vbox.pack_start(toolbar, False, False, 0)
-        self.show_search_toplevel(None, self.config['search'])
+        self.show_search_toplevel(None, config['search'])
 
         self.window.add(self.vbox)
 
@@ -164,7 +162,7 @@ class Gtk_Presentation(object):
         print 'Entering <' + searchtype + '> search mode...'
 
         search_module = __import__(searchtype + '.search')
-        search = search_module.search.Control('Gtk', self.config)
+        search = search_module.search.Control('Gtk', None)
         search_toplevel = search.toplevel
 
         try:
@@ -183,8 +181,8 @@ class Gtk_Presentation(object):
 class Hildon_Presentation(object):
     """Main window class."""
 
-    def __init__(self, config):
-        self.config = config
+    def __init__(self):
+        pass
 
 #==============================================================================